Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,38 +44,38 @@ def load_models():
|
|
44 |
|
45 |
# Load summarization model
|
46 |
if has_pipeline:
|
47 |
-
# Use pipeline if available
|
48 |
models['summarizer'] = pipeline(
|
49 |
"summarization",
|
50 |
-
model="
|
51 |
max_length=100,
|
52 |
truncation=True
|
53 |
)
|
54 |
else:
|
55 |
-
# Fall back to basic model loading
|
56 |
try:
|
57 |
-
models['summarizer_model'] = AutoModelForSeq2SeqLM.from_pretrained("
|
58 |
-
models['summarizer_tokenizer'] = AutoTokenizer.from_pretrained("
|
59 |
except Exception as e:
|
60 |
st.error(f"Error loading summarization model: {e}")
|
61 |
models['summarizer_model'] = None
|
62 |
models['summarizer_tokenizer'] = None
|
63 |
|
64 |
-
# Load sentiment model for evaluation
|
65 |
if has_pipeline:
|
66 |
# Use pipeline if available
|
67 |
models['evaluator'] = pipeline(
|
68 |
"sentiment-analysis",
|
69 |
-
model="
|
70 |
)
|
71 |
else:
|
72 |
-
# Fall back to basic model loading
|
73 |
try:
|
74 |
models['evaluator_model'] = AutoModelForSequenceClassification.from_pretrained(
|
75 |
-
"
|
76 |
)
|
77 |
models['evaluator_tokenizer'] = AutoTokenizer.from_pretrained(
|
78 |
-
"
|
79 |
)
|
80 |
except Exception as e:
|
81 |
st.error(f"Error loading sentiment model: {e}")
|
|
|
44 |
|
45 |
# Load summarization model
|
46 |
if has_pipeline:
|
47 |
+
# Use pipeline if available, now using the updated model
|
48 |
models['summarizer'] = pipeline(
|
49 |
"summarization",
|
50 |
+
model="marianna13/flan-t5-base-summarization",
|
51 |
max_length=100,
|
52 |
truncation=True
|
53 |
)
|
54 |
else:
|
55 |
+
# Fall back to basic model loading using the updated summarization model
|
56 |
try:
|
57 |
+
models['summarizer_model'] = AutoModelForSeq2SeqLM.from_pretrained("marianna13/flan-t5-base-summarization")
|
58 |
+
models['summarizer_tokenizer'] = AutoTokenizer.from_pretrained("marianna13/flan-t5-base-summarization")
|
59 |
except Exception as e:
|
60 |
st.error(f"Error loading summarization model: {e}")
|
61 |
models['summarizer_model'] = None
|
62 |
models['summarizer_tokenizer'] = None
|
63 |
|
64 |
+
# Load sentiment model for evaluation - updated model
|
65 |
if has_pipeline:
|
66 |
# Use pipeline if available
|
67 |
models['evaluator'] = pipeline(
|
68 |
"sentiment-analysis",
|
69 |
+
model="cardiffnlp/twitter-roberta-base-sentiment-latest"
|
70 |
)
|
71 |
else:
|
72 |
+
# Fall back to basic model loading using the updated evaluation model
|
73 |
try:
|
74 |
models['evaluator_model'] = AutoModelForSequenceClassification.from_pretrained(
|
75 |
+
"cardiffnlp/twitter-roberta-base-sentiment-latest"
|
76 |
)
|
77 |
models['evaluator_tokenizer'] = AutoTokenizer.from_pretrained(
|
78 |
+
"cardiffnlp/twitter-roberta-base-sentiment-latest"
|
79 |
)
|
80 |
except Exception as e:
|
81 |
st.error(f"Error loading sentiment model: {e}")
|