Spaces:
Sleeping
Sleeping
Update app.py
#1
by
paragon-analytics
- opened
app.py
CHANGED
@@ -8,12 +8,12 @@ model = AutoModelForSequenceClassification.from_pretrained("MarkAdamsMSBA24/ADRv
|
|
8 |
|
9 |
# Define the prediction function
|
10 |
def get_prediction(text):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
return
|
17 |
|
18 |
iface = gr.Interface(
|
19 |
fn=get_prediction,
|
|
|
8 |
|
9 |
# Define the prediction function
|
10 |
def get_prediction(text):
|
11 |
+
X_test = str(text).lower()
|
12 |
+
encoded_input = tokenizer(X_test, return_tensors='pt')
|
13 |
+
output = model(**encoded_input)
|
14 |
+
scores = output[0][0].detach()
|
15 |
+
scores = torch.nn.functional.softmax(scores)
|
16 |
+
return {"Severe Reaction": float(scores.numpy()[1]), "Non-severe Reaction": float(scores.numpy()[0])}
|
17 |
|
18 |
iface = gr.Interface(
|
19 |
fn=get_prediction,
|