tevykuch commited on
Commit
25ef427
1 Parent(s): 68e83e9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer, AutoModel
2
+ import gradio as gr
3
+
4
+ def predict(input_text):
5
+ inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True, max_length=512)
6
+ with torch.no_grad():
7
+ outputs = model(**inputs)
8
+
9
+ predictions = torch.softmax(outputs.logits, dim=-1)
10
+ predicted_class = predictions.argmax().item()
11
+
12
+ return f"Predicted class: {predicted_class}"
13
+
14
+
15
+ iface = gr.Interface(fn=predict,
16
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Type your text here..."),
17
+ outputs="text",
18
+ title="My Model Demo",
19
+ description="Enter some text to see the model prediction.")
20
+
21
+ iface.launch()