Tokymin commited on
Commit
3299e8b
·
1 Parent(s): 2583ba2

权限问题,在space中添加了环境变量token用于访问模型

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -12,7 +12,11 @@ from transformers import AutoTokenizer, AutoModel
12
  huggingface_token = os.getenv('HF_TOKEN')
13
 
14
  # Set up the token to use with the Hugging Face API
15
- os.environ['HUGGINGFACE_CO_API_TOKEN'] = huggingface_token
 
 
 
 
16
  tokenizer = AutoTokenizer.from_pretrained("Tokymin/Mood_Anxiety_Disorder_Classify_Model")
17
  model = AutoModelForSequenceClassification.from_pretrained("Tokymin/Mood_Anxiety_Disorder_Classify_Model", num_labels=8)
18
  model.eval()
 
12
  huggingface_token = os.getenv('HF_TOKEN')
13
 
14
  # Set up the token to use with the Hugging Face API
15
+ if huggingface_token is not None:
16
+ os.environ['HUGGINGFACE_CO_API_TOKEN'] = huggingface_token
17
+ else:
18
+ print("error, no token")
19
+ exit(0)
20
  tokenizer = AutoTokenizer.from_pretrained("Tokymin/Mood_Anxiety_Disorder_Classify_Model")
21
  model = AutoModelForSequenceClassification.from_pretrained("Tokymin/Mood_Anxiety_Disorder_Classify_Model", num_labels=8)
22
  model.eval()