File size: 2,335 Bytes
a83f80b 6671a55 a83f80b d564f5f c49cab1 d564f5f 766e63e 1d7e124 9660558 7c020ac 6671a55 9660558 6671a55 9660558 7c020ac 9660558 837f208 68a11ea 6671a55 68a11ea 7c020ac 6671a55 68a11ea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
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() |