Spaces:
Runtime error
Runtime error
delete unnecessary components
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ MAX_IMAGE_SIZE = 2048
|
|
| 18 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
|
| 19 |
|
| 20 |
@spaces.GPU(duration=300)
|
| 21 |
-
def infer(prompt, lora_model, seed=
|
| 22 |
global pipe
|
| 23 |
|
| 24 |
# Load LoRA if specified
|
|
@@ -50,12 +50,6 @@ def infer(prompt, lora_model, seed=42, randomize_seed=False, width=1024, height=
|
|
| 50 |
except Exception as e:
|
| 51 |
return None, seed, f"Error during image generation: {str(e)}"
|
| 52 |
|
| 53 |
-
examples = [
|
| 54 |
-
["a tiny astronaut hatching from an egg on the moon", ""],
|
| 55 |
-
["a cat holding a sign that says hello world", ""],
|
| 56 |
-
["an anime illustration of a wiener schnitzel", ""],
|
| 57 |
-
]
|
| 58 |
-
|
| 59 |
css = """
|
| 60 |
#col-container {
|
| 61 |
margin: 0 auto;
|
|
@@ -65,9 +59,7 @@ css = """
|
|
| 65 |
|
| 66 |
with gr.Blocks(css=css) as demo:
|
| 67 |
with gr.Column(elem_id="col-container"):
|
| 68 |
-
gr.Markdown(f"""# FLUX.1 [dev] with
|
| 69 |
-
12B param rectified flow transformer guidance-distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/)
|
| 70 |
-
[[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)]
|
| 71 |
""")
|
| 72 |
|
| 73 |
with gr.Row():
|
|
@@ -80,11 +72,6 @@ with gr.Blocks(css=css) as demo:
|
|
| 80 |
)
|
| 81 |
run_button = gr.Button("Run", scale=0)
|
| 82 |
|
| 83 |
-
lora_model = gr.Text(
|
| 84 |
-
label="LoRA Model ID (optional)",
|
| 85 |
-
placeholder="Enter Hugging Face LoRA model ID",
|
| 86 |
-
)
|
| 87 |
-
|
| 88 |
result = gr.Image(label="Result", show_label=False)
|
| 89 |
output_message = gr.Textbox(label="Output Message")
|
| 90 |
|
|
@@ -127,19 +114,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 127 |
step=1,
|
| 128 |
value=28,
|
| 129 |
)
|
| 130 |
-
|
| 131 |
-
gr.Examples(
|
| 132 |
-
examples=examples,
|
| 133 |
-
fn=infer,
|
| 134 |
-
inputs=[prompt, lora_model],
|
| 135 |
-
outputs=[result, seed, output_message],
|
| 136 |
-
cache_examples="lazy"
|
| 137 |
-
)
|
| 138 |
|
| 139 |
gr.on(
|
| 140 |
triggers=[run_button.click, prompt.submit],
|
| 141 |
fn=infer,
|
| 142 |
-
inputs=[prompt,
|
| 143 |
outputs=[result, seed, output_message]
|
| 144 |
)
|
| 145 |
|
|
|
|
| 18 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
|
| 19 |
|
| 20 |
@spaces.GPU(duration=300)
|
| 21 |
+
def infer(prompt, lora_model="davisbro/half_illustration", seed=0, randomize_seed=True, width=1024, height=1024, guidance_scale=5.0, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
| 22 |
global pipe
|
| 23 |
|
| 24 |
# Load LoRA if specified
|
|
|
|
| 50 |
except Exception as e:
|
| 51 |
return None, seed, f"Error during image generation: {str(e)}"
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
css = """
|
| 54 |
#col-container {
|
| 55 |
margin: 0 auto;
|
|
|
|
| 59 |
|
| 60 |
with gr.Blocks(css=css) as demo:
|
| 61 |
with gr.Column(elem_id="col-container"):
|
| 62 |
+
gr.Markdown(f"""# FLUX.1 [dev] with half illustration lora
|
|
|
|
|
|
|
| 63 |
""")
|
| 64 |
|
| 65 |
with gr.Row():
|
|
|
|
| 72 |
)
|
| 73 |
run_button = gr.Button("Run", scale=0)
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
result = gr.Image(label="Result", show_label=False)
|
| 76 |
output_message = gr.Textbox(label="Output Message")
|
| 77 |
|
|
|
|
| 114 |
step=1,
|
| 115 |
value=28,
|
| 116 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
gr.on(
|
| 119 |
triggers=[run_button.click, prompt.submit],
|
| 120 |
fn=infer,
|
| 121 |
+
inputs=[prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
| 122 |
outputs=[result, seed, output_message]
|
| 123 |
)
|
| 124 |
|