GithubHelp home page GithubHelp logo

Comments (7)

plemeri avatar plemeri commented on June 9, 2024

Hi @mighty98, the swin transformer backbone is brought from Swin Github Repo. Please refer to the original repository.

If you are trying to run the inference code only to generate mask, then try disable pretrained option.
pretrained option link

Model:
    name: "InSPyReNet_SwinB"
    depth: 64
    pretrained: True --> change this into False
    base_size: [384, 384]
    threshold: 512

Also, you can try using our python API & command line tool transparent-background which is identical to this work but with more user friendly interface.

If you are trying to train on your own, then please feel free to add a comment for more help. I'll help you with this problem in that case.

Thanks.

from inspyrenet.

mighty98 avatar mighty98 commented on June 9, 2024

@plemeri Thank you so much for the reply. I loved transparent-background but over there I see we have to load the state each time i want to infer. It is not working when i load the model once and export the model to infer n times.
Not sure if what i told makes sense without code. But will you be able to help me with it..

Im a newbie on ML and so forgive my dumbness

from inspyrenet.

plemeri avatar plemeri commented on June 9, 2024

I think in your case you need to use our tool as a Python API, not as a command line tool.
Using our tool as a command line tool, a trained checkpoint (state) should be loaded each time. On the other hand, Python API does not load the checkpoint each time you infer the sample. Here are sample code for Python API.

import cv2
import numpy as np

from PIL import Image
from transparent_background import Remover

remover = Remover()

img = Image.open('samples/aeroplane.jpg').convert('RGB') # read image

out = remover.process(img) 
out.save('output.png') # save result

In this script, remover.process function can be called without loading checkpoint each time.
For more usage, please refer to Python API document in ReadMe file.

Please leave more comments if you need more help.

from inspyrenet.

mighty98 avatar mighty98 commented on June 9, 2024

@plemeri Maybe im wrong but if you see the above code we are calling Remover() each time we call this api and at this point the init() function of Remover class is loading the weights.
What i instead tried is creating a Remover() class instance once and export it and try call 'process()' of this exported instance. But on doing so it doesnt work.

from inspyrenet.

plemeri avatar plemeri commented on June 9, 2024

Just don't call remover = Remover() more than once, and call remover.process(img) multiple times which works well.
Here is a simple example using for loop.

import os
import cv2
import numpy as np

from PIL import Image
from transparent_background import Remover

remover = Remover()

imgs = os.listdir('directory/to/images')
for img_file in imgs:
    img = Image.open(img_file).convert('RGB') # read image
    out = remover.process(img) 
    out.save(img_file) # save result

In this case, you don't need to call Remover() more than once.

from inspyrenet.

mighty98 avatar mighty98 commented on June 9, 2024

Hmm. let me try that.. Will update

from inspyrenet.

plemeri avatar plemeri commented on June 9, 2024

Closing due to inactivity. Please open another issue if problem persists.

from inspyrenet.

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.