Spaces:
Sleeping
Sleeping
jvroo
commited on
Commit
·
2091aa4
1
Parent(s):
76707ec
App fix remote errors
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ def local_sentiment_analysis(review):
|
|
| 28 |
def remote_sentiment_analysis(review):
|
| 29 |
try:
|
| 30 |
# Make a request to the Hugging Face Inference API for text classification
|
| 31 |
-
response =
|
| 32 |
sentiment = response[0]['label']
|
| 33 |
score = response[0]['score']
|
| 34 |
return f"Sentiment: {sentiment}, Confidence: {score:.2f}"
|
|
@@ -45,7 +45,7 @@ def analyze_sentiment(review, mode):
|
|
| 45 |
model_info = f"Using local model: {local_model}"
|
| 46 |
elif mode == "Inference API":
|
| 47 |
sentiment, score = remote_sentiment_analysis(review)
|
| 48 |
-
model_info = f"Using remote model: {
|
| 49 |
else:
|
| 50 |
return "Invalid mode selected.", None
|
| 51 |
|
|
|
|
| 28 |
def remote_sentiment_analysis(review):
|
| 29 |
try:
|
| 30 |
# Make a request to the Hugging Face Inference API for text classification
|
| 31 |
+
response = remote_inference_client.text_classification(review)
|
| 32 |
sentiment = response[0]['label']
|
| 33 |
score = response[0]['score']
|
| 34 |
return f"Sentiment: {sentiment}, Confidence: {score:.2f}"
|
|
|
|
| 45 |
model_info = f"Using local model: {local_model}"
|
| 46 |
elif mode == "Inference API":
|
| 47 |
sentiment, score = remote_sentiment_analysis(review)
|
| 48 |
+
model_info = f"Using remote model: {remote_model}"
|
| 49 |
else:
|
| 50 |
return "Invalid mode selected.", None
|
| 51 |
|