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

How to view pseudolabels images? #8

Open
rst1991 opened this issue Jan 10, 2023 · 5 comments
Open

How to view pseudolabels images? #8

rst1991 opened this issue Jan 10, 2023 · 5 comments

Comments

@rst1991
Copy link

rst1991 commented Jan 10, 2023

Pseudolabels are saved in .npz format. How to visualize it ?

@rst1991
Copy link
Author

rst1991 commented Jan 17, 2023

@cchen-cc Can you please help in generating pseudolabels. I am not able to visualize it.

@cchen-cc
Copy link
Owner

After reading the data from .npz files, you can then plot it out.

@rst1991
Copy link
Author

rst1991 commented Jan 18, 2023

@cchen-cc I am able to read data from .npz file but I am not able to plot it.

import matplotlib.pyplot as plt
import numpy as np
from numpy import load
from torchvision import transforms
from PIL import Image
import PIL

data = load('/data3/sfd/SFDA-DPL-main/generate_pseudo/pseudolabel_D2.npz', allow_pickle=True)
lst = data.files
for item in lst:
print(item)
print(data[item])
my_array=data[data.files[0]]

dfile = "/data3/sfd/SFDA-DPL-main/generate_pseudo/pseudolabel_D2.npz"
images = np.load(dfile,allow_pickle=True)["arr_0"]
tensor=images
tran = transforms.ToPILImage()
img = tran(tensor)
img.show()

Screenshot from 2023-01-18 11-30-46

@cchen-cc
Copy link
Owner

You can use plt.imshow() to plot the image.

@rst1991
Copy link
Author

rst1991 commented Jan 19, 2023

@cchen-cc
import matplotlib.pyplot as plt
import numpy as np
from torchvision import transforms
from PIL import Image
import PIL

dfile = "/data3/sfd/SFDA-DPL-main/generate_pseudo/pseudolabel_D2.npz"
images = np.load(dfile,allow_pickle=True)["arr_0"]
plt.imshow(images)

Traceback (most recent call last):
File "readlabel.py", line 51, in
plt.imshow(images)
File "/data3/rrd/rrd_py37/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2651, in imshow
None else {}), **kwargs)
File "/data3/rrd/rrd_py37/lib/python3.7/site-packages/matplotlib/init.py", line 1565, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "/data3/rrd/rrd_py37/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py", line 358, in wrapper
return func(*args, **kwargs)
File "/data3/rrd/rrd_py37/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py", line 358, in wrapper
return func(*args, **kwargs)
File "/data3/rrd/rrd_py37/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 5626, in imshow
im.set_data(X)
File "/data3/rrd/rrd_py37/lib/python3.7/site-packages/matplotlib/image.py", line 694, in set_data
"float".format(self._A.dtype))
TypeError: Image data of dtype <U6 cannot be converted to float

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