Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
+
|
4 |
+
# Load the model and tokenizer from Hugging Face model hub
|
5 |
+
model = AutoModelForSequenceClassification.from_pretrained("willco-afk/my-model-name")
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("willco-afk/my-model-name")
|
7 |
+
|
8 |
+
# Define the function for prediction
|
9 |
+
def predict(text):
|
10 |
+
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
11 |
+
outputs = model(**inputs)
|
12 |
+
logits = outputs.logits
|
13 |
+
prediction = logits.argmax(-1).item()
|
14 |
+
return prediction
|
15 |
+
|
16 |
+
# Create a Gradio interface
|
17 |
+
interface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
18 |
+
interface.launch()
|