Spaces:
Runtime error
Runtime error
Commit
·
f7d01d2
1
Parent(s):
e74b5ef
Update app.py
Browse filesfixed to do tech data classification
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def greet(name):
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
iface.launch()
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained("FuriouslyAsleep/unhappyZebra100")
|
| 7 |
+
|
| 8 |
+
model = AutoModelForSequenceClassification.from_pretrained("FuriouslyAsleep/unhappyZebra100")
|
| 9 |
|
| 10 |
def greet(name):
|
| 11 |
+
|
| 12 |
+
inputs = tokenizer(name, return_tensors="pt")
|
| 13 |
+
outputs = model(**inputs)
|
| 14 |
+
|
| 15 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 16 |
+
print(predictions)
|
| 17 |
+
# return "Hello " + name + "!!"
|
| 18 |
+
return "Probabilities are listed here (False prob, then True prob): ) + predictions
|
| 19 |
|
| 20 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 21 |
+
iface.launch()
|
| 22 |
+
|