hipnologo commited on
Commit
6065638
1 Parent(s): c5ed07f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,11 +1,10 @@
1
  #gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch()
2
  import gradio as gr
3
- from gradio import Interface
4
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
 
6
  def predict_review(text):
7
  # Specify the model name or path
8
- model_name = "hipnologo/gpt2-imdb-finetune" # Replace with your model name on the Hugging Face model hub
9
 
10
  # Load your model and tokenizer
11
  tokenizer = AutoTokenizer.from_pretrained(model_name)
@@ -27,12 +26,11 @@ def predict_review(text):
27
  result_md = f"Sentiment: {sentiment}"
28
  return result_md
29
 
30
- iface = Interface(
31
  fn=predict_review,
32
- inputs=gr.inputs.Textbox(lines=7, placeholder="Enter text here..."),
33
- outputs=gr.outputs.Textbox(),
34
  title="Sentiment Analysis",
35
- description="This application predicts the sentiment (Positive/Negative) of the input text using a fine-tuned GPT-2 model.",
36
- theme="compact" # change this to the theme you prefer: 'huggingface', 'default'
37
  )
38
  iface.launch()
 
1
  #gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch()
2
  import gradio as gr
 
3
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
 
5
  def predict_review(text):
6
  # Specify the model name or path
7
+ model_name = "hipnologo/gpt2-imdb-finetune"
8
 
9
  # Load your model and tokenizer
10
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
26
  result_md = f"Sentiment: {sentiment}"
27
  return result_md
28
 
29
+ iface = gr.Interface(
30
  fn=predict_review,
31
+ inputs=gr.components.Textbox(lines=7, placeholder="Enter text here..."),
32
+ outputs=gr.components.Textbox(),
33
  title="Sentiment Analysis",
34
+ description="This application predicts the sentiment (Positive/Negative) of the input text using a fine-tuned GPT-2 model."
 
35
  )
36
  iface.launch()