-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Predict black images #5
Comments
Hi Tanveer,
Thanks for reaching out - probably the issue is that you are not
normalizing the input correctly.
Here you can find the correct function used as "transform":
transform = transforms.Compose([
transforms.Resize((256, 256)),
transforms.ToTensor(),
lambda x: x if x.shape[0] == 3 else x.repeat(3, 1, 1),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224,
0.225]),
])
Hope this help.
Best,
Guglielmo
…On Wed, Jun 14, 2023 at 10:50 AM Tanveer Hussain ***@***.***> wrote:
def preprocess_image(img):
transform = T.Compose([T.Resize((256, 256)), T.ToTensor()])
x = transform(img)
x = torch.unsqueeze(x, 0)
x = x.cuda()
return x
def postprocess_image(preds, H, W):
# preds = F.softmax(output, 1).argmax(1)[0] * 255 # [h, w]
preds = Image.fromarray(preds.numpy().astype(np.uint8), 'L')
preds = preds.resize((W, H))
return preds
—
Reply to this email directly, view it on GitHub
<#5 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHUB6O3Z5PEYIQRHEEUOV73XLF3OLANCNFSM52TPGT6A>
.
You are receiving this because you modified the open/close state.Message
ID: <guglielmocamporese/hands-segmentation-pytorch/issues/5/1590759638@
github.com>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, why the model predicts a black image?
If I pass as input a jpg image:
Same behaviour with other images.
I downloaded the pretrained model using these lines of code you provided in the README:
Then I created the dir "checkpoint" on your project directory and put the model there.
Finally, I executed the main passing the predict parameters:
Note that I'm using Windows, that's why I didn't run the sh(s) you provided.
Thanks for your time!
The text was updated successfully, but these errors were encountered: