Spaces:
Sleeping
Sleeping
Luis Marques
commited on
Commit
•
a859fdb
1
Parent(s):
d57ee4f
first commit
Browse files- app.py +19 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
+
|
4 |
+
model_name = "./model.pkl"
|
5 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
|
8 |
+
|
9 |
+
def classify_text(text):
|
10 |
+
inputs = tokenizer(text, return_tensors="pt")
|
11 |
+
outputs = model(**inputs)
|
12 |
+
predictions = outputs.logits.argmax(dim=1)
|
13 |
+
|
14 |
+
return f"Predicted class: {predictions.item()}"
|
15 |
+
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=classify_text, inputs="text", outputs="text")
|
18 |
+
|
19 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio==2.1.2
|
2 |
+
transformers==4.13.0
|
3 |
+
torch==1.10.0
|