kadirnar commited on
Commit
1217943
1 Parent(s): 2928f1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
  import os
4
  import random
5
  import uuid
@@ -14,7 +12,7 @@ from huggingface_hub import snapshot_download
14
 
15
  huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
16
 
17
- snapshot_download(
18
  repo_id="stabilityai/stable-diffusion-3-medium",
19
  repo_type="model",
20
  ignore_patterns=["*.md", "*..gitattributes"],
@@ -33,9 +31,8 @@ USE_TORCH_COMPILE = False
33
  ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
34
 
35
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
36
- vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
37
 
38
- pipe = StableDiffusion3Pipeline.from_pretrained("stable-diffusion-3-medium", torch_dtype=torch.float16)
39
 
40
 
41
  def save_image(img):
@@ -68,8 +65,8 @@ def generate(
68
  pipe.to(device)
69
  seed = int(randomize_seed_fn(seed, randomize_seed))
70
  generator = torch.Generator().manual_seed(seed)
71
- #pipe.scheduler = DPMSolverSinglestepScheduler(use_karras_sigmas=True).from_config(pipe.scheduler.config)
72
- #pipe.scheduler = DPMSolverMultistepScheduler(algorithm_type="sde-dpmsolver++").from_config(pipe.scheduler.config)
73
 
74
  if not use_negative_prompt:
75
  negative_prompt = None # type: ignore
 
 
 
1
  import os
2
  import random
3
  import uuid
 
12
 
13
  huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
14
 
15
+ model_path = snapshot_download(
16
  repo_id="stabilityai/stable-diffusion-3-medium",
17
  repo_type="model",
18
  ignore_patterns=["*.md", "*..gitattributes"],
 
31
  ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
32
 
33
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
 
34
 
35
+ pipe = StableDiffusion3Pipeline.from_pretrained(model_path, torch_dtype=torch.float16)
36
 
37
 
38
  def save_image(img):
 
65
  pipe.to(device)
66
  seed = int(randomize_seed_fn(seed, randomize_seed))
67
  generator = torch.Generator().manual_seed(seed)
68
+
69
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
70
 
71
  if not use_negative_prompt:
72
  negative_prompt = None # type: ignore