updated image download format
Browse files
app.py
CHANGED
@@ -171,7 +171,11 @@ def generate_image(prompt: str, output_format: str = 'png') -> Tuple[Optional[Im
|
|
171 |
# Convert image to specified format
|
172 |
downloadable_image = convert_image(image, output_format)
|
173 |
|
174 |
-
|
|
|
|
|
|
|
|
|
175 |
|
176 |
except Exception as e:
|
177 |
print(f"Image generation error: {e}")
|
@@ -223,11 +227,11 @@ def create_gradio_interface():
|
|
223 |
# Status Output
|
224 |
status_output = gr.Textbox(label="Status")
|
225 |
|
226 |
-
# Download Button
|
227 |
download_button = gr.File(
|
228 |
label="Download Image",
|
229 |
file_count="single",
|
230 |
-
type="file
|
231 |
)
|
232 |
|
233 |
# Event Handlers
|
|
|
171 |
# Convert image to specified format
|
172 |
downloadable_image = convert_image(image, output_format)
|
173 |
|
174 |
+
# Create a temporary file for download
|
175 |
+
temp_file = io.BytesIO(downloadable_image)
|
176 |
+
temp_file.name = f"generated_image.{output_format.lower()}"
|
177 |
+
|
178 |
+
return image, "Image generated successfully!", temp_file
|
179 |
|
180 |
except Exception as e:
|
181 |
print(f"Image generation error: {e}")
|
|
|
227 |
# Status Output
|
228 |
status_output = gr.Textbox(label="Status")
|
229 |
|
230 |
+
# Download Button (Fixed to use binary type)
|
231 |
download_button = gr.File(
|
232 |
label="Download Image",
|
233 |
file_count="single",
|
234 |
+
type="binary" # Changed from 'file' to 'binary'
|
235 |
)
|
236 |
|
237 |
# Event Handlers
|