Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_fac
|
|
44 |
model = enable_lora(lora_model, basemodel) if process_lora else basemodel
|
45 |
image, seed = await generate_image(prompt, model, "", width, height, scales, steps, seed)
|
46 |
if image is None:
|
47 |
-
return [None, None
|
48 |
|
49 |
image_path = "temp_image.jpg"
|
50 |
image.save(image_path, format="JPEG")
|
@@ -54,17 +54,17 @@ async def gen(prompt, basemodel, width, height, scales, steps, seed, upscale_fac
|
|
54 |
if upscale_image_path is not None:
|
55 |
upscale_image = Image.open(upscale_image_path)
|
56 |
upscale_image.save("upscale_image.jpg", format="JPEG")
|
57 |
-
return [image_path, "upscale_image.jpg"
|
58 |
else:
|
59 |
print("Error: The scaled image path is None")
|
60 |
-
return [image_path, image_path
|
61 |
else:
|
62 |
-
return [image_path, image_path
|
63 |
|
64 |
css = """
|
65 |
#col-container{ margin: 0 auto; max-width: 1024px;}
|
66 |
"""
|
67 |
-
|
68 |
with gr.Blocks(css=css) as demo:
|
69 |
with gr.Column(elem_id="col-container"):
|
70 |
with gr.Row():
|
@@ -72,24 +72,20 @@ with gr.Blocks(css=css) as demo:
|
|
72 |
output_res = ImageSlider(label="Flux / Upscaled")
|
73 |
with gr.Column(scale=2):
|
74 |
prompt = gr.Textbox(label="Image Description")
|
75 |
-
basemodel_choice = gr.Dropdown(label="Model", choices=["black-forest-labs/FLUX.1-schnell", "Shakker-Labs/FLUX.1-dev-LoRA-add-details"], value="black-forest-labs/FLUX.1-schnell")
|
76 |
-
lora_model_choice = gr.Dropdown(label="LoRA", choices=["XLabs-AI/flux-RealismLora"], value="XLabs-AI/flux-RealismLora")
|
77 |
process_lora = gr.Checkbox(label="LoRA Process")
|
78 |
process_upscale = gr.Checkbox(label="Scale Process")
|
79 |
upscale_factor = gr.Radio(label="Scaling Factor", choices=[2, 4, 8], value=2)
|
80 |
|
81 |
with gr.Accordion(label="Advanced Options", open=False):
|
82 |
width = gr.Slider(label="Width", minimum=512, maximum=1280, step=8, value=1280)
|
83 |
-
height = gr.Slider(label="Height", minimum=512, maximum=1280, step=8, value=
|
84 |
-
scales = gr.Slider(label="Scale", minimum=1, maximum=20, step=1, value=
|
85 |
-
steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=
|
86 |
seed = gr.Number(label="Seed", value=-1)
|
|
|
87 |
|
88 |
btn = gr.Button("Generate")
|
89 |
-
|
90 |
-
|
91 |
-
fn=gen,
|
92 |
-
inputs=[prompt, basemodel_choice, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model_choice, process_lora],
|
93 |
-
outputs=[output_res, seed_output], # Updated outputs to include seed
|
94 |
-
)
|
95 |
-
demo.launch()
|
|
|
44 |
model = enable_lora(lora_model, basemodel) if process_lora else basemodel
|
45 |
image, seed = await generate_image(prompt, model, "", width, height, scales, steps, seed)
|
46 |
if image is None:
|
47 |
+
return [None, None]
|
48 |
|
49 |
image_path = "temp_image.jpg"
|
50 |
image.save(image_path, format="JPEG")
|
|
|
54 |
if upscale_image_path is not None:
|
55 |
upscale_image = Image.open(upscale_image_path)
|
56 |
upscale_image.save("upscale_image.jpg", format="JPEG")
|
57 |
+
return [image_path, "upscale_image.jpg"]
|
58 |
else:
|
59 |
print("Error: The scaled image path is None")
|
60 |
+
return [image_path, image_path]
|
61 |
else:
|
62 |
+
return [image_path, image_path]
|
63 |
|
64 |
css = """
|
65 |
#col-container{ margin: 0 auto; max-width: 1024px;}
|
66 |
"""
|
67 |
+
|
68 |
with gr.Blocks(css=css) as demo:
|
69 |
with gr.Column(elem_id="col-container"):
|
70 |
with gr.Row():
|
|
|
72 |
output_res = ImageSlider(label="Flux / Upscaled")
|
73 |
with gr.Column(scale=2):
|
74 |
prompt = gr.Textbox(label="Image Description")
|
75 |
+
basemodel_choice = gr.Dropdown(label="Model", choices=["black-forest-labs/FLUX.1-schnell", "black-forest-labs/FLUX.1-DEV", "enhanceaiteam/Flux-uncensored", "Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro", "Shakker-Labs/FLUX.1-dev-LoRA-add-details", "city96/FLUX.1-dev-gguf"], value="black-forest-labs/FLUX.1-schnell")
|
76 |
+
lora_model_choice = gr.Dropdown(label="LoRA", choices=["Shakker-Labs/FLUX.1-dev-LoRA-add-details", "XLabs-AI/flux-RealismLora", "enhanceaiteam/Flux-uncensored"], value="XLabs-AI/flux-RealismLora")
|
77 |
process_lora = gr.Checkbox(label="LoRA Process")
|
78 |
process_upscale = gr.Checkbox(label="Scale Process")
|
79 |
upscale_factor = gr.Radio(label="Scaling Factor", choices=[2, 4, 8], value=2)
|
80 |
|
81 |
with gr.Accordion(label="Advanced Options", open=False):
|
82 |
width = gr.Slider(label="Width", minimum=512, maximum=1280, step=8, value=1280)
|
83 |
+
height = gr.Slider(label="Height", minimum=512, maximum=1280, step=8, value=768)
|
84 |
+
scales = gr.Slider(label="Scale", minimum=1, maximum=20, step=1, value=8)
|
85 |
+
steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=8)
|
86 |
seed = gr.Number(label="Seed", value=-1)
|
87 |
+
print(seed)
|
88 |
|
89 |
btn = gr.Button("Generate")
|
90 |
+
btn.click(fn=gen, inputs=[prompt, basemodel_choice, width, height, scales, steps, seed, upscale_factor, process_upscale, lora_model_choice, process_lora], outputs=output_res,)
|
91 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|