thushalya
commited on
Commit
·
13f875c
1
Parent(s):
cfb943c
Add predicted_class
Browse files
app.py
CHANGED
|
@@ -351,7 +351,7 @@ def load_model(tweet):
|
|
| 351 |
pred = model(inputs)
|
| 352 |
print("prediction ",pred)
|
| 353 |
print("sigmoid output",torch.sigmoid(pred))
|
| 354 |
-
pred = torch.sigmoid(pred)
|
| 355 |
# Assuming your model returns a single value for prediction
|
| 356 |
|
| 357 |
|
|
@@ -368,6 +368,7 @@ def load_model(tweet):
|
|
| 368 |
def greet(tweet):
|
| 369 |
print("start")
|
| 370 |
prediction = load_model(tweet)
|
|
|
|
| 371 |
# features_list = extract_features(tweet)
|
| 372 |
# print(personality_detection(tweet))
|
| 373 |
# print(str(features_list["Average_Word_Length"]))
|
|
@@ -380,7 +381,7 @@ def greet(tweet):
|
|
| 380 |
label = "Non Hate"
|
| 381 |
|
| 382 |
|
| 383 |
-
return label,str(
|
| 384 |
|
| 385 |
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 386 |
demo = gr.Interface(
|
|
|
|
| 351 |
pred = model(inputs)
|
| 352 |
print("prediction ",pred)
|
| 353 |
print("sigmoid output",torch.sigmoid(pred))
|
| 354 |
+
pred = torch.sigmoid(pred)
|
| 355 |
# Assuming your model returns a single value for prediction
|
| 356 |
|
| 357 |
|
|
|
|
| 368 |
def greet(tweet):
|
| 369 |
print("start")
|
| 370 |
prediction = load_model(tweet)
|
| 371 |
+
prediction_value = prediction.item()
|
| 372 |
# features_list = extract_features(tweet)
|
| 373 |
# print(personality_detection(tweet))
|
| 374 |
# print(str(features_list["Average_Word_Length"]))
|
|
|
|
| 381 |
label = "Non Hate"
|
| 382 |
|
| 383 |
|
| 384 |
+
return label,str(prediction_value)+"%",str(1-prediction_value)+"%"
|
| 385 |
|
| 386 |
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 387 |
demo = gr.Interface(
|