I have a problem with running the application. The problem occurs with the following code snippet. When I create a new py. everything works fine. I saved a py. file and closed the editor and when I try to execute the same code again I get an error.
import pandas as pd import io import pickle from top2vec import Top2Vec import streamlit as st @st.cache_resource() def topic_modeling(docs): model = Top2Vec(docs, embedding_model='universal-sentence-encoder-multilingual') model.save("model_save") model = Top2Vec.load("model_save") return (model) def pickle_model(model): f = io.BytesIO() pickle.dump(model, f) return f uploaded_file = st.file_uploader("Choose a file", type=['csv'], help='Accept only CSV extenction') if uploaded_file is not None: df = pd.read_csv(uploaded_file) df=df.head(1000) docs = list(df.loc[:,"NPSCombined"].values) model = topic_modeling(docs) file = pickle_model(model) st.write(model, file) else: st.write("upload file")
Please help me find a solution. I’m going to be all gray soon