Nessuna descrizione

runTinyYoloV2.ts 927B

12345678910111213141516171819202122232425262728293031
  1. import * as ort from "onnxruntime-react-native";
  2. import { loadOnnxSession } from "./loadModel";
  3. /**
  4. * TinyYOLOv2 (common export) expects float32 input NCHW [1,3,416,416]
  5. * output is typically [1, 125, 13, 13] (5 boxes * (5 + 20 classes) = 125)
  6. */
  7. export async function runTinyYoloV2Dummy() {
  8. const session = await loadOnnxSession();
  9. const inputName = session.inputNames[0];
  10. const outputName = session.outputNames[0];
  11. // Standard Tiny YOLOv2 input size
  12. const W = 416, H = 416;
  13. const input = new Float32Array(1 * 3 * H * W).fill(0.5); // dummy data
  14. const feeds: Record<string, ort.Tensor> = {};
  15. feeds[inputName] = new ort.Tensor("float32", input, [1, 3, H, W]);
  16. const results = await session.run(feeds);
  17. const out = results[outputName];
  18. return {
  19. inputName,
  20. outputName,
  21. dims: out.dims, // expected [1,125,13,13]
  22. dataLen: out.data.length // should match product(dims)
  23. };
  24. }