Axios error when uploading images in streamlit app


I dont know why I am getting a axios error when I am uploading image in the streamlit app ( through my computer
when I am choosing from the preloaded images its working fine but then when I am uploading then its creating problem.

Steps to reproduce

Code snippet:

class JUA():
    def __init__(self, image1, url='',
                 headers={'accept': 'application/json'}):
        self.url = url
        self.image1 = image1
        self.headers = headers

    def predict(self):
        with open(self.image1, 'rb') as image:
            response =, headers=self.headers,
                                     files={'file': (self.image1, image, 'image/png')})

        if response.status_code == 200:
                result = response.json()['prediction']
                return result
            except JSONDecodeError as e:
                print("Error decoding JSON:", e)
                print("Response content:", response.content)
            print('Failed to call the API, status code:', response.status_code)
            print('Response content:', response.content)

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

It should authorize the API call but instead its giving axios error

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.


Additional information

Please anyone help me

can anyone give us a solution for this problem