dhruthick commited on
Commit
ca7b248
·
1 Parent(s): dd817e4

updated files

Browse files
Files changed (4) hide show
  1. .gitignore +1 -2
  2. Dockerfile +1 -1
  3. app.py +13 -10
  4. config.json +3 -0
.gitignore CHANGED
@@ -1,4 +1,3 @@
1
  .DS_Store
2
  backend/.DS_Store
3
- backend/models/bert-mood-prediction-1.pt
4
- config.json
 
1
  .DS_Store
2
  backend/.DS_Store
3
+ backend/models/bert-mood-prediction-1.pt
 
Dockerfile CHANGED
@@ -11,6 +11,6 @@ RUN pip install -r requirements.txt
11
 
12
  COPY . .
13
 
14
- EXPOSE 8000
15
 
16
  CMD ["python", "app.py"]
 
11
 
12
  COPY . .
13
 
14
+ EXPOSE 7860
15
 
16
  CMD ["python", "app.py"]
app.py CHANGED
@@ -3,7 +3,7 @@ from lyricsgenius import Genius
3
  import json
4
  import torch
5
  import numpy as np
6
- from transformers import BertTokenizer, BertForSequenceClassification
7
 
8
  app = Flask(__name__)
9
 
@@ -14,14 +14,17 @@ mood_map = {
14
  2: 'Relaxed'
15
  }
16
 
17
- # Load your pre-trained model and tokenizer
18
- model = BertForSequenceClassification.from_pretrained(
19
- "bert-base-uncased", # Use the 12-layer BERT model, with an uncased vocab.
20
- num_labels = 4, # The number of output labels.
21
- output_attentions = False, # Whether the model returns attentions weights.
22
- output_hidden_states = False, # Whether the model returns all hidden-states.
23
- )
24
- model.load_state_dict(torch.load('backend/models/bert-mood-prediction-1.pt', map_location=torch.device('cpu')))
 
 
 
25
  model.eval()
26
 
27
  # load API Token in config file
@@ -115,4 +118,4 @@ def get_lyrics(song_title, artist_name):
115
  return False, "TIMEOUT"
116
 
117
  if __name__ == '__main__':
118
- app.run(host='0.0.0.0', port=8000)
 
3
  import json
4
  import torch
5
  import numpy as np
6
+ from transformers import BertTokenizer, BertForSequenceClassification, AutoTokenizer, AutoModelForSequenceClassification
7
 
8
  app = Flask(__name__)
9
 
 
14
  2: 'Relaxed'
15
  }
16
 
17
+ # model = BertForSequenceClassification.from_pretrained(
18
+ # "bert-base-uncased", # Use the 12-layer BERT model, with an uncased vocab.
19
+ # num_labels = 4, # The number of output labels.
20
+ # output_attentions = False, # Whether the model returns attentions weights.
21
+ # output_hidden_states = False, # Whether the model returns all hidden-states.
22
+ # )
23
+ # model.load_state_dict(torch.load('backend/models/bert-mood-prediction-1.pt', map_location=torch.device('cpu')))
24
+ # model.eval()
25
+
26
+ tokenizer = AutoTokenizer.from_pretrained("dhruthick/my-bert-lyrics-classifier")
27
+ model = AutoModelForSequenceClassification.from_pretrained("dhruthick/my-bert-lyrics-classifier")
28
  model.eval()
29
 
30
  # load API Token in config file
 
118
  return False, "TIMEOUT"
119
 
120
  if __name__ == '__main__':
121
+ app.run(host='0.0.0.0', port=7860)
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "GENIUS_TOKEN": "PFl5Jdd01ayEMNqxIkuoAWnA7N9Xw9KqD9BSphLmjQ4IBrJqyaTA9CxKP2k8yJpz"
3
+ }