Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -67,6 +67,120 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
|
|
| 67 |
if lora_id:
|
| 68 |
pipe.unload_lora_weights()
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
|
|
|
|
| 67 |
if lora_id:
|
| 68 |
pipe.unload_lora_weights()
|
| 69 |
|
| 70 |
+
examples = [
|
| 71 |
+
"a tiny astronaut hatching from an egg on the moon",
|
| 72 |
+
"a cat holding a sign that says hello world",
|
| 73 |
+
"an anime illustration of a wiener schnitzel",
|
| 74 |
+
]
|
| 75 |
+
|
| 76 |
+
css="""
|
| 77 |
+
#col-container {
|
| 78 |
+
margin: 0 auto;
|
| 79 |
+
max-width: 520px;
|
| 80 |
+
}
|
| 81 |
+
"""
|
| 82 |
+
|
| 83 |
+
with gr.Blocks(css=css) as demo:
|
| 84 |
+
|
| 85 |
+
with gr.Column(elem_id="col-container"):
|
| 86 |
+
gr.Markdown(f"""# FLUX.1 [dev] LoRA
|
| 87 |
+
12B param rectified flow transformer guidance-distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/)
|
| 88 |
+
[[non-commercial license](https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/LICENSE.md)] [[blog](https://blackforestlabs.ai/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-dev)]
|
| 89 |
+
""")
|
| 90 |
+
|
| 91 |
+
with gr.Row():
|
| 92 |
+
|
| 93 |
+
prompt = gr.Text(
|
| 94 |
+
label="Prompt",
|
| 95 |
+
show_label=False,
|
| 96 |
+
max_lines=1,
|
| 97 |
+
placeholder="Enter your prompt",
|
| 98 |
+
container=False,
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
run_button = gr.Button("Run", scale=0)
|
| 102 |
+
|
| 103 |
+
result = gr.Image(label="Result", show_label=False)
|
| 104 |
+
|
| 105 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 106 |
+
|
| 107 |
+
seed = gr.Slider(
|
| 108 |
+
label="Seed",
|
| 109 |
+
minimum=0,
|
| 110 |
+
maximum=MAX_SEED,
|
| 111 |
+
step=1,
|
| 112 |
+
value=0,
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 116 |
+
|
| 117 |
+
with gr.Row():
|
| 118 |
+
|
| 119 |
+
width = gr.Slider(
|
| 120 |
+
label="Width",
|
| 121 |
+
minimum=256,
|
| 122 |
+
maximum=MAX_IMAGE_SIZE,
|
| 123 |
+
step=8,
|
| 124 |
+
value=1024,
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
height = gr.Slider(
|
| 128 |
+
label="Height",
|
| 129 |
+
minimum=256,
|
| 130 |
+
maximum=MAX_IMAGE_SIZE,
|
| 131 |
+
step=8,
|
| 132 |
+
value=1024,
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
with gr.Row():
|
| 136 |
+
|
| 137 |
+
guidance_scale = gr.Slider(
|
| 138 |
+
label="Guidance Scale",
|
| 139 |
+
minimum=1,
|
| 140 |
+
maximum=15,
|
| 141 |
+
step=0.1,
|
| 142 |
+
value=3.5,
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
num_inference_steps = gr.Slider(
|
| 146 |
+
label="Number of inference steps",
|
| 147 |
+
minimum=1,
|
| 148 |
+
maximum=50,
|
| 149 |
+
step=1,
|
| 150 |
+
value=28,
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
with gr.Row():
|
| 154 |
+
lora_id = gr.Textbox(
|
| 155 |
+
label="LoRA Model ID (HuggingFace path)",
|
| 156 |
+
placeholder="username/lora-model",
|
| 157 |
+
max_lines=1
|
| 158 |
+
)
|
| 159 |
+
lora_scale = gr.Slider(
|
| 160 |
+
label="LoRA Scale",
|
| 161 |
+
minimum=0,
|
| 162 |
+
maximum=2,
|
| 163 |
+
step=0.01,
|
| 164 |
+
value=0.95,
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
gr.Examples(
|
| 168 |
+
examples = examples,
|
| 169 |
+
fn = infer,
|
| 170 |
+
inputs = [prompt],
|
| 171 |
+
outputs = [result, seed],
|
| 172 |
+
cache_examples="lazy"
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
gr.on(
|
| 176 |
+
triggers=[run_button.click, prompt.submit],
|
| 177 |
+
fn = infer,
|
| 178 |
+
inputs = [prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps,lora_id,lora_scale],
|
| 179 |
+
outputs = [result, seed]
|
| 180 |
+
)
|
| 181 |
+
|
| 182 |
+
demo.launch()
|
| 183 |
+
|
| 184 |
|
| 185 |
|
| 186 |
|