doniramdani820 commited on
Commit
4fe1c86
Β·
verified Β·
1 Parent(s): d27713e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -519,8 +519,13 @@ async def handle_upright_challenge(data: dict) -> dict:
519
 
520
  # Debug: Log image dimensions
521
  logger.info(f"πŸ” UPRIGHT DEBUG: Original image dimensions: {original_w}x{original_h}")
522
-
523
- input_tensor = preprocess_image(image_bytes, model_data['input_size'])
 
 
 
 
 
524
  outputs = model_data['session'].run(None, {model_data['input_name']: input_tensor})[0]
525
 
526
  predictions = np.squeeze(outputs).T
@@ -547,9 +552,9 @@ async def handle_upright_challenge(data: dict) -> dict:
547
  # Debug: Log model space coordinates
548
  logger.info(f"πŸ” UPRIGHT DEBUG: Best detection (model space): x_center={box_model[0]:.2f}, y_center={box_model[1]:.2f}, width={box_model[2]:.2f}, height={box_model[3]:.2f}")
549
 
550
- scale = min(model_data['input_size'] / original_w, model_data['input_size'] / original_h)
551
- pad_x = (model_data['input_size'] - original_w * scale) / 2
552
- pad_y = (model_data['input_size'] - original_h * scale) / 2
553
 
554
  # Debug: Log scaling parameters
555
  logger.info(f"πŸ” UPRIGHT DEBUG: Scaling parameters: scale={scale:.4f}, pad_x={pad_x:.2f}, pad_y={pad_y:.2f}")
 
519
 
520
  # Debug: Log image dimensions
521
  logger.info(f"πŸ” UPRIGHT DEBUG: Original image dimensions: {original_w}x{original_h}")
522
+
523
+ # Determine input size for this inference (prefer model config, default to 640 for consistency with ONNX test)
524
+ input_size = model_data.get('input_size')
525
+ if not isinstance(input_size, int) or input_size <= 0:
526
+ input_size = 640
527
+
528
+ input_tensor = preprocess_image(image_bytes, input_size)
529
  outputs = model_data['session'].run(None, {model_data['input_name']: input_tensor})[0]
530
 
531
  predictions = np.squeeze(outputs).T
 
552
  # Debug: Log model space coordinates
553
  logger.info(f"πŸ” UPRIGHT DEBUG: Best detection (model space): x_center={box_model[0]:.2f}, y_center={box_model[1]:.2f}, width={box_model[2]:.2f}, height={box_model[3]:.2f}")
554
 
555
+ scale = min(input_size / original_w, input_size / original_h)
556
+ pad_x = (input_size - original_w * scale) / 2
557
+ pad_y = (input_size - original_h * scale) / 2
558
 
559
  # Debug: Log scaling parameters
560
  logger.info(f"πŸ” UPRIGHT DEBUG: Scaling parameters: scale={scale:.4f}, pad_x={pad_x:.2f}, pad_y={pad_y:.2f}")