How do I convert the following array into a jpg? (Please help)

I am trying to convert the following NumPy array into an image again(I need to see the image to continue with my project):

I tried the plt image show but it gave me an error that the float variables are not convertible

Instead of including a pickled file, can you please share your current code in a way that allows people to view it online - such as a repl, GitHub gist, or similar?

It would also help if you could be more specific with your request for help. Where is the error occurring? What research have you done into it so far? What did you try before you got stuck?


JusttoShare/codeforviewingtheimg at main · valimikayilov/JusttoShare (

More information is needed.

I tried the code above and the error that I got is the following:

C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\cbook\ VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  x = np.array(x, subok=True, copy=copy)
Traceback (most recent call last):
  File "C:\Users\Desktop\Programming in Python 2\ex4\unittest\", line 9, in <module>
  File "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\", line 2724, in imshow
    __ret = gca().imshow(
  File "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\", line 1447, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\axes\", line 5523, in imshow
  File "C:\Users\AppData\Local\Programs\Python\Python39\lib\site-packages\matplotlib\", line 702, in set_data
    raise TypeError("Image data of dtype {} cannot be converted to "
TypeError: Image data of dtype object cannot be converted to float

I did extensive research but I don’t know how to do it

this how I think that image was converted but I don’t know how to convert it back:

for img in self.found_files:
    loaded =
    numpyimage = np.asarray(loaded)

I’m no expert on pickle, but shouldn’t you be able to get the data-type of the content? See what data it is made up off? Then look for operations defined on that data? Or ask whoever made this thing how they made it and how to reverse it?

I feel like you are giving us pretty much nothing to work with.

1 Like


a: array_like

  Input data, in any form that can be converted to an array. This includes lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays.

If your loaded isn’t an array-like type, then you won’t be able to use asarray like this. It appears that your self.found_files could be converted to an array. Is that what you needed to do?

1 Like

that code is what should have been used to convert images into arrays, but now I want to see them as images again. The images are greyscaled, and I need to see them with the help of plt.imshow

espero te sirva busca un poco en data scinecie

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.