Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import streamlit as st
|
|
| 3 |
import pandas as pd
|
| 4 |
import torch
|
| 5 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, GPT2ForSequenceClassification, TrainingArguments, Trainer, DataCollatorWithPadding, DataCollatorForLanguageModeling
|
| 6 |
-
from text_processor import generate_text, classify_text
|
| 7 |
|
| 8 |
# Step 1: Set Up Your Environment
|
| 9 |
# Environment setup and package installations.
|
|
@@ -45,13 +45,3 @@ if text:
|
|
| 45 |
labels = classify_text(text, seq_classifier_model, seq_classifier_tokenizer)
|
| 46 |
st.write('Classified Labels:')
|
| 47 |
st.write(labels)
|
| 48 |
-
|
| 49 |
-
# Post-process labels based on a threshold or confidence score
|
| 50 |
-
def post_process_labels(results):
|
| 51 |
-
# Implement your logic to extract and filter labels
|
| 52 |
-
# based on your sequence classification model's output
|
| 53 |
-
# For example, you might use a threshold for each label's score
|
| 54 |
-
# to determine whether it should be considered a valid theme.
|
| 55 |
-
# Return the selected labels as a list.
|
| 56 |
-
selected_labels = []
|
| 57 |
-
return selected_labels
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import torch
|
| 5 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer, GPT2ForSequenceClassification, TrainingArguments, Trainer, DataCollatorWithPadding, DataCollatorForLanguageModeling
|
| 6 |
+
from text_processor import generate_text, classify_text, post_process_labels
|
| 7 |
|
| 8 |
# Step 1: Set Up Your Environment
|
| 9 |
# Environment setup and package installations.
|
|
|
|
| 45 |
labels = classify_text(text, seq_classifier_model, seq_classifier_tokenizer)
|
| 46 |
st.write('Classified Labels:')
|
| 47 |
st.write(labels)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|