Hatman commited on
Commit
a5df98e
·
verified ·
1 Parent(s): 566b8e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -16,6 +16,11 @@ dtype = torch.float16 if torch.cuda.is_available() else torch.float32
16
  pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=dtype).to(device)
17
  pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin")
18
 
 
 
 
 
 
19
  @spaces.GPU(enable_queue=True)
20
  def create_image(image_pil,
21
  prompt,
@@ -44,7 +49,7 @@ def create_image(image_pil,
44
  pipeline.set_ip_adapter_scale(scale)
45
 
46
  style_image = load_image(image_pil)
47
- generator = torch.Generator(device=device).manual_seed(randomize_seed_fn(seed, False))
48
 
49
  image = pipeline(
50
  prompt=prompt,
 
16
  pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=dtype).to(device)
17
  pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin")
18
 
19
+ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
20
+ if randomize_seed:
21
+ seed = random.randint(0, 2000)
22
+ return seed
23
+
24
  @spaces.GPU(enable_queue=True)
25
  def create_image(image_pil,
26
  prompt,
 
49
  pipeline.set_ip_adapter_scale(scale)
50
 
51
  style_image = load_image(image_pil)
52
+ generator = torch.Generator(device=device).manual_seed(randomize_seed_fn(seed, True))
53
 
54
  image = pipeline(
55
  prompt=prompt,