mmsegmentation icon indicating copy to clipboard operation
mmsegmentation copied to clipboard

rs_image_inference

Open dongxiaofei12 opened this issue 1 year ago • 4 comments

Why the result is black when I use this.

dongxiaofei12 avatar Sep 18 '24 07:09 dongxiaofei12

And if I want to superimpose my inference onto the original, how do I do that?

dongxiaofei12 avatar Sep 19 '24 03:09 dongxiaofei12

i dont understand your question, but if u want to impose the inference on the original image you can use opacity

config_file = 'pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py' checkpoint_file = 'pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'

config_file = 'segformer_mit-b2_8x1_1024x1024_160k_kitti.py'

checkpoint_file = 'checkpoints/Segformer_B2.pth'

Initialize the model

model = init_model(config_file, checkpoint_file, device='cuda:0')

Load an image

img = 'demo/image.png' # or img = mmcv.imread(img)

Run inference

result = inference_model(model, img)

Save and display the result

output_file = 'result.jpg' show_result_pyplot(model, img, result, show=False, out_file=output_file, opacity=0.5)

image = cv2.imread(output_file) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # Convert BGR to RGB for correct display

plt.figure(figsize=(10, 10)) plt.imshow(image) plt.axis('off') # Turn off axis plt.show()

JohnalDsouza avatar Sep 30 '24 15:09 JohnalDsouza

i dont understand your question, but if u want to impose the inference on the original image you can use opacity

config_file = 'pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py' checkpoint_file = 'pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'

config_file = 'segformer_mit-b2_8x1_1024x1024_160k_kitti.py'

checkpoint_file = 'checkpoints/Segformer_B2.pth'

Initialize the model

model = init_model(config_file, checkpoint_file, device='cuda:0')

Load an image

img = 'demo/image.png' # or img = mmcv.imread(img)

Run inference

result = inference_model(model, img)

Save and display the result

output_file = 'result.jpg' show_result_pyplot(model, img, result, show=False, out_file=output_file, opacity=0.5)

image = cv2.imread(output_file) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # Convert BGR to RGB for correct display

plt.figure(figsize=(10, 10)) plt.imshow(image) plt.axis('off') # Turn off axis plt.show()

thanks.

dongxiaofei12 avatar Oct 03 '24 02:10 dongxiaofei12

i dont understand your question, but if u want to impose the inference on the original image you can use opacity config_file = 'pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py' checkpoint_file = 'pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'

config_file = 'segformer_mit-b2_8x1_1024x1024_160k_kitti.py'

checkpoint_file = 'checkpoints/Segformer_B2.pth'

Initialize the model

model = init_model(config_file, checkpoint_file, device='cuda:0')

Load an image

img = 'demo/image.png' # or img = mmcv.imread(img)

Run inference

result = inference_model(model, img)

Save and display the result

output_file = 'result.jpg' show_result_pyplot(model, img, result, show=False, out_file=output_file, opacity=0.5) image = cv2.imread(output_file) image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # Convert BGR to RGB for correct display plt.figure(figsize=(10, 10)) plt.imshow(image) plt.axis('off') # Turn off axis plt.show()

thanks.How do I use sliding inference if my picture is large?

dongxiaofei12 avatar Oct 03 '24 12:10 dongxiaofei12