MaryahGreene commited on
Commit
fa9f927
·
verified ·
1 Parent(s): 912516f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
+ import gradio as gr
3
+ import torch
4
+
5
+ model = AutoModelForSequenceClassification.from_pretrained("my-flava-model")
6
+ tokenizer = AutoTokenizer.from_pretrained("my-flava-model")
7
+
8
+ def classify_text(text):
9
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
10
+ with torch.no_grad():
11
+ outputs = model(**inputs)
12
+ prediction = torch.argmax(outputs.logits, dim=1).item()
13
+ return str(prediction)
14
+
15
+ iface = gr.Interface(fn=classify_text, inputs="text", outputs="text")
16
+ iface.launch()