giorgio-caparvi commited on
Commit
e2edca9
·
1 Parent(s): a212e09

checking image creation

Browse files
Files changed (1) hide show
  1. api/app.py +16 -4
api/app.py CHANGED
@@ -77,13 +77,25 @@ def generate_design():
77
  # Esegui la funzione `main()` di eval.py passando gli argomenti
78
  final_image = eval.main(args)
79
 
80
- # Converti l'immagine in un buffer di memoria
 
 
 
 
 
 
 
 
 
81
  img_io = io.BytesIO()
82
- final_image.save(img_io, 'JPEG') # Cambia il formato se necessario
83
- img_io.seek(0) # Riporta il puntatore all'inizio del buffer
 
84
 
85
- # Invia l'immagine come file scaricabile
 
86
  return send_file(img_io, mimetype='image/jpeg', as_attachment=True, attachment_filename='generated_image.jpg')
 
87
  except Exception as e:
88
  return str(e), 500
89
 
 
77
  # Esegui la funzione `main()` di eval.py passando gli argomenti
78
  final_image = eval.main(args)
79
 
80
+ # Save the image to the current directory
81
+ save_path = os.path.join(os.getcwd(), 'generated_image.jpg')
82
+ final_image.save(save_path, 'JPEG') # Save the image in the current directory
83
+
84
+ # Print the contents of the current directory
85
+ print("Files in current directory:")
86
+ for file_name in os.listdir(os.getcwd()):
87
+ print(file_name)
88
+
89
+ # Also save the image to a BytesIO buffer to return via HTTP
90
  img_io = io.BytesIO()
91
+ final_image.save(img_io, 'JPEG')
92
+ img_io.seek(0)
93
+
94
 
95
+
96
+ # Return the image as a file download
97
  return send_file(img_io, mimetype='image/jpeg', as_attachment=True, attachment_filename='generated_image.jpg')
98
+
99
  except Exception as e:
100
  return str(e), 500
101