GitHub Actions commited on
Commit
9047434
·
1 Parent(s): 23001f1

deploy: sync from GitHub ded10b2c8bf0361526be3cfd8375c5d664941035

Browse files
Files changed (2) hide show
  1. app.py +6 -4
  2. static/script.js +4 -4
app.py CHANGED
@@ -172,7 +172,8 @@ def preview_image():
172
  try:
173
  data = request.get_json()
174
  uuid = data.get('uuid')
175
- session_id = session['id']
 
176
  _meta = _load_session_meta(session_id)
177
  uuid_map_to_uuid_imgname = session.get('uuid_map_to_uuid_imgname') or _meta.get('uuid_map_to_uuid_imgname', {})
178
  img_name = uuid_map_to_uuid_imgname.get(uuid)
@@ -395,7 +396,8 @@ def annotate_image():
395
  data = request.get_json()
396
  uuid = data.get('uuid')
397
  confidence = float(data.get('confidence', 0.5))
398
- session_id = session['id']
 
399
  _meta = _load_session_meta(session_id)
400
  uuid_map_to_uuid_imgname = session.get('uuid_map_to_uuid_imgname') or _meta.get('uuid_map_to_uuid_imgname', {})
401
  img_name = uuid_map_to_uuid_imgname.get(uuid)
@@ -435,7 +437,7 @@ def export_images():
435
  try:
436
  data = request.get_json()
437
  confidence = float(data.get('confidence', 0.5))
438
- session_id = session['id']
439
  _meta = _load_session_meta(session_id)
440
  filename_map = session.get('filename_map') or _meta.get('filename_map', {})
441
  uuid_map_to_uuid_imgname = session.get('uuid_map_to_uuid_imgname') or _meta.get('uuid_map_to_uuid_imgname', {})
@@ -486,7 +488,7 @@ def export_images():
486
  def export_csv():
487
  try:
488
  data = request.json
489
- session_id = session['id']
490
  job_state = session.get('job_state')
491
  _meta = _load_session_meta(session_id)
492
  filename_map = session.get('filename_map') or _meta.get('filename_map', {})
 
172
  try:
173
  data = request.get_json()
174
  uuid = data.get('uuid')
175
+ # Prefer client-supplied session_id (cookie may differ on HF Spaces HTTPS proxy)
176
+ session_id = data.get('session_id') or session['id']
177
  _meta = _load_session_meta(session_id)
178
  uuid_map_to_uuid_imgname = session.get('uuid_map_to_uuid_imgname') or _meta.get('uuid_map_to_uuid_imgname', {})
179
  img_name = uuid_map_to_uuid_imgname.get(uuid)
 
396
  data = request.get_json()
397
  uuid = data.get('uuid')
398
  confidence = float(data.get('confidence', 0.5))
399
+ # Prefer client-supplied session_id (cookie may differ on HF Spaces HTTPS proxy)
400
+ session_id = data.get('session_id') or session['id']
401
  _meta = _load_session_meta(session_id)
402
  uuid_map_to_uuid_imgname = session.get('uuid_map_to_uuid_imgname') or _meta.get('uuid_map_to_uuid_imgname', {})
403
  img_name = uuid_map_to_uuid_imgname.get(uuid)
 
437
  try:
438
  data = request.get_json()
439
  confidence = float(data.get('confidence', 0.5))
440
+ session_id = data.get('session_id') or session['id']
441
  _meta = _load_session_meta(session_id)
442
  filename_map = session.get('filename_map') or _meta.get('filename_map', {})
443
  uuid_map_to_uuid_imgname = session.get('uuid_map_to_uuid_imgname') or _meta.get('uuid_map_to_uuid_imgname', {})
 
488
  def export_csv():
489
  try:
490
  data = request.json
491
+ session_id = data.get('session_id') or session['id']
492
  job_state = session.get('job_state')
493
  _meta = _load_session_meta(session_id)
494
  filename_map = session.get('filename_map') or _meta.get('filename_map', {})
static/script.js CHANGED
@@ -491,14 +491,14 @@ document.addEventListener('DOMContentLoaded', () => {
491
  method: 'POST',
492
  credentials: 'include',
493
  headers: { 'Content-Type': 'application/json' },
494
- body: JSON.stringify({ uuid: uuid, confidence })
495
  });
496
  } else {
497
  response = await fetch('/preview', {
498
  method: 'POST',
499
  credentials: 'include',
500
  headers: { 'Content-Type': 'application/json' },
501
- body: JSON.stringify({ uuid: uuid })
502
  });
503
  }
504
  if (response.ok) {
@@ -1066,7 +1066,7 @@ document.addEventListener('DOMContentLoaded', () => {
1066
  method: 'POST',
1067
  credentials: 'include',
1068
  headers: { 'Content-Type': 'application/json' },
1069
- body: JSON.stringify({ confidence: threshold })
1070
  });
1071
  if (!resp.ok) throw new Error('Failed to export CSV');
1072
  const blob = await resp.blob();
@@ -1104,7 +1104,7 @@ document.addEventListener('DOMContentLoaded', () => {
1104
  method: 'POST',
1105
  credentials: 'include',
1106
  headers: { 'Content-Type': 'application/json' },
1107
- body: JSON.stringify({ confidence: threshold })
1108
  });
1109
  if (!resp.ok) throw new Error('Failed to export images');
1110
  const blob = await resp.blob();
 
491
  method: 'POST',
492
  credentials: 'include',
493
  headers: { 'Content-Type': 'application/json' },
494
+ body: JSON.stringify({ uuid: uuid, confidence, session_id: uploadSessionId })
495
  });
496
  } else {
497
  response = await fetch('/preview', {
498
  method: 'POST',
499
  credentials: 'include',
500
  headers: { 'Content-Type': 'application/json' },
501
+ body: JSON.stringify({ uuid: uuid, session_id: uploadSessionId })
502
  });
503
  }
504
  if (response.ok) {
 
1066
  method: 'POST',
1067
  credentials: 'include',
1068
  headers: { 'Content-Type': 'application/json' },
1069
+ body: JSON.stringify({ confidence: threshold, session_id: uploadSessionId })
1070
  });
1071
  if (!resp.ok) throw new Error('Failed to export CSV');
1072
  const blob = await resp.blob();
 
1104
  method: 'POST',
1105
  credentials: 'include',
1106
  headers: { 'Content-Type': 'application/json' },
1107
+ body: JSON.stringify({ confidence: threshold, session_id: uploadSessionId })
1108
  });
1109
  if (!resp.ok) throw new Error('Failed to export images');
1110
  const blob = await resp.blob();