How to output result image from output?
See original GitHub issueWhen i finished the model training. & load model & input a single image by:
# Image preprocessing
image = cv2.imread(image_path, cv2.IMREAD_COLOR).astype(float)
image = cv2.resize(image, dsize=(512,512))
image_original = image.astype(np.uint8)
image = torch.from_numpy(image.transpose(2, 0, 1)).float().unsqueeze(0)
image = image.to(device)
# Inference
output = Model(image)
output is a tensor & shape is (5,512,512). like:
[[[ 4916.116 5713.0825 6510.0493 ... 8198.43 7449.5635
6700.7207]
[ 5698.8423 6637.15 7575.4585 ... 9693.137 8787.99
7882.872 ]
[ 6481.569 7561.218 8640.867 ... 11187.843 10126.417
9065.023 ]
...
if i want to invert the tensor to labelimage ,What should i do?
if i process output by softmax or argmax or torch.max ,the output will be null image like
[[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
...
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]
[0 0 0 ... 0 0 0]]
It’s a weird question!
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Creating an Output Image File
To actually render the current image into an output file, first set up the graphics in VMD just as you wish the output...
Read more >How to display an image as result of true in a function
So I'm playing around with some code and I'm trying to design a program that displays an image if a true statement results...
Read more >Output an image of your source code (not-quite-a-Quine)
I have just implemented a solution in whitespace. The resulting image looks quite boring.
Read more >ImageOutput: Writing Images - Read the Docs
You may request that the output image pixels be stored in any of several data types. This is done by setting the format...
Read more >Output Image - an overview | ScienceDirect Topics
1. Hardware to output images to the screen and input devices to control the display. This might be called the computer graphics system....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What is your model setting? When I run:
The output size is (1, 21, 513, 513). Then run the following code
I could get the final prediction and the shape of prediction is (513, 513).
Based on the example you provided, I guess the number of classes in your example is 5. So, when you get output, you could run
pred=output.data.cpu().numpy()
andpred=np.argmax(pred, axis=0)
to get the prediction labels, just like what I do above.Hope this could help you 😃
@leedoge hi, I think i have solved this problem. but, maybe no. i forgot because it has already 1 month. You can check your input processing. like have you substract your image with imagenet mean ?
best regards, Albert Christianto