Open Puhouchen opened 1 year ago
After running grounded_sam_demo.py, the size of the mask and raw image don't match each other. Although the mask can be resized, i wonder why the size of mask has been changed? keeping the same size maybe a normal idea...
Would you like to share the image you've tested for this issue~
thanks for your reply!My command is as follows and images in attachment which have different size:python
grounded_sam_demo.py \ --config GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py \ --grounded_checkpoint groundingdino_swint_ogc.pth \ --sam_checkpoint sam_vit_h_4b8939.pth \ --input_image assets/dophin_and_man.jpeg \ --output_dir "outputs" \ --box_threshold 0.3 \ --text_threshold 0.25 \ --text_prompt "dolphin" \ --device "cuda"
***@***.***
---- Replied Message ----
From
Ren ***@***.***>
Date
5/2/2023 22:06
To
***@***.***>
Cc
***@***.***>
,
***@***.***>
Subject
Re: [IDEA-Research/Grounded-Segment-Anything] The size of the mask and raw image don't match (Issue #210)
After running grounded_sam_demo.py, the size of the mask and raw image don't match each other. Although the mask can be resized, i wonder why the size of mask has been changed? keeping the same size maybe a normal idea...
Would you like to share the image you've tested for this issue~
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
The same problem. the shape of raw image input to the demo is (1280, 853, 3). The output mask's shape is (2310, 1539, 3). The scaling ratio is not a integer.
The size of the mask.jpg depends on the figsize and dpi of the matplotlib used to plot the mask in ‘save_mask_data’ function in ‘grounded_sam_demo.py’ , as for example, using the following code, the size of the mask.jpg will be 3000x3000x3
plt.figure(figsize=(10, 10))
plt.imshow(mask_img.numpy())
plt.axis('off')
plt.savefig(os.path.join(output_dir, 'mask.jpg'), dpi=300, pad_inches=0.0)
# plt.savefig(os.path.join(output_dir, 'mask.jpg'), bbox_inches="tight", dpi=300, pad_inches=0.0)
if your want to use the mask value whose size is equal to raw_jpg , you can just save the variable ‘mask_img’ by
np.save(os.path.join(output_dir,'mask.npy'),mask_img)
After running grounded_sam_demo.py, the size of the mask and raw image don't match each other. Although the mask can be resized, i wonder why the size of mask has been changed? keeping the same size maybe a normal idea...