Using imageio.imread
instead of scipy.misc.imread
(because it is depreciated) is giving me an issue. I want to perform something like this but using imageio
:
for file_indexes in duplicates[:30]:
try:
plt.subplot(121), plt.imshow(imread(files_list[file_indexes[1]]))
plt.title(file_indexes[1]), plt.xticks([]), plt.yticks([])
When I try the following I get the error
File "<ipython-input-18-2b05f47215d7>", line 4
plt.subplot(121),img = imageio.imread(files_list[file_indexes[1]])
^
SyntaxError: can't assign to function call
That's what I've tried:
for file_indexes in duplicates[:30]:
try:
plt.subplot(121), img = imageio.imread((files_list[file_indexes[1]]))
plt.title(file_indexes[1]), plt.xticks([]), plt.yticks([])
In general, I want to replace scipy.misc.imread
in the following code with imageio.imread
:
for file_indexes in duplicates[:30]:
try:
plt.subplot(121),plt.imshow(imread(files_list[file_indexes[1]]))
plt.title(file_indexes[1]), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(imread(files_list[file_indexes[0]]))
plt.title(str(file_indexes[0]) + ' duplicate'), plt.xticks([]), plt.yticks([])
plt.show()
except OSError as e:
continue
What is the right way to use the correct syntax?
The initial error is located here:
plt.subplot(121), img = imageio.imread((files_list[file_indexes[1]]))
Before, there was no assignment, just another simple statement: plt.imshow(...)
. Now, there's an assigment, which is not allowed in a list of simple statements. To fix this, you'd just need to move
img = imageio.imread(...)
to a separate line.
But, since you only want to switch from the deprecated scipy.misc.imread
to imageio.imread
, just replace
plt.imshow(imread(...))
with
plt.imshow(imageio.imread(...))