prithivMLmods commited on
Commit
a6638ea
1 Parent(s): d5336ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -1,5 +1,5 @@
1
  #!/usr/bin/env python
2
- #patch 0.01
3
  import os
4
  import random
5
  import uuid
@@ -10,8 +10,8 @@ import numpy as np
10
  from PIL import Image
11
  import spaces
12
  import torch
13
- from diffusers import StableDiffusion3Pipeline, FlowMatchEulerDiscreteScheduler
14
- from typing import Tuple
15
 
16
  # BaseConditions
17
  bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
@@ -141,13 +141,20 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
141
 
142
  huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
143
 
 
 
 
 
 
 
 
 
 
 
144
  if torch.cuda.is_available():
145
- repo = "stabilityai/stable-diffusion-3-medium" # You might want to replace with your specific repo if different
146
  pipe = StableDiffusion3Pipeline.from_pretrained(
147
- repo,
148
  torch_dtype=torch.float16,
149
- revision="refs/pr/26",
150
- use_auth_token=huggingface_token
151
  ).to(device)
152
 
153
  if ENABLE_CPU_OFFLOAD:
@@ -214,13 +221,12 @@ def generate(
214
  options = {
215
  "prompt": prompt,
216
  "negative_prompt": negative_prompt,
217
- "width": width,
218
- "height": height,
219
  "guidance_scale": guidance_scale,
220
- "num_inference_steps": 20,
221
  "generator": generator,
 
 
 
222
  "num_images_per_prompt": num_images,
223
- "use_resolution_binning": use_resolution_binning,
224
  "output_type": "pil",
225
  }
226
 
 
1
  #!/usr/bin/env python
2
+ #patch 0.01yle(collage_style, prompt, negative_prompt)
3
  import os
4
  import random
5
  import uuid
 
10
  from PIL import Image
11
  import spaces
12
  import torch
13
+ from diffusers import StableDiffusion3Pipeline, DPMSolverMultistepScheduler, AutoencoderKL
14
+ from huggingface_hub import snapshot_download
15
 
16
  # BaseConditions
17
  bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
 
141
 
142
  huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
143
 
144
+ # Download the model to a local directory
145
+ model_path = snapshot_download(
146
+ repo_id="stabilityai/stable-diffusion-3-medium",
147
+ revision="refs/pr/26",
148
+ repo_type="model",
149
+ ignore_patterns=["*.md", "*.gitattributes"],
150
+ local_dir="stable-diffusion-3-medium",
151
+ token=huggingface_token,
152
+ )
153
+
154
  if torch.cuda.is_available():
 
155
  pipe = StableDiffusion3Pipeline.from_pretrained(
156
+ model_path,
157
  torch_dtype=torch.float16,
 
 
158
  ).to(device)
159
 
160
  if ENABLE_CPU_OFFLOAD:
 
221
  options = {
222
  "prompt": prompt,
223
  "negative_prompt": negative_prompt,
 
 
224
  "guidance_scale": guidance_scale,
 
225
  "generator": generator,
226
+ "num_inference_steps": 25,
227
+ "height": height,
228
+ "width": width,
229
  "num_images_per_prompt": num_images,
 
230
  "output_type": "pil",
231
  }
232