ritz26 commited on
Commit
d93d849
·
1 Parent(s): abbd19b

add fast mode feature

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -144,6 +144,7 @@ def index():
144
 
145
  # Check if we have a cached person image and coordinates
146
  use_cached_person = 'person_coordinates' in session and 'person_image_path' in session
 
147
  person_coordinates = None
148
  person_path = None
149
 
@@ -174,6 +175,7 @@ def index():
174
  session['person_image_path'] = person_path
175
  session['person_coordinates'] = person_coordinates
176
  print(f"[INFO] Cached person coordinates: {person_coordinates}")
 
177
 
178
  # Process garment image
179
  tshirt_file = request.files['tshirt_image']
@@ -241,7 +243,7 @@ def index():
241
  # Serve via dynamic route with cached person info
242
  return render_template('index.html',
243
  result_img=f'/outputs/{unique_filename}',
244
- cached_person=use_cached_person,
245
  person_image_path=person_path,
246
  processing_time=f"{processing_time:.2f}s")
247
 
@@ -249,7 +251,13 @@ def index():
249
  print(f"[ERROR] {e}")
250
  return f"Error: {e}"
251
 
252
- return render_template('index.html')
 
 
 
 
 
 
253
 
254
  @app.route('/change_person', methods=['POST'])
255
  def change_person():
 
144
 
145
  # Check if we have a cached person image and coordinates
146
  use_cached_person = 'person_coordinates' in session and 'person_image_path' in session
147
+ cached_person_flag = use_cached_person
148
  person_coordinates = None
149
  person_path = None
150
 
 
175
  session['person_image_path'] = person_path
176
  session['person_coordinates'] = person_coordinates
177
  print(f"[INFO] Cached person coordinates: {person_coordinates}")
178
+ cached_person_flag = True
179
 
180
  # Process garment image
181
  tshirt_file = request.files['tshirt_image']
 
243
  # Serve via dynamic route with cached person info
244
  return render_template('index.html',
245
  result_img=f'/outputs/{unique_filename}',
246
+ cached_person=cached_person_flag,
247
  person_image_path=person_path,
248
  processing_time=f"{processing_time:.2f}s")
249
 
 
251
  print(f"[ERROR] {e}")
252
  return f"Error: {e}"
253
 
254
+ # GET request: keep person image visible if available in session
255
+ has_cached = 'person_coordinates' in session and 'person_image_path' in session
256
+ return render_template(
257
+ 'index.html',
258
+ cached_person=has_cached,
259
+ person_image_path=session.get('person_image_path') if has_cached else None
260
+ )
261
 
262
  @app.route('/change_person', methods=['POST'])
263
  def change_person():