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

Please cope with the new version of scipy #3

Open
minoharat opened this issue Sep 18, 2023 · 0 comments
Open

Please cope with the new version of scipy #3

minoharat opened this issue Sep 18, 2023 · 0 comments

Comments

@minoharat
Copy link

Thank you for your aggressive work.

Scipy has changed several specifications in the new version. In those modifications, the 'imread' function has been removed and then the same name function in matplotlib should be used as replacement.

Also, scipy has removed the 'toimage'. So, the 'Image.fromarray' function of PILLOW library should be used.

Please replace the corresponding descriptions in accordance with the changes of scipy as follows:

kitti_to_cityscapes.py:
line 34-35
old:
semantic_img = sp.imread(join(semantic_dir,f))
instance_img = sp.imread(join(instance_dir,f))
new:
semantic_img = plt.imread(join(semantic_dir, f))
instance_img = plt.imread(join(instance_dir, f))
line 57-58
old:
sp.toimage(semantic_img, mode='L').save(out_semantic_filename)
sp.toimage(instance_img, high=np.max(instance_img), low=np.min( instance_img), mode='I').save(out_instance_filename)
new:
Image.fromarray(semantic_img, mode='L').save(out_semantic_filename)
Image.fromarray(instance_img, mode='I').save(out_instance_filename)

The following import command must be added previously.
from PIL import Image

vkitti2_to_cityscapes.py:
perhaps line 71-72:
old:
semantic_img = sp.imread(join(semantic_dir, f.replace('rgb', 'classgt').replace('jpg', 'png')))
instance_img = sp.imread(join(instance_dir, f.replace('rgb', 'instancegt').replace('jpg', 'png')), mode='L')
new:
semantic_img = plt.imread(join(semantic_dir, f.replace('rgb', 'classgt').replace('jpg', 'png')))
instance_img = rgb2gray(plt.imread(join(instance_dir, f.replace('rgb', 'instancegt').replace('jpg', 'png'))))

perhaps line 78-79:
old:
sp.toimage(semantic_rst, mode='L').save(out_semantic_filename)
sp.toimage(instance_rst, high=np.max(instance_rst), low=np.min(instance_rst), mode='I').save(out_instance_filename)
new:
Image.fromarray(semantic_rst, mode='L').save(out_semantic_filename)
Image.fromarray(instance_rst, mode='I').save(out_instance_filename)

The following function must be defined previously. The definition of the function is original in the following web page.

https://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python

def rgb2gray(rgb):
r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
return gray

Sincerely,

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

1 participant