{"id":16224188,"url":"https://github.com/vladmandic/nanodet","last_synced_at":"2025-10-24T22:32:51.454Z","repository":{"id":41409338,"uuid":"350728053","full_name":"vladmandic/nanodet","owner":"vladmandic","description":"NanoDet: Tiny Object Detection for TFJS and NodeJS","archived":true,"fork":false,"pushed_at":"2022-10-29T02:11:51.000Z","size":29428,"stargazers_count":23,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-27T22:44:52.608Z","etag":null,"topics":["nanodet","object-detection","tensorflow","tensorflowjs","tfjs","tfjs-models"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vladmandic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-23T13:43:28.000Z","updated_at":"2024-09-06T23:09:57.000Z","dependencies_parsed_at":"2023-01-19T23:00:59.089Z","dependency_job_id":null,"html_url":"https://github.com/vladmandic/nanodet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fnanodet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fnanodet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fnanodet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladmandic%2Fnanodet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladmandic","download_url":"https://codeload.github.com/vladmandic/nanodet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238043943,"owners_count":19407117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nanodet","object-detection","tensorflow","tensorflowjs","tfjs","tfjs-models"],"created_at":"2024-10-10T12:23:06.503Z","updated_at":"2025-10-24T22:32:42.604Z","avatar_url":"https://github.com/vladmandic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NanoDet: Tiny Object Detection for TFJS and NodeJS\n\nModels included in `/model-tfjs-graph-*` were converted to TFJS Graph model format from the original repository  \nModels descriptors and signature have been additionally parsed for readability\n\n## Implementation\n\nActual model parsing implementation in `nanodet.js` does not follow original Pyhthon implementation and is fully custom and optimized for JavaScript execution\n\nOriginal model is internally using Int64 values, but TFJS does not support Int64 so there are some overflows due to Int32 casting,  \nMost commonly around class 62, so that one is excluded from results  \n\nNote that `NanoDet-G` variation is about 4x faster in Browser execution using `WebGL` backend than `NanoDet-M` variation  \n\nFunction `processResults()` takes output of `model.execute` and returns array of objects:\n\n- id: internal number of detection box, used only for debugging\n- strideSize: internal size of the stride where object was detected, used only for debugging\n- score: value 0..1\n- class: coco class number\n- label: coco label as string\n- box: detection box [x1, y1, x2, y2] normalized to input image dimensions\n- boxRaw: detection box [x1, y1, x2, y2] normalized to 0..1\n- center: center point of detected object [x, y] normalized to input image dimensions\n- centerRaw: center point of detected object [x, y] normalized to 0..1\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n## Example\n\n![Example Image](outputs/cars.jpg)\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n## Conversion Notes\n\nSource: \u003chttps://github.com/RangiLyu/nanodet\u003e  \n\n### Requirements:\n\n```shell\npip install torch onnx onnx-tf onnx-simplifier tensorflowjs\n```\n\n### Fixes:\n\n- Error during conversion: `pytorch_half_pixel`  \n  Edit `export.py` to `set opset_version=10` which forces onnx export to use older upscale instead of resize op\n\n### Conversion:\n\n- From PyTorch to ONNX to TensorFlow Saved model to TensorFlow/JS Graph model\n\n```shell\npython export.py --cfg_path config/nanodet-m-416.yml --model_path models/nanodet_m_416.pth --out_path models/nanodet_m_416.onnx\npython -m onnxsim models/nanodet_m_416.onnx models/nanodet_m_416-simplified.onnx\nonnx-tf convert --infile models/nanodet_m_416-simplified.onnx --outdir models/saved-m\ntensorflowjs_converter --input_format tf_saved_model --output_format tfjs_graph_model --strip_debug_ops=* --weight_shard_size_bytes 18388608 models/saved-m models/graph-m\n```\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n## Tests\n\n```shell\nnode nanodet.js car.jpg\n```\n\n```js\n2021-03-16 12:03:39 INFO:  detector version 0.0.1\n2021-03-16 12:03:39 INFO:  User: vlado Platform: linux Arch: x64 Node: v15.4.0\n2021-03-16 12:03:39 INFO:  Loaded model { modelPath: 'file://models/nanodet/nanodet.json', minScore: 0.15, iouThreshold: 0.1, maxResults: 10, scaleBox: 2.5 } tensors: 524 bytes: 3771112\n2021-03-16 12:03:39 INFO:  Loaded image: car.jpg inputShape: [ 2000, 1333, [length]: 2 ] outputShape: [ 1, 3, 416, 416, [length]: 4 ]\n2021-03-16 12:03:39 DATA:  Results: [\n  {\n    score: 0.7859958410263062,\n    strideSize: 1,\n    class: 3,\n    label: 'car',\n    center: [ 1000, 1076, [length]: 2 ],\n    centerRaw: [ 0.5, 0.8076923076923077, [length]: 2 ],\n    box: [ 375, 868, 1625, 1284, [length]: 4 ],\n    boxRaw: [ 0.1875, 0.6514423076923077, 0.8125, 0.9639423076923077, [length]: 4 ]\n  },\n  {\n    score: 0.20603930950164795,\n    strideSize: 1,\n    class: 26,\n    label: 'umbrella',\n    center: [ 1615, 358, [length]: 2 ],\n    centerRaw: [ 0.8076923076923077, 0.2692307692307692, [length]: 2 ],\n    box: [ 1302, -57, 1927, 983, [length]: 4 ],\n    boxRaw: [ 0.6514423076923077, -0.04326923076923078, 0.9639423076923077, 0.7379807692307692, [length]: 4 ]\n  },\n  {\n    score: 0.16496318578720093,\n    strideSize: 4,\n    class: 59,\n    label: 'potted plant',\n    center: [ 865, 858, [length]: 2 ],\n    centerRaw: [ 0.4326923076923077, 0.6442307692307693, [length]: 2 ],\n    box: [ 748, 754, 943, 910, [length]: 4 ],\n    boxRaw: [ 0.3740985576923077, 0.5661057692307693, 0.4717548076923077, 0.6832932692307693, [length]: 4 ]\n  },\n  {\n    score: 0.15522807836532593,\n    strideSize: 4,\n    class: 14,\n    label: 'bench',\n    center: [ 1557, 858, [length]: 2 ],\n    centerRaw: [ 0.7788461538461539, 0.6442307692307693, [length]: 2 ],\n    box: [ 1362, 832, 1753, 884, [length]: 4 ],\n    boxRaw: [ 0.6811899038461539, 0.6246995192307693, 0.8765024038461539, 0.6637620192307693, [length]: 4 ]\n  },\n]\n2021-03-16 12:03:39 STATE:  Created output image: car-nanodet.jpg]\n```\n\n\u003cbr\u003e\u003chr\u003e\u003cbr\u003e\n\n## Notes\n\n- BoxRaw and CenterRaw are normalized to range 0..1\n- Box and Center are normalized to input image size in pixels\n\nWhat's different about this model is that we get 3 different resultsets\nand need to check each as different strides pick up different sized objects\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladmandic%2Fnanodet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladmandic%2Fnanodet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladmandic%2Fnanodet/lists"}