Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,25 +23,24 @@ def flux_krea_generate(
|
|
23 |
height: int = 1024
|
24 |
) -> Optional[Image.Image]:
|
25 |
"""
|
26 |
-
|
27 |
-
|
28 |
-
This
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
Args:
|
33 |
-
prompt: Text description of the image to generate.
|
34 |
-
negative_prompt:
|
35 |
-
steps: Number of denoising steps (1-100). Higher
|
36 |
-
cfg_scale: Classifier-free guidance scale (1-20). Higher
|
37 |
-
sampler: Sampling method to use.
|
38 |
-
seed: Random seed for reproducible results. Use -1 for random seed.
|
39 |
-
strength:
|
40 |
-
width:
|
41 |
-
height:
|
42 |
-
|
43 |
Returns:
|
44 |
-
PIL
|
45 |
"""
|
46 |
if prompt == "" or prompt is None:
|
47 |
return None
|
@@ -139,10 +138,29 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
139 |
|
140 |
# Image output area to display the generated image
|
141 |
with gr.Row():
|
142 |
-
|
|
|
143 |
|
144 |
-
# Bind the button to the flux_krea_generate function
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
# Launch the Gradio app with MCP server enabled
|
148 |
app.launch(show_api=True, share=False, mcp_server=True)
|
|
|
23 |
height: int = 1024
|
24 |
) -> Optional[Image.Image]:
|
25 |
"""
|
26 |
+
Text-to-image generation with FLUX.1-Krea-dev (no input image required).
|
27 |
+
|
28 |
+
This tool generates a single image from a text prompt using the
|
29 |
+
black-forest-labs/FLUX.1-Krea-dev model on Hugging Face Inference.
|
30 |
+
|
|
|
31 |
Args:
|
32 |
+
prompt: Text description of the image to generate.
|
33 |
+
negative_prompt: What should NOT appear in the image.
|
34 |
+
steps: Number of denoising steps (1-100). Higher is slower but can improve quality.
|
35 |
+
cfg_scale: Classifier-free guidance scale (1-20). Higher = follow the prompt more closely.
|
36 |
+
sampler: Sampling method to use. One of: "DPM++ 2M Karras", "DPM++ SDE Karras", "Euler", "Euler a", "Heun", "DDIM".
|
37 |
+
seed: Random seed for reproducible results. Use -1 for a random seed per call.
|
38 |
+
strength: Generation strength (0-1). Kept for parity; not an input image strength.
|
39 |
+
width: Output width in pixels (64-1216, multiple of 32 recommended).
|
40 |
+
height: Output height in pixels (64-1216, multiple of 32 recommended).
|
41 |
+
|
42 |
Returns:
|
43 |
+
A PIL.Image of the generated result. No input image is expected or required.
|
44 |
"""
|
45 |
if prompt == "" or prompt is None:
|
46 |
return None
|
|
|
138 |
|
139 |
# Image output area to display the generated image
|
140 |
with gr.Row():
|
141 |
+
# Output component only; no input image is required by the tool
|
142 |
+
image_output = gr.Image(label="Image Output", elem_id="gallery")
|
143 |
|
144 |
+
# Bind the button to the flux_krea_generate function for the UI only
|
145 |
+
# Hide this event as an MCP tool to avoid schema confusion (UI wires image output)
|
146 |
+
text_button.click(
|
147 |
+
flux_krea_generate,
|
148 |
+
inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height],
|
149 |
+
outputs=image_output,
|
150 |
+
show_api=False,
|
151 |
+
api_description=False,
|
152 |
+
)
|
153 |
+
|
154 |
+
# Expose a dedicated MCP/API endpoint with a clear schema (text-to-image only)
|
155 |
+
# This avoids clients misinterpreting the UI event as requiring an input image.
|
156 |
+
gr.api(
|
157 |
+
flux_krea_generate,
|
158 |
+
api_name="generate_image",
|
159 |
+
api_description=(
|
160 |
+
"Generate an image from a text prompt using FLUX.1-Krea-dev. "
|
161 |
+
"Inputs are text and numeric parameters only; no input image is required."
|
162 |
+
),
|
163 |
+
)
|
164 |
|
165 |
# Launch the Gradio app with MCP server enabled
|
166 |
app.launch(show_api=True, share=False, mcp_server=True)
|