Array download in format .jpeg - cloud

I have array, need to download it in format .jpeg. In cloud.

i do -

img  = tensorflow.keras.utils.array_to_img(array)

(Image.fromarray don`t work )

if i do -


i can to see picture in browser .


st.download_button(label='download',data=img,file_name = 'O.jpg')

don`t work

On local computer work:

img =  Image.fromarray(array)'image_file.jpg')

in Streamlit cloud it don`t work ((((

I made it !!! ))))

            pred_ar_int = pred_ar.astype(np.uint8)
            im = Image.fromarray(pred_ar_int)
            with io.BytesIO() as f:
      , format='JPEG')
                data = f.getvalue()