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

added paired and unpaired

Browse files
api/app.py CHANGED
@@ -37,7 +37,7 @@ def current_endpoint():
37
  # Return the current URL to the client
38
  return f"Current Endpoint: {full_url}"
39
 
40
- @app.route('/generate-design', methods=['GET'])
41
  def generate_design():
42
 
43
  '''# Esegui il comando di generazione
@@ -92,6 +92,67 @@ def generate_design():
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
 
 
37
  # Return the current URL to the client
38
  return f"Current Endpoint: {full_url}"
39
 
40
+ @app.route('/generate-design-paired', methods=['GET'])
41
  def generate_design():
42
 
43
  '''# Esegui il comando di generazione
 
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
100
+
101
+ @app.route('/generate-design-unpaired', methods=['GET'])
102
+ def generate_design():
103
+
104
+ '''# Esegui il comando di generazione
105
+ command = [
106
+ 'python', '/api/model/src/eval.py',
107
+ '--dataset_path', '/api/model/assets/data/vitonhd',
108
+ '--batch_size', '1',
109
+ '--mixed_precision', 'fp16',
110
+ '--output_dir', output_dir,
111
+ '--save_name', 'generato_paired',
112
+ '--num_workers_test', '4',
113
+ '--sketch_cond_rate', '0.2',
114
+ '--dataset', 'vitonhd',
115
+ '--start_cond_rate', '0.0',
116
+ '--test_order', 'paired'
117
+ ]
118
+
119
+ # Esegui il comando senza gestire il JSON, lascia che l'errore venga stampato
120
+ subprocess.run(command, check=True)'''
121
+ try:
122
+ # Creiamo una lista di argomenti come quelli che passeresti via CLI
123
+ sys.argv = [
124
+ 'eval.py',
125
+ '--dataset_path', '/api/model/assets/data/vitonhd',
126
+ '--batch_size', '1',
127
+ '--mixed_precision', 'fp16',
128
+ #'--output_dir', '/api/output/generato_paired_paired/images',
129
+ '--save_name', 'generato_unpaired',
130
+ '--num_workers_test', '4',
131
+ '--sketch_cond_rate', '0.2',
132
+ '--dataset', 'vitonhd',
133
+ '--start_cond_rate', '0.0',
134
+ '--test_order', 'unpaired'
135
+ ]
136
+
137
+ # Esegui la funzione `main()` di eval.py passando gli argomenti
138
+ final_image = eval.main()
139
+
140
+ # Save the image to the current directory
141
+ save_path = os.path.join(os.getcwd(), 'generated_image.jpg')
142
+ #final_image.save(save_path, 'JPEG') # Save the image in the current directory
143
+
144
+ # Print the contents of the current directory
145
+ #print("Files in current directory:")
146
+ #for file_name in os.listdir(os.getcwd()):
147
+ # print(file_name)
148
+
149
+ # Also save the image to a BytesIO buffer to return via HTTP
150
+ img_io = io.BytesIO()
151
+ final_image.save(img_io, 'JPEG')
152
+ img_io.seek(0)
153
+
154
+
155
+
156
  # Return the image as a file download
157
  return send_file(img_io, mimetype='image/jpeg', as_attachment=True, download_name='in memory_image.jpg')
158
 
api/model/assets/data/vitonhd/captions.json CHANGED
The diff for this file is too large to render. See raw diff
 
api/model/assets/data/vitonhd/old_captions.json ADDED
The diff for this file is too large to render. See raw diff
 
api/model/assets/data/vitonhd/test/im_sketch/12419_00.png DELETED
Binary file (33.1 kB)
 
api/model/assets/data/vitonhd/test/image/12419_00.jpg DELETED
Binary file (103 kB)
 
api/model/assets/data/vitonhd/test_pairs.txt CHANGED
@@ -1,2 +1 @@
1
- 12419_00.jpg 01944_00.jpg
2
  03191_00.jpg 00349_00.jpg
 
 
1
  03191_00.jpg 00349_00.jpg