Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,10 @@ import gradio as gr
|
|
| 6 |
import numpy as np
|
| 7 |
import torch
|
| 8 |
from PIL import Image
|
| 9 |
-
from diffusers import StableDiffusionXLPipeline, EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, AutoencoderKL
|
| 10 |
from custom_pipeline import CosStableDiffusionXLInstructPix2PixPipeline
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
from huggingface_hub import InferenceClient
|
| 13 |
-
from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler
|
| 14 |
|
| 15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 16 |
dtype = torch.float16
|
|
@@ -19,17 +18,20 @@ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype
|
|
| 19 |
repo = "fluently/Fluently-XL-Final"
|
| 20 |
|
| 21 |
pipe_best = StableDiffusionXLPipeline.from_pretrained(repo, torch_dtype=torch.float16, vae=vae)
|
|
|
|
| 22 |
pipe_best.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle")
|
| 23 |
pipe_best.load_lora_weights("KingNish/Better-Image-XL-Lora", weight_name="example-03.safetensors", adapter_name="lora")
|
| 24 |
pipe_best.set_adapters(["lora","dalle"], adapter_weights=[1.5, 0.7])
|
| 25 |
pipe_best.to("cuda")
|
| 26 |
|
| 27 |
pipe_3D = StableDiffusionXLPipeline.from_pretrained(repo, torch_dtype=torch.float16, vae=vae)
|
|
|
|
| 28 |
pipe_3D.load_lora_weights("artificialguybr/3DRedmond-V1", weight_name="3DRedmond-3DRenderStyle-3DRenderAF.safetensors", adapter_name="3D")
|
| 29 |
pipe_3D.set_adapters(["3D"])
|
| 30 |
pipe_3D.to("cuda")
|
| 31 |
|
| 32 |
pipe_logo = StableDiffusionXLPipeline.from_pretrained(repo, torch_dtype=torch.float16, vae=vae)
|
|
|
|
| 33 |
pipe_logo.load_lora_weights("artificialguybr/LogoRedmond-LogoLoraForSDXL", weight_name="LogoRedmond_LogoRedAF.safetensors", adapter_name="logo")
|
| 34 |
pipe_logo.set_adapters(["logo"])
|
| 35 |
pipe_logo.to("cuda")
|
|
@@ -60,10 +62,11 @@ def set_timesteps_patched(self, num_inference_steps: int, device = None):
|
|
| 60 |
# Image Editor
|
| 61 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
| 62 |
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
| 63 |
-
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file(
|
| 64 |
-
|
| 65 |
-
)
|
| 66 |
-
pipe_edit.
|
|
|
|
| 67 |
pipe_edit.to("cuda")
|
| 68 |
|
| 69 |
# Generator
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
import torch
|
| 8 |
from PIL import Image
|
| 9 |
+
from diffusers import StableDiffusionXLPipeline, EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, AutoencoderKL, EulerAncestralDiscreteScheduler
|
| 10 |
from custom_pipeline import CosStableDiffusionXLInstructPix2PixPipeline
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
from huggingface_hub import InferenceClient
|
|
|
|
| 13 |
|
| 14 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 15 |
dtype = torch.float16
|
|
|
|
| 18 |
repo = "fluently/Fluently-XL-Final"
|
| 19 |
|
| 20 |
pipe_best = StableDiffusionXLPipeline.from_pretrained(repo, torch_dtype=torch.float16, vae=vae)
|
| 21 |
+
pipe_best.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe_best.scheduler.config)
|
| 22 |
pipe_best.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle")
|
| 23 |
pipe_best.load_lora_weights("KingNish/Better-Image-XL-Lora", weight_name="example-03.safetensors", adapter_name="lora")
|
| 24 |
pipe_best.set_adapters(["lora","dalle"], adapter_weights=[1.5, 0.7])
|
| 25 |
pipe_best.to("cuda")
|
| 26 |
|
| 27 |
pipe_3D = StableDiffusionXLPipeline.from_pretrained(repo, torch_dtype=torch.float16, vae=vae)
|
| 28 |
+
pipe_3D.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe_3D.scheduler.config)
|
| 29 |
pipe_3D.load_lora_weights("artificialguybr/3DRedmond-V1", weight_name="3DRedmond-3DRenderStyle-3DRenderAF.safetensors", adapter_name="3D")
|
| 30 |
pipe_3D.set_adapters(["3D"])
|
| 31 |
pipe_3D.to("cuda")
|
| 32 |
|
| 33 |
pipe_logo = StableDiffusionXLPipeline.from_pretrained(repo, torch_dtype=torch.float16, vae=vae)
|
| 34 |
+
pipe_logo.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe_logo.scheduler.config)
|
| 35 |
pipe_logo.load_lora_weights("artificialguybr/LogoRedmond-LogoLoraForSDXL", weight_name="LogoRedmond_LogoRedAF.safetensors", adapter_name="logo")
|
| 36 |
pipe_logo.set_adapters(["logo"])
|
| 37 |
pipe_logo.to("cuda")
|
|
|
|
| 62 |
# Image Editor
|
| 63 |
edit_file = hf_hub_download(repo_id="stabilityai/cosxl", filename="cosxl_edit.safetensors")
|
| 64 |
EDMEulerScheduler.set_timesteps = set_timesteps_patched
|
| 65 |
+
pipe_edit = StableDiffusionXLInstructPix2PixPipeline.from_single_file( edit_file, num_in_channels=8, is_cosxl_edit=True, vae=vae, torch_dtype=torch.float16,)
|
| 66 |
+
pipe_edit.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe_edit.scheduler.config)
|
| 67 |
+
pipe_edit.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle")
|
| 68 |
+
pipe_edit.load_lora_weights("KingNish/Better-Image-XL-Lora", weight_name="example-03.safetensors", adapter_name="lora")
|
| 69 |
+
pipe_edit.set_adapters(["lora","dalle"], adapter_weights=[1.5, 0.7])
|
| 70 |
pipe_edit.to("cuda")
|
| 71 |
|
| 72 |
# Generator
|