Comments (7)
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.
@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.
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.
@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.
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.
Hmm. let me try that.. Will update
from inspyrenet.
Closing due to inactivity. Please open another issue if problem persists.
from inspyrenet.
Related Issues (20)
- Not getting the same quality as the hugging face web demo model HOT 2
- Train with another shape HOT 1
- Unexpected keys in state_dict when trying inference HOT 1
- Model difference between Res2Net50 Backbone and Res2Net50 [DUTS-TR] trained checkpoint HOT 3
- Unable to reproduce models and Increasing validation loss HOT 1
- `base_size` and `stage` parameters are not used for encoder and decoder HOT 6
- Overflow NaN can be happen in training HOT 1
- unable to load jit model HOT 2
- Some confusion about dynamic_resize HOT 2
- Image mask alignment problem HOT 4
- train custom dataset HOT 2
- Multiple masks area HOT 1
- InSPyReNet for mask refinement? HOT 1
- Fine tuning HOT 9
- InSPyReNet_SwinB_DIS5K_LR Result Download Failed HOT 1
- HR CustomDataset Finetuning HOT 2
- Is this undertrained HOT 1
- Downloading InSPyReNet models and testing them...
- inspyrenet is the best architecture of image segmentation i've used so far, please keep upgrading
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inspyrenet.