FellOffTheStairs commited on
Commit
33f1413
·
verified ·
1 Parent(s): 7e2cdfb

Update app.py

Browse files

git add app.py
git commit -m "Add Gradio/Streamlit interface for my model"
git push

Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -1,10 +1,22 @@
1
- import streamlit as st
2
  from transformers import pipeline
3
 
4
- pipe = pipeline('text-classification')
5
- text = st.text_area('Enter your text:')
6
 
7
- if text:
8
- out = pipe(text)
9
- st.json(out)
 
 
 
 
 
 
 
 
 
 
 
 
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