Alibrown commited on
Commit
9907307
Β·
verified Β·
1 Parent(s): 7c29612

Rename app.py to _app.py

Browse files
Files changed (1) hide show
  1. app.py β†’ _app.py +15 -1
app.py β†’ _app.py RENAMED
@@ -5,6 +5,16 @@ import torch
5
  import gradio as gr
6
  from diffusers import StableDiffusionPipeline
7
  import paramiko
 
 
 
 
 
 
 
 
 
 
8
 
9
  # Konfiguration
10
  STORAGE_DOMAIN = os.getenv('STORAGE_DOMAIN', '').strip() # SFTP Server Domain
@@ -16,7 +26,11 @@ STORAGE_SECRET = os.getenv('STORAGE_SECRET', '').strip() # Secret Token
16
  # Modell laden
17
  device = "cuda" if torch.cuda.is_available() else "cpu"
18
  repo = "stabilityai/stable-diffusion-3-medium-diffusers"
19
- pipe = StableDiffusionPipeline.from_pretrained(repo, torch_dtype=torch.float16).to(device)
 
 
 
 
20
 
21
  # Maximalwerte
22
  MAX_SEED = np.iinfo(np.int32).max
 
5
  import gradio as gr
6
  from diffusers import StableDiffusionPipeline
7
  import paramiko
8
+ from huggingface_hub import login
9
+
10
+ # Hugging Face Token
11
+ HF_TOKEN = os.getenv('HUGGING_FACE_HUB_TOKEN', '').strip()
12
+
13
+ if not HF_TOKEN:
14
+ raise ValueError("HUGGING_FACE_HUB_TOKEN is not set. Please set the token as an environment variable.")
15
+
16
+ # Hugging Face Login
17
+ login(token=HF_TOKEN)
18
 
19
  # Konfiguration
20
  STORAGE_DOMAIN = os.getenv('STORAGE_DOMAIN', '').strip() # SFTP Server Domain
 
26
  # Modell laden
27
  device = "cuda" if torch.cuda.is_available() else "cpu"
28
  repo = "stabilityai/stable-diffusion-3-medium-diffusers"
29
+
30
+ try:
31
+ pipe = StableDiffusionPipeline.from_pretrained(repo, torch_dtype=torch.float16).to(device)
32
+ except Exception as e:
33
+ raise RuntimeError(f"Failed to load the model. Ensure the token has access to the repo. Error: {e}")
34
 
35
  # Maximalwerte
36
  MAX_SEED = np.iinfo(np.int32).max