首页 > 解决方案 > JSONDecodeError:预期值:第 1 行第 1 列(字符 0)。streamlit 应用程序中出现问题

问题描述

我正在使用 python 制作一个神经网络可视化器 web 应用程序,但是当我运行 streamlit 应用程序的代码时,它一直向我显示这个 json 解码错误。有人可以告诉我我应该如何解决这个错误。在此处输入代码

    %%writefile app.py

import streamlit as st
import json
import requests
import matplotlib.pyplot as plt
import numpy as np

URI = 'http://127.0.0.1:5000'

st.title('Neural Network Visualizer')
st.sidebar.markdown('## Input Image')

if st.button('Get random prediction'):
    response = requests.post(URI, data={})
    response = json.loads(response.text)
    preds = response.get('prediction')
    image = response.get('image')
    image = np.reshape(image, (28, 28))

    st.image(image, width=150)

标签: pythonjsonmachine-learningneural-networkstreamlit

解决方案


推荐阅读