Spaces:
Running
Running
Upload 51 files
Browse files
src/components/MultiSourceCaptioningView.tsx
CHANGED
|
@@ -72,6 +72,10 @@ import * as ort from 'onnxruntime-web';
|
|
| 72 |
// Set your YOLOv8 ONNX model URL here:
|
| 73 |
const YOLOV8_ONNX_URL = "https://huggingface.co/Quazim0t0/yolov8-onnx/resolve/main/yolov8n.onnx"; // <-- PUT YOUR ONNX FILE URL HERE
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
// 1. Load the ONNX model once
|
| 76 |
let yoloSession: ort.InferenceSession | null = null;
|
| 77 |
// Add a busy flag to prevent concurrent YOLOv8 inferences
|
|
@@ -408,12 +412,9 @@ export default function MultiSourceCaptioningView() {
|
|
| 408 |
// Draw all YOLOv8 boxes from last detection
|
| 409 |
const yoloBoxes = lastYoloBoxesRef.current;
|
| 410 |
yoloBoxes.forEach((obj: any) => {
|
| 411 |
-
|
| 412 |
-
const
|
| 413 |
-
const
|
| 414 |
-
const procH = processingVideo.videoHeight;
|
| 415 |
-
const scaleX = canvasW / procW;
|
| 416 |
-
const scaleY = canvasH / procH;
|
| 417 |
const [x1, y1, x2, y2] = obj.bbox;
|
| 418 |
const drawX = x1 * scaleX;
|
| 419 |
const drawY = y1 * scaleY;
|
|
|
|
| 72 |
// Set your YOLOv8 ONNX model URL here:
|
| 73 |
const YOLOV8_ONNX_URL = "https://huggingface.co/Quazim0t0/yolov8-onnx/resolve/main/yolov8n.onnx"; // <-- PUT YOUR ONNX FILE URL HERE
|
| 74 |
|
| 75 |
+
// Add these constants to match the YOLOv8 input size
|
| 76 |
+
const YOLOV8_INPUT_WIDTH = 640;
|
| 77 |
+
const YOLOV8_INPUT_HEIGHT = 480;
|
| 78 |
+
|
| 79 |
// 1. Load the ONNX model once
|
| 80 |
let yoloSession: ort.InferenceSession | null = null;
|
| 81 |
// Add a busy flag to prevent concurrent YOLOv8 inferences
|
|
|
|
| 412 |
// Draw all YOLOv8 boxes from last detection
|
| 413 |
const yoloBoxes = lastYoloBoxesRef.current;
|
| 414 |
yoloBoxes.forEach((obj: any) => {
|
| 415 |
+
// Scale from YOLOv8 input size to canvas size
|
| 416 |
+
const scaleX = canvas.width / YOLOV8_INPUT_WIDTH;
|
| 417 |
+
const scaleY = canvas.height / YOLOV8_INPUT_HEIGHT;
|
|
|
|
|
|
|
|
|
|
| 418 |
const [x1, y1, x2, y2] = obj.bbox;
|
| 419 |
const drawX = x1 * scaleX;
|
| 420 |
const drawY = y1 * scaleY;
|