Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def predict(replicate_api, prompt, lora_id, lora_scale=0.95, aspect_ratio="1:1",
|
|
15 |
|
16 |
# Validate API key and prompt
|
17 |
if not replicate_api or not prompt:
|
18 |
-
return "Error: Missing necessary inputs.", -1
|
19 |
|
20 |
# Set the seed if randomize_seed is True
|
21 |
if randomize_seed:
|
@@ -46,11 +46,11 @@ def predict(replicate_api, prompt, lora_id, lora_scale=0.95, aspect_ratio="1:1",
|
|
46 |
"lucataco/flux-dev-lora:a22c463f11808638ad5e2ebd582e07a469031f48dd567366fb4c6fdab91d614d",
|
47 |
input=input_params
|
48 |
)
|
49 |
-
return output[0], seed # Return the generated image and seed
|
50 |
|
51 |
except Exception as e:
|
52 |
# Catch any exceptions, such as invalid API token or lack of credits
|
53 |
-
return f"Error: {str(e)}", -1
|
54 |
|
55 |
finally:
|
56 |
# Always remove the API key from the environment
|
@@ -119,6 +119,8 @@ with gr.Blocks(css=css) as demo:
|
|
119 |
submit = gr.Button("Generate Image", scale=1)
|
120 |
|
121 |
output = gr.Image(label="Output Image", show_label=True)
|
|
|
|
|
122 |
|
123 |
|
124 |
gr.Examples(
|
@@ -130,7 +132,7 @@ with gr.Blocks(css=css) as demo:
|
|
130 |
triggers=[submit.click, prompt.submit],
|
131 |
fn=predict,
|
132 |
inputs=[replicate_api, prompt, custom_lora, lora_scale, aspect_ratio, seed, randomize_seed, guidance_scale, num_inference_steps],
|
133 |
-
outputs = [output, seed]
|
134 |
)
|
135 |
|
136 |
demo.launch()
|
|
|
15 |
|
16 |
# Validate API key and prompt
|
17 |
if not replicate_api or not prompt:
|
18 |
+
return "Error: Missing necessary inputs.", -1, None
|
19 |
|
20 |
# Set the seed if randomize_seed is True
|
21 |
if randomize_seed:
|
|
|
46 |
"lucataco/flux-dev-lora:a22c463f11808638ad5e2ebd582e07a469031f48dd567366fb4c6fdab91d614d",
|
47 |
input=input_params
|
48 |
)
|
49 |
+
return output[0], seed, seed # Return the generated image and seed
|
50 |
|
51 |
except Exception as e:
|
52 |
# Catch any exceptions, such as invalid API token or lack of credits
|
53 |
+
return f"Error: {str(e)}", -1, None
|
54 |
|
55 |
finally:
|
56 |
# Always remove the API key from the environment
|
|
|
119 |
submit = gr.Button("Generate Image", scale=1)
|
120 |
|
121 |
output = gr.Image(label="Output Image", show_label=True)
|
122 |
+
|
123 |
+
seed_used = gr.Textbox(label="Seed Used", show_copy_button = True)
|
124 |
|
125 |
|
126 |
gr.Examples(
|
|
|
132 |
triggers=[submit.click, prompt.submit],
|
133 |
fn=predict,
|
134 |
inputs=[replicate_api, prompt, custom_lora, lora_scale, aspect_ratio, seed, randomize_seed, guidance_scale, num_inference_steps],
|
135 |
+
outputs = [output, seed, seed_used]
|
136 |
)
|
137 |
|
138 |
demo.launch()
|