pseudotheos
commited on
Commit
·
ea7b3db
1
Parent(s):
c7f2b00
Update app.py
Browse files
app.py
CHANGED
@@ -201,27 +201,17 @@ def generate_image_from_parameters(prompt, guidance_scale, controlnet_scale, con
|
|
201 |
control_image = Image.open(temp_image_path)
|
202 |
|
203 |
# Call existing inference function with the provided parameters
|
204 |
-
generated_image = inference(control_image, prompt, "", guidance_scale, controlnet_scale, 0, controlnet_end, upscaler_strength, seed, sampler_type)
|
205 |
-
|
206 |
-
# Specify the desired output directory for saving generated images
|
207 |
-
output_directory = "/home/user/app/generated_files"
|
208 |
-
|
209 |
-
# Create the output directory if it doesn't exist
|
210 |
-
os.makedirs(output_directory, exist_ok=True)
|
211 |
-
|
212 |
-
# Generate a unique filename for the saved image
|
213 |
-
filename = f"generated_image_{int(time.time())}.png"
|
214 |
-
|
215 |
-
# Save the generated image to the permanent location
|
216 |
-
output_path = os.path.join(output_directory, filename)
|
217 |
-
generated_image.save(output_path, format="PNG")
|
218 |
|
219 |
-
#
|
220 |
-
|
221 |
-
|
|
|
|
|
222 |
|
223 |
-
# Return the image data
|
224 |
-
|
|
|
225 |
|
226 |
except Exception as e:
|
227 |
# Handle exceptions and return an error message if something goes wrong
|
|
|
201 |
control_image = Image.open(temp_image_path)
|
202 |
|
203 |
# Call existing inference function with the provided parameters
|
204 |
+
generated_image, _, _, _ = inference(control_image, prompt, "", guidance_scale, controlnet_scale, 0, controlnet_end, upscaler_strength, seed, sampler_type)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
+
# Save the generated image as binary data
|
207 |
+
output_image_io = io.BytesIO()
|
208 |
+
generated_image.save(output_image_io, format="PNG")
|
209 |
+
output_image_io.seek(0)
|
210 |
+
output_image_binary = output_image_io.read()
|
211 |
|
212 |
+
# Return the generated image binary data
|
213 |
+
logger.debug("Output Values: generated_image=<binary data>")
|
214 |
+
return output_image_binary
|
215 |
|
216 |
except Exception as e:
|
217 |
# Handle exceptions and return an error message if something goes wrong
|