Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,8 +16,6 @@ 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=torch.float32).to(device)
|
| 17 |
pipeline.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter_sdxl.bin")
|
| 18 |
|
| 19 |
-
print(device)
|
| 20 |
-
|
| 21 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
| 22 |
if randomize_seed:
|
| 23 |
seed = random.randint(0, 2000)
|
|
@@ -34,7 +32,7 @@ def create_image(image_pil,
|
|
| 34 |
seed,
|
| 35 |
target="Load only style blocks",
|
| 36 |
):
|
| 37 |
-
|
| 38 |
if target !="Load original IP-Adapter":
|
| 39 |
if target=="Load only style blocks":
|
| 40 |
scale = {
|
|
@@ -53,8 +51,8 @@ def create_image(image_pil,
|
|
| 53 |
|
| 54 |
style_image = load_image(image_pil)
|
| 55 |
generator = torch.Generator(device=device).manual_seed(randomize_seed_fn(seed, True))
|
| 56 |
-
|
| 57 |
-
|
| 58 |
image = pipeline(
|
| 59 |
prompt=prompt,
|
| 60 |
ip_adapter_image=style_image,
|
|
|
|
| 16 |
pipeline = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float32).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)
|
|
|
|
| 32 |
seed,
|
| 33 |
target="Load only style blocks",
|
| 34 |
):
|
| 35 |
+
|
| 36 |
if target !="Load original IP-Adapter":
|
| 37 |
if target=="Load only style blocks":
|
| 38 |
scale = {
|
|
|
|
| 51 |
|
| 52 |
style_image = load_image(image_pil)
|
| 53 |
generator = torch.Generator(device=device).manual_seed(randomize_seed_fn(seed, True))
|
| 54 |
+
|
| 55 |
+
|
| 56 |
image = pipeline(
|
| 57 |
prompt=prompt,
|
| 58 |
ip_adapter_image=style_image,
|