crevelop commited on
Commit
7a28656
·
unverified ·
1 Parent(s): 7834888

add token authentication

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -2,6 +2,8 @@ import spaces
2
  import gradio as gr
3
  import numpy as np
4
  import random
 
 
5
 
6
  # import spaces #[uncomment to use ZeroGPU]
7
  from diffusers import DiffusionPipeline
@@ -15,6 +17,13 @@ if torch.cuda.is_available():
15
  else:
16
  torch_dtype = torch.float32
17
 
 
 
 
 
 
 
 
18
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
19
  pipe = pipe.to(device)
20
 
 
2
  import gradio as gr
3
  import numpy as np
4
  import random
5
+ import os
6
+ from huggingface_hub import login
7
 
8
  # import spaces #[uncomment to use ZeroGPU]
9
  from diffusers import DiffusionPipeline
 
17
  else:
18
  torch_dtype = torch.float32
19
 
20
+ # Authenticate with Hugging Face
21
+ huggingface_token = os.getenv('HUGGING_FACE_TOKEN')
22
+ if huggingface_token is None:
23
+ raise ValueError("HUGGING_FACE_TOKEN environment variable not set.")
24
+
25
+ login(token=huggingface_token)
26
+
27
  pipe = DiffusionPipeline.from_pretrained(model_repo_id, torch_dtype=torch_dtype)
28
  pipe = pipe.to(device)
29