pakornor commited on
Commit
ed55ec0
1 Parent(s): e0ab0fc

add changes

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -0
  2. app.py +4 -4
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /usr/src/app
4
+
5
+ COPY requirements.txt ./
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ COPY ./app.py .
10
+
11
+ CMD [ "python", "/usr/src/app/app.py" ]
app.py CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
2
  import numpy as np
3
  import torch
4
  from transformers import AutoModelForSequenceClassification
5
- from transformers import TFAutoModelForSequenceClassification
6
  from transformers import AutoTokenizer, AutoConfig
7
  from scipy.special import softmax
8
 
@@ -38,7 +37,7 @@ def sentiment_analysis(text):
38
 
39
  # Format output dictionary of scores
40
  labels = ['Negative', 'Neutral', 'Positive']
41
- scores = {l:float(s) for (l,s) in zip(labels, scores_) }
42
 
43
  return scores
44
 
@@ -47,7 +46,7 @@ def sentiment_analysis(text):
47
  app = gr.Interface(
48
  fn=sentiment_analysis,
49
  inputs=gr.Textbox("Input tweet here:"),
50
- outputs="label",
51
  title="Sentiment Analysis of Tweets on Covid-19 Vaccines",
52
  description="With this App, you can type Tweets related to the Covid Vaccine and the app will rate the sentiment of the tweet..!",
53
  examples=[["Be careful of covid vaccination"],
@@ -55,4 +54,5 @@ app = gr.Interface(
55
  ["I cant wait for the Covid Vaccine!"]]
56
  )
57
 
58
- app.launch()
 
 
2
  import numpy as np
3
  import torch
4
  from transformers import AutoModelForSequenceClassification
 
5
  from transformers import AutoTokenizer, AutoConfig
6
  from scipy.special import softmax
7
 
 
37
 
38
  # Format output dictionary of scores
39
  labels = ['Negative', 'Neutral', 'Positive']
40
+ scores = {l:float(s) for (l,s) in zip(labels, scores_)}
41
 
42
  return scores
43
 
 
46
  app = gr.Interface(
47
  fn=sentiment_analysis,
48
  inputs=gr.Textbox("Input tweet here:"),
49
+ outputs="text",
50
  title="Sentiment Analysis of Tweets on Covid-19 Vaccines",
51
  description="With this App, you can type Tweets related to the Covid Vaccine and the app will rate the sentiment of the tweet..!",
52
  examples=[["Be careful of covid vaccination"],
 
54
  ["I cant wait for the Covid Vaccine!"]]
55
  )
56
 
57
+ if __name__ == "__main__":
58
+ app.launch(server_name="0.0.0.0", server_port="7860")