Upload gradio.py
Browse files
gradio.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Before running this program, install gradio and transformers
|
2 |
+
|
3 |
+
from transformers import pipeline
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
model = "Aansh123/test_trainer"
|
7 |
+
classifier = pipeline("Classification", model = model)
|
8 |
+
|
9 |
+
def classification(sentence):
|
10 |
+
return classifier(sentence)[0]['text-classification']
|
11 |
+
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn = classification,
|
14 |
+
inputs = gr.inputs.Textbox(label="Input your Review"),
|
15 |
+
outputs = gr.outputs.Textbox(label="Rating"),
|
16 |
+
title = "Review Rating",
|
17 |
+
description = "Sentiment Analysis of Review and provision of final Ratings using a fine-tuned model."
|
18 |
+
)
|
19 |
+
|
20 |
+
iface.launch()
|