Spaces:
Runtime error
Runtime error
Update app.py
Browse filesgit add app.py
git commit -m "Add Gradio/Streamlit interface for my model"
git push
app.py
CHANGED
|
@@ -1,10 +1,22 @@
|
|
| 1 |
-
import
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load your pre-trained model from Hugging Face
|
| 5 |
+
model = pipeline("text-classification", model="your-username/your-model-repo")
|
| 6 |
|
| 7 |
+
# Define the prediction function
|
| 8 |
+
def predict(text):
|
| 9 |
+
return model(text)
|
| 10 |
+
|
| 11 |
+
# Create Gradio interface
|
| 12 |
+
interface = gr.Interface(
|
| 13 |
+
fn=predict, # The prediction function
|
| 14 |
+
inputs="text", # Input to your model (text, image, etc.)
|
| 15 |
+
outputs="label", # Output of your model (label, text, image, etc.)
|
| 16 |
+
title="My Model", # Title of the app
|
| 17 |
+
description="This app predicts the category of customer support requests.",
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
# Launch the interface
|
| 21 |
+
interface.launch()
|
| 22 |
|