Comments (5)
in infer.py, change Line 148 from
Image.fromarray(final).save(save_path)
to
Image.fromarray(final.squeeze()).save(save_path)
from adabins.
Thanks for sharing comment @Rothfeld , np.squeeze resolves this issue
from adabins.
I used .squeeze() function earlier for the same issue on a single PIL image and it worked perfectly and I assumed it should resolve when trying to do for the whole image directory. But, unexpectedly, .squeeze() function doesn't resolve the issue for that part, any ideas?
Input
# predict depths of images stored in a directory and store the predictions in 16-bit format in a given separate dir
infer_helper.predict_dir("test_imgs", "test_imgs_results") #test_imgs_results is a new directory to store output
Output
KeyError Traceback (most recent call last)
D:\anaconda3\lib\site-packages\PIL\Image.py in fromarray(obj, mode)
2750 try:
-> 2751 mode, rawmode = _fromarray_typemap[typekey]
2752 except KeyError as e:
KeyError: ((1, 1, 480, 640), '<u2')
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
<ipython-input-7-36b5885687fe> in <module>
1 # predict depths of images stored in a directory and store the predictions in 16-bit format in a given separate dir
----> 2 infer_helper.predict_dir("test_imgs", "test_imgs_results")
D:\anaconda3\lib\site-packages\torch\autograd\grad_mode.py in decorate_context(*args, **kwargs)
24 def decorate_context(*args, **kwargs):
25 with self.__class__():
---> 26 return func(*args, **kwargs)
27 return cast(F, decorate_context)
28
<private_repo>\infer.py in predict_dir(self, test_dir, out_dir)
146 save_path = os.path.join(out_dir, basename + ".png")
147
--> 148 Image.fromarray(final.squeeze()).save(save_path) #added .squeeze() to shrink size from 1,1,480,640 to 480,640
149
150
D:\anaconda3\lib\site-packages\PIL\Image.py in fromarray(obj, mode)
2751 mode, rawmode = _fromarray_typemap[typekey]
2752 except KeyError as e:
-> 2753 raise TypeError("Cannot handle this data type: %s, %s" % typekey) from e
2754 else:
2755 rawmode = mode
TypeError: Cannot handle this data type: (1, 1, 480, 640), <u2
from adabins.
@NitishJaiswal it was working in #13
from adabins.
Need Help:
def convert_nifti_to_png(input_path, output_path):
img = nib.load(input_path)
data = img.get_fdata()
data_normalized = (data - np.min(data)) / (np.max(data) - np.min(data))
data_scaled = (data_normalized * 255).astype(np.uint8)
data_3d = np.squeeze(data_scaled)
data_uint8 = data_scaled.astype(np.uint8)
image = Image.fromarray(data_uint8)
image.save(output_path, 'PNG')
KeyError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in fromarray(obj, mode)
2834 try:
-> 2835 mode, rawmode = _fromarray_typemap[typekey]
2836 except KeyError as e:
KeyError: ((1, 1, 10, 30), '|u1')
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
3 frames
/usr/local/lib/python3.10/dist-packages/PIL/Image.py in fromarray(obj, mode)
2835 mode, rawmode = _fromarray_typemap[typekey]
2836 except KeyError as e:
-> 2837 raise TypeError("Cannot handle this data type: %s, %s" % typekey) from e
2838 else:
2839 rawmode = mode
TypeError: Cannot handle this data type: (1, 1, 10, 30), |u1
from adabins.
Related Issues (20)
- Training HOT 1
- Outdoor application
- Training KITTI HOT 1
- For the configuration of the SUNRGBD dataset parameters?
- Tran: 0% HOT 1
- About Range attention maps
- RuntimeError: The size of tensor a (4096) must match the size of tensor b (500) at non-singleton dimension 2 HOT 2
- Question about Max, Min Depth Value HOT 1
- Tokens used for regressino & queries HOT 1
- Dataset mentioned in the paper
- Add pretrained models (.pt) to release? HOT 1
- Question about 1-cycle policy
- hello,i do not know the meaning of the train_test_input/*.txt
- RuntimeError: Given groups=1, weight of size [256, 128, 1, 1], expected input[1, 98, 176, 144] to have 128 channels, but got 98 channels instead HOT 1
- How much GPU memory is needed to train this network HOT 1
- bin_widths always turn to 000001
- How to train HOT 1
- RuntimeError: CUDA error: invalid device function
- RuntimeError: Unexpected error from cudaGetDeviceCount()
- Have you compared AdaBins with monodepth2?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.