Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,18 +21,13 @@ ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
|
|
21 |
|
22 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
32 |
-
pipe.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle2")
|
33 |
-
pipe.set_adapters(["dalle2"])
|
34 |
-
pipe.to("cuda")
|
35 |
-
|
36 |
|
37 |
def save_image(img):
|
38 |
unique_name = str(uuid.uuid4()) + ".png"
|
@@ -47,6 +42,7 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
47 |
@spaces.GPU(duration=30, queue=False)
|
48 |
def generate(
|
49 |
prompt: str,
|
|
|
50 |
negative_prompt: str = "",
|
51 |
use_negative_prompt: bool = False,
|
52 |
seed: int = 0,
|
@@ -58,7 +54,27 @@ def generate(
|
|
58 |
use_resolution_binning: bool = True,
|
59 |
progress=gr.Progress(track_tqdm=True),
|
60 |
):
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
63 |
generator = torch.Generator().manual_seed(seed)
|
64 |
|
@@ -112,6 +128,8 @@ with gr.Blocks(css=css) as demo:
|
|
112 |
)
|
113 |
run_button = gr.Button("Run", scale=0)
|
114 |
result = gr.Gallery(label="Result", columns=1)
|
|
|
|
|
115 |
with gr.Accordion("Advanced options", open=False):
|
116 |
with gr.Row():
|
117 |
use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True)
|
|
|
21 |
|
22 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
23 |
|
24 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
25 |
+
"sd-community/sdxl-flash",
|
26 |
+
torch_dtype=torch.float16,
|
27 |
+
use_safetensors=True,
|
28 |
+
add_watermarker=False
|
29 |
+
)
|
30 |
+
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
def save_image(img):
|
33 |
unique_name = str(uuid.uuid4()) + ".png"
|
|
|
42 |
@spaces.GPU(duration=30, queue=False)
|
43 |
def generate(
|
44 |
prompt: str,
|
45 |
+
style: str,
|
46 |
negative_prompt: str = "",
|
47 |
use_negative_prompt: bool = False,
|
48 |
seed: int = 0,
|
|
|
54 |
use_resolution_binning: bool = True,
|
55 |
progress=gr.Progress(track_tqdm=True),
|
56 |
):
|
57 |
+
if style=="BEST" :
|
58 |
+
pipe.load_lora_weights("ehristoforu/dalle-3-xl-v2", weight_name="dalle-3-xl-lora-v2.safetensors", adapter_name="dalle2")
|
59 |
+
pipe.load_lora_weights("ehristoforu/dalle-3-xl", weight_name="dalle-3-xl-lora-v1.safetensors", adapter_name="dalle1")
|
60 |
+
pipe.set_adapters(["dalle2","dalle1"], adapter_weights=[1.5, 0.5])
|
61 |
+
elif style=="Origami":
|
62 |
+
pipe.load_lora_weights("RalFinger/origami-style-sdxl-lora", weight_name="ral-orgmi-sdxl.safetensors", adapter_name="origami")
|
63 |
+
pipe.set_adapters(["origami"], adapter_weights=[2])
|
64 |
+
elif style=="3D":
|
65 |
+
pipe.load_lora_weights("artificialguybr/3DRedmond-V1", weight_name="3DRedmond-3DRenderStyle-3DRenderAF.safetensors", adapter_name="dalle2")
|
66 |
+
pipe.load_lora_weights("goofyai/3d_render_style_xl", weight_name="3d_render_style_xl.safetensors", adapter_name="dalle1")
|
67 |
+
pipe.set_adapters(["dalle2","dalle1"], adapter_weights=[1.1, 0.8])
|
68 |
+
elif style=="PixelART":
|
69 |
+
pipe.load_lora_weights("artificialguybr/PixelArtRedmond", weight_name="PixelArtRedmond-Lite64.safetensors", adapter_name="lora")
|
70 |
+
pipe.load_lora_weights("nerijs/pixel-art-xl", weight_name="pixel-art-xl.safetensors", adapter_name="pixel")
|
71 |
+
pipe.set_adapters(["lora", "pixel"], adapter_weights=[1.0, 1.2])
|
72 |
+
elif style=="Logo":
|
73 |
+
pipe.load_lora_weights("artificialguybr/StickersRedmond", weight_name="StickersRedmond.safetensors", adapter_name="lora")
|
74 |
+
pipe.load_lora_weights("artificialguybr/LogoRedmond-LogoLoraForSDXL", weight_name="LogoRedmond_LogoRedAF.safetensors", adapter_name="pixel")
|
75 |
+
pipe.set_adapters(["lora", "pixel"], adapter_weights=[0.5, 1.2])
|
76 |
+
else:
|
77 |
+
pipe.to("cuda")
|
78 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
79 |
generator = torch.Generator().manual_seed(seed)
|
80 |
|
|
|
128 |
)
|
129 |
run_button = gr.Button("Run", scale=0)
|
130 |
result = gr.Gallery(label="Result", columns=1)
|
131 |
+
with gr.Row():
|
132 |
+
style = gr.Radio(choices=["Default","BEST","3D", "PixelART","Logo","Origami"],label="Style", value="Default")
|
133 |
with gr.Accordion("Advanced options", open=False):
|
134 |
with gr.Row():
|
135 |
use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True)
|