【问题标题】:Problem with dependencies in Streamlit appStreamlit 应用程序中的依赖项问题
【发布时间】:2021-11-30 03:39:36
【问题描述】:

当我尝试运行我的 streamlit 应用程序时,我在 Anaconda Prompt 中收到这些错误:

我将代码简化为更具可读性,但基本上它使用 Keras 模型处理输入,然后我使用 pickle 保存此模型,以便之后使用 Streamlit API 进行预测

import streamlit as st 
import cv2 as cv
import matplotlib.pyplot as plt
import pandas as pd
import os 
import numpy as np
import keras
from keras.models import Sequential
import joblib
import pickle



def some_function():

     pass  #some function to preprocess data and train a model with Keras

    
def main():
  ruta_to_model=r'path'
  model = pickle.load(open(os.path.join(ruta_to_model,'model_pose.pkl'),'rb'))

  st.set_page_config(page_title='Pose Framework',layout='wide',initial_sidebar_state='expanded')



  files=[]

  for file in os.listdir(r'path'):
      if file.endswith('.jpg'):
          files.append(file)

  option=st.multiselect('Input:', files)

  if option and st.button('Predict'):
      inputs=some_function()
      model.predict(inputs)

【问题讨论】:

  • 我认为错误在 some_function() 的某个地方,在你的预处理函数中

标签: python streamlit


【解决方案1】:

错误包含

ImportError: cannot import name 'DataFrame' from 'pandas' (unknown location)

您是否在 conda 环境中安装了pandas?

conda install pandas

【讨论】:

    猜你喜欢
    • 2023-02-01
    • 2015-06-27
    • 1970-01-01
    • 1970-01-01
    • 2021-12-07
    • 1970-01-01
    • 2019-02-05
    • 1970-01-01
    • 2015-04-26
    相关资源
    最近更新 更多