Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,7 +34,19 @@ def classify_text(text):
|
|
| 34 |
logger.info(f"Classifying text: {text}")
|
| 35 |
predictions = classifier(text)
|
| 36 |
logger.info(f"Predictions: {predictions}")
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
except Exception as e:
|
| 39 |
logger.error(f"Error classifying text: {e}")
|
| 40 |
return {"error": str(e)}
|
|
|
|
| 34 |
logger.info(f"Classifying text: {text}")
|
| 35 |
predictions = classifier(text)
|
| 36 |
logger.info(f"Predictions: {predictions}")
|
| 37 |
+
|
| 38 |
+
# Process predictions to add the custom logic
|
| 39 |
+
result = []
|
| 40 |
+
for prediction in predictions:
|
| 41 |
+
if prediction['score'] > 0.95:
|
| 42 |
+
label = "Immunization"
|
| 43 |
+
else:
|
| 44 |
+
label = "None"
|
| 45 |
+
result.append({'label': label, 'score': prediction['score']})
|
| 46 |
+
|
| 47 |
+
logger.info(f"Processed predictions: {result}")
|
| 48 |
+
return result
|
| 49 |
+
|
| 50 |
except Exception as e:
|
| 51 |
logger.error(f"Error classifying text: {e}")
|
| 52 |
return {"error": str(e)}
|