masapasa commited on
Commit
0ff00ed
1 Parent(s): fe6f64b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -1,16 +1,12 @@
1
  import gradio as gr
2
-
3
- classifier = pipeline("text-classification", model="huggingface/juliensimon/distilbert-amazon-shoe-reviews")
4
-
5
-
6
- def predict(review):
7
- prediction = classifier(review)
8
- print(prediction)
9
- stars = prediction[0]["label"]
10
- stars = (int)(stars.split("_")[1]) + 1
11
- score = 100 * prediction[0]["score"]
12
- return "{} {:.0f}%".format("\U00002B50" * stars, score)
13
-
14
-
15
- iface = gr.Interface(fn=predict, inputs="text", outputs="text")
16
- iface.launch()
1
  import gradio as gr
2
+ from gradio import inputs
3
+ description = "text classification"
4
+ interface = gr.Interface.load("huggingface/juliensimon/distilbert-amazon-shoe-reviews",
5
+ title = "text classification",
6
+ inputs = [
7
+ gr.inputs.Textbox(lines=7, label="Story"),
8
+ ],
9
+ description=description,
10
+ examples=[["Adventurer is approached by a mysterious stranger in the tavern for a new quest"]]
11
+ )
12
+ interface.launch()