Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,12 +4,12 @@ from transformers import pipeline, AutoModelForSequenceClassification, AutoToken
|
|
4 |
# Model name
|
5 |
model_name = "ElKulako/cryptobert"
|
6 |
|
7 |
-
# Load model and tokenizer explicitly
|
8 |
try:
|
9 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
11 |
|
12 |
-
# Load
|
13 |
sentiment_pipeline = pipeline(
|
14 |
"text-classification",
|
15 |
model=model,
|
@@ -25,10 +25,10 @@ def analyze(text):
|
|
25 |
return {"error": "No text provided."}
|
26 |
|
27 |
try:
|
28 |
-
# Get
|
29 |
result = sentiment_pipeline(text)[0]
|
30 |
|
31 |
-
# Override logic for crypto-
|
32 |
text_lower = text.lower()
|
33 |
|
34 |
# Force "positive" for bullish terms
|
@@ -52,11 +52,11 @@ gr.Interface(
|
|
52 |
fn=analyze,
|
53 |
inputs=gr.Textbox(placeholder="Enter crypto news headline..."),
|
54 |
outputs=gr.JSON(),
|
55 |
-
title="Crypto
|
56 |
-
description="Analyzes sentiment of crypto news headlines.
|
57 |
-
|
58 |
).launch(
|
59 |
server_name="0.0.0.0",
|
60 |
-
server_port=7860
|
61 |
-
enable_queue=True # Ensures API requests are handled properly
|
62 |
)
|
|
|
|
4 |
# Model name
|
5 |
model_name = "ElKulako/cryptobert"
|
6 |
|
7 |
+
# Load model and tokenizer explicitly
|
8 |
try:
|
9 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
11 |
|
12 |
+
# Load sentiment pipeline
|
13 |
sentiment_pipeline = pipeline(
|
14 |
"text-classification",
|
15 |
model=model,
|
|
|
25 |
return {"error": "No text provided."}
|
26 |
|
27 |
try:
|
28 |
+
# Get model's prediction
|
29 |
result = sentiment_pipeline(text)[0]
|
30 |
|
31 |
+
# Override logic for crypto-related keywords (case-insensitive)
|
32 |
text_lower = text.lower()
|
33 |
|
34 |
# Force "positive" for bullish terms
|
|
|
52 |
fn=analyze,
|
53 |
inputs=gr.Textbox(placeholder="Enter crypto news headline..."),
|
54 |
outputs=gr.JSON(),
|
55 |
+
title="Crypto Sentiment Analysis",
|
56 |
+
description="Analyzes sentiment of crypto-related news headlines.",
|
57 |
+
flagging_mode="never" # Fixed deprecated warning
|
58 |
).launch(
|
59 |
server_name="0.0.0.0",
|
60 |
+
server_port=7860
|
|
|
61 |
)
|
62 |
+
|