mdj1412's picture
Upload app.py
6671a55
raw
history blame
2.34 kB
import gradio as gr
from datasets import load_dataset
import random
README = """
# Movie Review Score Discriminator
It is a program that classifies whether it is positive or negative by entering movie reviews.
You can choose between the Korean version and the English version.
## Usage
"""
model_name = "roberta-base"
learning_rate = 5e-5
batch_size_train = 64
step = 1900
id2label = {0: "NEGATIVE", 1: "POSITIVE"}
label2id = {"NEGATIVE": 0, "POSITIVE": 1}
title = "Movie Review Score Discriminator"
description = "It is a program that classifies whether it is positive or negative by entering movie reviews. You can choose between the Korean version and the English version."
imdb_dataset = load_dataset('imdb')
examples = []
# examples = ["the greatest musicians ", "cold movie "]
for i in range(3):
idx = random.randrange(len(imdb_dataset['train']))
examples.append(imdb_dataset['train'][idx]['text'])
def fn(text):
return "hello, " + text
demo1 = gr.Interface.load("models/cardiffnlp/twitter-roberta-base-sentiment", inputs="text", outputs="text",
title=title, theme="peach",
allow_flagging="auto",
description=description, examples=examples)
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# demo2 = gr.Interface(fn=greet, inputs="text", outputs="text",
# title=title, theme="peach",
# allow_flagging="auto",
# description=description, examples=examples)
here = gr.Interface(fn,
inputs= gr.inputs.Textbox( lines=1, placeholder=None, default="", label=None),
outputs='text',
title="Sentiment analysis of movie reviews",
description=description,
theme="peach",
allow_flagging="auto",
flagging_dir='flagging records')
demo3 = gr.Interface.load("models/mdj1412/movie_review_score_discriminator_eng", inputs="text", outputs="text",
title=title, theme="peach",
allow_flagging="auto",
description=description, examples=examples)
if __name__ == "__main__":
# here.launch()
demo3.launch()