jbraha commited on
Commit
306c463
·
2 Parent(s): fa8cd67 613e7ae

Merge branch 'main' into milestone-3

Browse files
Files changed (3) hide show
  1. .github/workflows/main.yml +1 -1
  2. app.py +24 -18
  3. working_training.ipynb +0 -0
.github/workflows/main.yml CHANGED
@@ -23,4 +23,4 @@ jobs:
23
  && git switch main
24
  && git merge origin/milestone-3
25
  && git push
26
- && git push https://jbraha:$HF_TOKEN@huggingface.co/spaces/jbraha/aiproject
 
23
  && git switch main
24
  && git merge origin/milestone-3
25
  && git push
26
+ && git push -f https://jbraha:$HF_TOKEN@huggingface.co/spaces/jbraha/aiproject
app.py CHANGED
@@ -43,16 +43,17 @@ option = st.selectbox(
43
  ('Default', 'Fine-Tuned' , 'Roberta'))
44
 
45
 
46
- if option == 'Fine-Tuned':
47
- model = AutoModelForSequenceClassification.from_pretrained(fine_tuned)
48
- tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
49
- classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer, top_k=None)
50
- elif option == 'Roberta':
51
- model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
52
- tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
53
- classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
54
- else:
55
- classifier = pipeline('sentiment-analysis')
 
56
 
57
 
58
 
@@ -74,13 +75,18 @@ strings = [ "D'aww! He matches this background colour I'm seemingly stuck with.
74
 
75
 
76
  if st.button('Analyze'):
77
- result = classifier(input)
78
- result = result[0]
79
  if option == 'Fine-Tuned':
 
 
80
  result = unpack(result)
81
  add_to_table(input, result, output)
82
- # st.table(output)
83
- else:
 
 
 
 
 
84
  st.write(result)
85
  else:
86
  st.write('Excited to analyze!')
@@ -88,10 +94,10 @@ else:
88
 
89
 
90
  for string in strings:
91
- result = classifier(string)
92
- result = result[0]
93
- result = unpack(result)
94
- add_to_table(string, result, output)
95
 
96
  st.table(output)
97
 
 
43
  ('Default', 'Fine-Tuned' , 'Roberta'))
44
 
45
 
46
+ # init classifiers
47
+
48
+ model = AutoModelForSequenceClassification.from_pretrained(fine_tuned)
49
+ tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
50
+ ft_classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer, top_k=None)
51
+
52
+ model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
53
+ tokenizer = AutoTokenizer.from_pretrained("cardiffnlp/twitter-roberta-base-sentiment")
54
+ rob_classifier = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)
55
+
56
+ def_classifier = pipeline('sentiment-analysis')
57
 
58
 
59
 
 
75
 
76
 
77
  if st.button('Analyze'):
 
 
78
  if option == 'Fine-Tuned':
79
+ result = ft_classifier(input)
80
+ result = result[0]
81
  result = unpack(result)
82
  add_to_table(input, result, output)
83
+ elif option == 'Roberta':
84
+ result = rob_classifier(input)
85
+ result = result[0]
86
+ st.write(result)
87
+ elif option == 'Default':
88
+ result = def_classifier(input)
89
+ result = result[0]
90
  st.write(result)
91
  else:
92
  st.write('Excited to analyze!')
 
94
 
95
 
96
  for string in strings:
97
+ item = ft_classifier(string)
98
+ item = item[0]
99
+ item = unpack(item)
100
+ add_to_table(string, item, output)
101
 
102
  st.table(output)
103
 
working_training.ipynb CHANGED
The diff for this file is too large to render. See raw diff