qisan commited on
Commit
61336fa
1 Parent(s): 4b4aa45

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -10,6 +10,7 @@ import transformers
10
  from transformers import BertModel, BertTokenizer
11
  from PIL import Image
12
  import requests
 
13
 
14
  class_names = ['Not Depressed', 'Depressed']
15
  pt_file = hf_hub_download(repo_id="liangc40/sentimental_analysis", filename="model.pt")
@@ -42,7 +43,9 @@ def analyse(text):
42
  outputs = model(input_ids = encoding['input_ids'], attention_mask = encoding['attention_mask'])
43
  _, preds = torch.max(outputs, dim=1)
44
  face_url = "https://raw.githubusercontent.com/liangc40/ID2223_Sentimental_Analysis_Project/main/Image/"+ str(preds) + ".png"
45
- img = Image.open(requests.get(face_url, stream=True).raw)
 
 
46
  #print(preds)
47
  return img
48
 
 
10
  from transformers import BertModel, BertTokenizer
11
  from PIL import Image
12
  import requests
13
+ import io
14
 
15
  class_names = ['Not Depressed', 'Depressed']
16
  pt_file = hf_hub_download(repo_id="liangc40/sentimental_analysis", filename="model.pt")
 
43
  outputs = model(input_ids = encoding['input_ids'], attention_mask = encoding['attention_mask'])
44
  _, preds = torch.max(outputs, dim=1)
45
  face_url = "https://raw.githubusercontent.com/liangc40/ID2223_Sentimental_Analysis_Project/main/Image/"+ str(preds) + ".png"
46
+ r = requests.get(face_url, stream=True)
47
+ img = Image.open(io.BytesIO(r.content))
48
+ #img = Image.open(requests.get(face_url, stream=True).raw)
49
  #print(preds)
50
  return img
51