prokofyev8 commited on
Commit
e450728
·
verified ·
1 Parent(s): 1c03840

using model_local_path

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -6,15 +6,28 @@ import spaces #[uncomment to use ZeroGPU]
6
  from diffusers import DiffusionPipeline
7
  import torch
8
 
9
- model_id = "ostris/Z-Image-De-Turbo"
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  pipe = DiffusionPipeline.from_pretrained(
12
- model_id,
13
  torch_dtype=torch.bfloat16,
14
- variant="bf16",
15
- subfolder="transformer"
16
  )
17
 
 
 
 
18
  MAX_SEED = np.iinfo(np.int32).max
19
  MAX_IMAGE_SIZE = 1024
20
 
 
6
  from diffusers import DiffusionPipeline
7
  import torch
8
 
9
+ model_local_path = "./Z-Image-De-Turbo" # Попробуйте сначала этот путь
10
+
11
+ if not os.path.exists(model_local_path):
12
+ potential_paths = [
13
+ "/home/user/Z-Image-De-Turbo",
14
+ os.path.expanduser("~/.cache/huggingface/hub/models--ostris--Z-Image-De-Turbo"),
15
+ ]
16
+ for path in potential_paths:
17
+ if os.path.exists(path):
18
+ model_local_path = path
19
+ break
20
+
21
+ print(f"Пытаюсь загрузить модель из: {model_local_path}")
22
 
23
  pipe = DiffusionPipeline.from_pretrained(
24
+ os.path.join(model_local_path, "transformer"),
25
  torch_dtype=torch.bfloat16,
 
 
26
  )
27
 
28
+ device = "cuda" if torch.cuda.is_available() else "cpu"
29
+ pipe.to(device)
30
+
31
  MAX_SEED = np.iinfo(np.int32).max
32
  MAX_IMAGE_SIZE = 1024
33