Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,10 +15,15 @@ pipe = DiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.bfloat16)
|
|
15 |
|
16 |
lora_repo = "kaytoo2022/kaytoo2022-flux"
|
17 |
trigger_word = "" # Leave trigger_word blank if not used.
|
18 |
-
pipe.load_lora_weights(lora_repo)
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
pipe.to("cuda")
|
24 |
|
@@ -65,11 +70,13 @@ example_width = 1152
|
|
65 |
example_height = 896
|
66 |
example_seed = 3981632454
|
67 |
example_lora_scale = 0.85
|
|
|
|
|
68 |
|
69 |
def load_example():
|
70 |
# Load example image from file
|
71 |
example_image = Image.open(example_image_path)
|
72 |
-
return example_prompt, example_cfg_scale, example_steps, True, example_seed, example_width, example_height, example_lora_scale, example_image
|
73 |
|
74 |
with gr.Blocks() as app:
|
75 |
gr.Markdown("# Flux Lora Image Generator")
|
@@ -84,12 +91,14 @@ with gr.Blocks() as app:
|
|
84 |
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
85 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=example_seed)
|
86 |
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=1, step=0.01, value=example_lora_scale)
|
|
|
|
|
87 |
with gr.Column(scale=1):
|
88 |
result = gr.Image(label="Generated Image")
|
89 |
gr.Markdown("Generate images using Flux and a text prompt.\nUse `b3lla dog` in the prompt to trigger generating an image of Bella the dog.\n[[non-commercial license, Flux.1 Dev](https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md)]")
|
90 |
|
91 |
# Automatically load example data and image when the interface is launched
|
92 |
-
app.load(load_example, inputs=[], outputs=[prompt, cfg_scale, steps, randomize_seed, seed, width, height, lora_scale, result])
|
93 |
|
94 |
generate_button.click(
|
95 |
run_lora,
|
|
|
15 |
|
16 |
lora_repo = "kaytoo2022/kaytoo2022-flux"
|
17 |
trigger_word = "" # Leave trigger_word blank if not used.
|
18 |
+
pipe.load_lora_weights(lora_repo, adapter_name='kaytoo')
|
19 |
|
20 |
+
lora_ghibli = 'alvarobartt/ghibli-characters-flux-lora'
|
21 |
+
pipe.load_lora_weights(lora_ghibli, adapter_name='ghibli')
|
22 |
+
|
23 |
+
lora_repo_anime = "aleksa-codes/flux-ghibsky-illustration"
|
24 |
+
pipe.load_lora_weights(lora_repo_anime, adapter_name='ghibsky')
|
25 |
+
|
26 |
+
pipe.set_adapters(["kaytoo", "ghibli", "ghibsky"], adapter_weights=[0.85, 0.65, 0.65])
|
27 |
|
28 |
pipe.to("cuda")
|
29 |
|
|
|
70 |
example_height = 896
|
71 |
example_seed = 3981632454
|
72 |
example_lora_scale = 0.85
|
73 |
+
example_lora_scale_ghibli = 0.65
|
74 |
+
example_lora_scale_ghibsky = 0.65
|
75 |
|
76 |
def load_example():
|
77 |
# Load example image from file
|
78 |
example_image = Image.open(example_image_path)
|
79 |
+
return example_prompt, example_cfg_scale, example_steps, True, example_seed, example_width, example_height, example_lora_scale, example_lora_scale_ghibli, example_lora_scale_ghibsky, example_image
|
80 |
|
81 |
with gr.Blocks() as app:
|
82 |
gr.Markdown("# Flux Lora Image Generator")
|
|
|
91 |
randomize_seed = gr.Checkbox(True, label="Randomize seed")
|
92 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=example_seed)
|
93 |
lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=1, step=0.01, value=example_lora_scale)
|
94 |
+
lora_scale_ghibli = gr.Slider(label="LoRA Scale (ghibli)", minimum=0, maximum=1, step=0.01, value=example_lora_scale_ghibli)
|
95 |
+
lora_scale_ghibsky = gr.Slider(label="LoRA Scale (ghibli)", minimum=0, maximum=1, step=0.01, value=example_lora_scale_ghibsky)
|
96 |
with gr.Column(scale=1):
|
97 |
result = gr.Image(label="Generated Image")
|
98 |
gr.Markdown("Generate images using Flux and a text prompt.\nUse `b3lla dog` in the prompt to trigger generating an image of Bella the dog.\n[[non-commercial license, Flux.1 Dev](https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md)]")
|
99 |
|
100 |
# Automatically load example data and image when the interface is launched
|
101 |
+
app.load(load_example, inputs=[], outputs=[prompt, cfg_scale, steps, randomize_seed, seed, width, height, lora_scale, lora_scale_ghibli, lora_scale_ghibsky, result])
|
102 |
|
103 |
generate_button.click(
|
104 |
run_lora,
|