hipnologo commited on
Commit
ce9a470
1 Parent(s): ae0430f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,6 +1,6 @@
1
- import gradio as gr
2
  #gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch()
3
-
 
4
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
 
6
  def predict_review(text):
@@ -24,16 +24,15 @@ def predict_review(text):
24
  sentiment = 'Positive' if predicted_class == 1 else 'Negative'
25
 
26
  # Create a Markdown string for the output
27
- result_md = f"## Sentiment: **{sentiment}**"
28
  return result_md
29
 
30
  iface = gr.Interface(
31
  fn=predict_review,
32
- inputs=gr.inputs.Textbox(lines=7, placeholder="Enter text here..."),
33
- outputs=gr.outputs.Markdown(),
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()
39
-
 
 
1
  #gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch()
2
+ import gradio as gr
3
+ from gradio import inputs, outputs
4
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
5
 
6
  def predict_review(text):
 
24
  sentiment = 'Positive' if predicted_class == 1 else 'Negative'
25
 
26
  # Create a Markdown string for the output
27
+ result_md = f"Sentiment: {sentiment}"
28
  return result_md
29
 
30
  iface = gr.Interface(
31
  fn=predict_review,
32
+ inputs=inputs.Textbox(lines=7, placeholder="Enter text here..."),
33
+ outputs=outputs.Text(),
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()