Giter VIP home page Giter VIP logo

Comments (4)

ZHKKKe avatar ZHKKKe commented on June 8, 2024 1

@rebotnix
Thanks for your patience. Our demos and pre-trained models are released.

from modnet.

ZHKKKe avatar ZHKKKe commented on June 8, 2024

Hi, thank you for your good suggestion. See if we can achieve this goal after the code is released. I will @ you when the inference code is available. :)

from modnet.

rebotnix avatar rebotnix commented on June 8, 2024

Hi ZHKKKe,

would like to let you know that i was able to run the inference on NVIDIA NX and AGX. Really good job.

Tested with one image yet, will try video and TRT acceleration soon. See my picture blew.

out

For Developers:
If you want to save the image instead of displaying it, just add

def combined_display(image, matte):
	  # calculate display resolution
	  w, h = image.width, image.height
	  rw, rh = 800, int(h * 800 / (3 * w))
	  
	  # obtain predicted foreground
	  image = np.asarray(image)
	  if len(image.shape) == 2:
	    image = image[:, :, None]
	  if image.shape[2] == 1:
	    image = np.repeat(image, 3, axis=2)
	  elif image.shape[2] == 4:
	    image = image[:, :, 0:3]
	  matte = np.repeat(np.asarray(matte)[:, :, None], 3, axis=2) / 255
	  foreground = image * matte + np.full(image.shape, 255) * (1 - matte)
	  
	  # combine image, foreground, and alpha into one line
	  combined = np.concatenate((image, foreground, matte * 255), axis=1)
	  combined = Image.fromarray(np.uint8(combined)).resize((rw, rh))
	  return combined

Call it

input_folder = "images"
  output_folder = "output"

  image_names = os.listdir(input_folder)

  for image_name in image_names:
  	matte_name = image_name.split('.')[0] + '.png'
  	image = Image.open(os.path.join(input_folder, image_name))
  	matte = Image.open(os.path.join(output_folder, matte_name))
  	res = combined_display(image, matte)
  	res.save("out.png")

Do not need colab or anything else then. Maybe that helps.

from modnet.

ZHKKKe avatar ZHKKKe commented on June 8, 2024

Great! Big thanks!

from modnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.