Spaces:
Runtime error
Runtime error
Update app.py
Browse files6 unmodified lines789101112127 unmodified lines14014114214314414514623 unmodified lines17017117217317417517645 unmodified lines2222232242256 unmodified linesfrom nltk.tokenize import sent_tokenizeimport plotly.express as pximport timenltk.download('punkt')# Define the model and tokenizer127 unmodified lines# UPLOAD CSV# Define the prediction functiondef predict_sdg_from_csv(file):# Read the CSV filedf_docs = pd.read_csv(file)text_list = df_docs["text_inputs"].tolist()23 unmodified linesprediction_score = []# Preprocess text and make predictionsfor text_input in text_list:time.sleep(0.02) # Sleep to avoid rate limitingcleaned_text = prep_text(text_input)tokenized_text = tokenizer(cleaned_text, return_tensors="pt", truncation=True, max_length=512, padding=True)45 unmodified lines)# Run the interfacedemo.launch()6 unmodified lines78910111213127 unmodified lines14114214314414514614723 unmodified lines17117217317417517617745 unmodified lines2232242252266 unmodified linesfrom nltk.tokenize import sent_tokenizeimport plotly.express as pximport timeimport tqdmnltk.download('punkt')# Define the model and tokenizer127 unmodified lines# UPLOAD CSV# Define the prediction functiondef predict_sdg_from_csv(file, progress=gr.Progress()):# Read the CSV filedf_docs = pd.read_csv(file)text_list = df_docs["text_inputs"].tolist()23 unmodified linesprediction_score = []# Preprocess text and make predictionsfor text_input in progress.tqdm(text_list, desc="Analysing data":time.sleep(0.02) # Sleep to avoid rate limitingcleaned_text = prep_text(text_input)tokenized_text = tokenizer(cleaned_text, return_tensors="pt", truncation=True, max_length=512, padding=True)45 unmodified lines)# Run the interfacedemo.queue().launch()
app.py+4-3