giorgio-caparvi commited on
Commit
cb14b48
·
1 Parent(s): 63a4201

serializing image and returning only the one modified

Browse files
api/app.py CHANGED
@@ -78,25 +78,22 @@ def generate_design():
78
 
79
  # Save the image to the current directory
80
  save_path = os.path.join(os.getcwd(), 'generated_image.jpg')
81
- final_image.save(save_path, 'JPEG') # Save the image in the current directory
82
 
83
  # Print the contents of the current directory
84
- print("Files in current directory:")
85
- for file_name in os.listdir(os.getcwd()):
86
- print(file_name)
87
 
88
- # Invia l'immagine come file scaricabile direttamente dalla directory
89
- return send_file(save_path, mimetype='image/jpeg', as_attachment=True)
90
-
91
  # Also save the image to a BytesIO buffer to return via HTTP
92
- #img_io = io.BytesIO()
93
- #final_image.save(img_io, 'JPEG')
94
- #img_io.seek(0)
95
 
96
 
97
 
98
  # Return the image as a file download
99
- #return send_file(img_io, mimetype='image/jpeg', as_attachment=True, download_name='generated_image.jpg')
100
 
101
  except Exception as e:
102
  return str(e), 500
 
78
 
79
  # Save the image to the current directory
80
  save_path = os.path.join(os.getcwd(), 'generated_image.jpg')
81
+ #final_image.save(save_path, 'JPEG') # Save the image in the current directory
82
 
83
  # Print the contents of the current directory
84
+ #print("Files in current directory:")
85
+ #for file_name in os.listdir(os.getcwd()):
86
+ # print(file_name)
87
 
 
 
 
88
  # Also save the image to a BytesIO buffer to return via HTTP
89
+ img_io = io.BytesIO()
90
+ final_image.save(img_io, 'JPEG')
91
+ img_io.seek(0)
92
 
93
 
94
 
95
  # Return the image as a file download
96
+ return send_file(img_io, mimetype='image/jpeg', as_attachment=True, download_name='in memory_image.jpg')
97
 
98
  except Exception as e:
99
  return str(e), 500
api/model/assets/data/vitonhd/test/im_sketch/old_12419_00.png ADDED
api/model/assets/data/vitonhd/test/image/old_12419_00.jpg ADDED