Skip to content
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

rs_image_inference #3772

Open
dongxiaofei12 opened this issue Sep 18, 2024 · 4 comments
Open

rs_image_inference #3772

dongxiaofei12 opened this issue Sep 18, 2024 · 4 comments

Comments

@dongxiaofei12
Copy link

Why the result is black when I use this.

@dongxiaofei12
Copy link
Author

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

@JohnalDsouza
Copy link

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()

@dongxiaofei12
Copy link
Author

dongxiaofei12 commented Oct 3, 2024

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
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants