Spaces:
Sleeping
Sleeping
shweaung
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ article_text = """
|
|
| 25 |
|
| 26 |
def query(lora_id, prompt, steps=28, cfg_scale=3.5, randomize_seed=True, seed=-1, width=1024, height=1024, output_format="PNG"):
|
| 27 |
if prompt == "" or prompt == None:
|
| 28 |
-
return None
|
| 29 |
|
| 30 |
if lora_id.strip() == "" or lora_id == None:
|
| 31 |
lora_id = "black-forest-labs/FLUX.1-dev"
|
|
@@ -71,10 +71,11 @@ def query(lora_id, prompt, steps=28, cfg_scale=3.5, randomize_seed=True, seed=-1
|
|
| 71 |
img_byte_arr = io.BytesIO()
|
| 72 |
image.save(img_byte_arr, format=output_format)
|
| 73 |
img_byte_arr.seek(0)
|
| 74 |
-
|
|
|
|
| 75 |
except Exception as e:
|
| 76 |
print(f"Error when trying to open the image: {e}")
|
| 77 |
-
return None
|
| 78 |
|
| 79 |
|
| 80 |
examples = [
|
|
@@ -119,7 +120,7 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
| 119 |
with gr.Row():
|
| 120 |
seed_output = gr.Textbox(label="Seed Used", show_copy_button=True, elem_id="seed-output")
|
| 121 |
with gr.Row():
|
| 122 |
-
download_button = gr.File(label="Download Image",
|
| 123 |
|
| 124 |
gr.Markdown(article_text)
|
| 125 |
|
|
@@ -128,12 +129,10 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', css=css) as app:
|
|
| 128 |
inputs=[text_prompt],
|
| 129 |
)
|
| 130 |
|
| 131 |
-
def download_image(
|
| 132 |
-
|
| 133 |
-
file_name = f"generated_image.{format_extension}"
|
| 134 |
-
return file_name, image
|
| 135 |
|
| 136 |
-
text_button.click(query, inputs=[custom_lora, text_prompt, steps, cfg, randomize_seed, seed, width, height, output_format], outputs=[image_output, seed_output,
|
| 137 |
-
download_button.change(download_image, inputs=[
|
| 138 |
|
| 139 |
app.launch(show_api=False, share=True)
|
|
|
|
| 25 |
|
| 26 |
def query(lora_id, prompt, steps=28, cfg_scale=3.5, randomize_seed=True, seed=-1, width=1024, height=1024, output_format="PNG"):
|
| 27 |
if prompt == "" or prompt == None:
|
| 28 |
+
return None, None, None
|
| 29 |
|
| 30 |
if lora_id.strip() == "" or lora_id == None:
|
| 31 |
lora_id = "black-forest-labs/FLUX.1-dev"
|
|
|
|
| 71 |
img_byte_arr = io.BytesIO()
|
| 72 |
image.save(img_byte_arr, format=output_format)
|
| 73 |
img_byte_arr.seek(0)
|
| 74 |
+
|
| 75 |
+
return Image.open(io.BytesIO(img_byte_arr.getvalue())), seed, io.BytesIO(img_byte_arr.getvalue())
|
| 76 |
except Exception as e:
|
| 77 |
print(f"Error when trying to open the image: {e}")
|
| 78 |
+
return None, None, None
|
| 79 |
|
| 80 |
|
| 81 |
examples = [
|
|
|
|
| 120 |
with gr.Row():
|
| 121 |
seed_output = gr.Textbox(label="Seed Used", show_copy_button=True, elem_id="seed-output")
|
| 122 |
with gr.Row():
|
| 123 |
+
download_button = gr.File(label="Download Image", elem_id="download-button")
|
| 124 |
|
| 125 |
gr.Markdown(article_text)
|
| 126 |
|
|
|
|
| 129 |
inputs=[text_prompt],
|
| 130 |
)
|
| 131 |
|
| 132 |
+
def download_image(image_data):
|
| 133 |
+
return image_data
|
|
|
|
|
|
|
| 134 |
|
| 135 |
+
text_button.click(query, inputs=[custom_lora, text_prompt, steps, cfg, randomize_seed, seed, width, height, output_format], outputs=[image_output, seed_output, download_button])
|
| 136 |
+
download_button.change(download_image, inputs=[download_button], outputs=download_button)
|
| 137 |
|
| 138 |
app.launch(show_api=False, share=True)
|