{"id":29017928,"url":"https://github.com/akarazniewicz/smd","last_synced_at":"2025-06-25T23:08:37.653Z","repository":{"id":53521985,"uuid":"216019397","full_name":"akarazniewicz/smd","owner":"akarazniewicz","description":"Simple mmdetection CPU inference","archived":false,"fork":false,"pushed_at":"2021-03-26T08:05:48.000Z","size":3666,"stargazers_count":28,"open_issues_count":8,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-02-28T18:51:21.251Z","etag":null,"topics":["computer-vision","deeplearning","faster-rcnn","machine-learning","mask-rcnn","object-detection","pytorch","retinanet"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akarazniewicz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-18T12:30:05.000Z","updated_at":"2023-01-12T03:50:57.000Z","dependencies_parsed_at":"2022-09-09T05:40:46.399Z","dependency_job_id":null,"html_url":"https://github.com/akarazniewicz/smd","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/akarazniewicz/smd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazniewicz%2Fsmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazniewicz%2Fsmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazniewicz%2Fsmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazniewicz%2Fsmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akarazniewicz","download_url":"https://codeload.github.com/akarazniewicz/smd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akarazniewicz%2Fsmd/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261967134,"owners_count":23237665,"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":["computer-vision","deeplearning","faster-rcnn","machine-learning","mask-rcnn","object-detection","pytorch","retinanet"],"created_at":"2025-06-25T23:08:33.018Z","updated_at":"2025-06-25T23:08:37.642Z","avatar_url":"https://github.com/akarazniewicz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Simple mmdetection \n\nOverall goal of this project is to implement most popular, inference only, CPU friendly object detection models from [mmdetection framework](https://github.com/open-mmlab/mmdetection) for research and production use. Currently mmdetection does not support CPU only inference mode ([see here](https://github.com/open-mmlab/mmdetection/issues/1274)), however in real life, production models are rarely deployed on GPU enabled environments. SMD solves this problem.\n\n### Goals\n\n* Create foundation for better understanding and research of CPU-only DNN performance\n* All mmdetection pretrained weights can be directly used with SMD ([mmedtecection model ZOO](https://github.com/open-mmlab/mmdetection/blob/master/docs/MODEL_ZOO.md)).\n* SMD limits number of dependencies to: torch, torchvision, PIL and numpy\n* Wherever possible mmdetection specific code is replaced with torch and torchvision alternatives (transforms, nms etc.)\n\n### Non-goals\n\n* By design this code has no training capabilities at all. Training specific code is either removed or reduced to the bare minimum. For training, finetuning or transfer learning use [mmdetection](https://github.com/open-mmlab/mmdetection) you can then just use trained model wit smd for CPU only inference.\n\n### Implemented architectures\n\n- [ ] TorchScript support (current priority)\n- [x] RetinaNet with FPN and ResNet 50 backbone\n- [x] RetinaNet with FPN and ResNet 101 backbone\n- [x] Faster R-CNN with FPN and ResNet 50 backbone\n- [x] Faster R-CNN with FPN and ResNet 101 backbone\n- [x] Mask R-CNN with FPN and ResNet 50 backbone\n- [x] Mask R-CNN with FPN and ResNet 101 backbone\n- [ ] RetinaNet with FPN and ResNet 50 with deformable convolutions backbone\n- [ ] RetinaNet with FPN and ResNet 101 with deformable convolutions backbone\n- [ ] SSD 300\n- [ ] SSD 512\n- [ ] FoveaBox\n\n### Installing\n\n`pip install -r requirements.txt`\n\n### Sample code\n\n[See demo jupyter notebook complete example](demo/demo.jpnby)\n\n```python\nfrom models.detectors import create_detector\nimport torch\nimport torchvision\nimport cv2\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\n# download pretrained mmdetection model from model zoo\ntorch.utils.model_zoo.load_url(\n    'https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection/models/retinanet_r101_fpn_1x_20181129-f016f384.pth',\n    model_dir='.')\n\n# create RetinaNet with ResNet 101 backbone, and pretrained COCO weights\n# Note: COCO has 80 classes plus one background class. You can use Your own model. Just set You number of classes and feed\n# pretrained checkpoint.\nretina = create_detector('retinanet_r101_fpn', number_of_classes=81, pretrained='retinanet_r101_fpn_1x_20181129-f016f384.pth')\n\n# with pytorch 1.3, model can be easily quantized (better CPU performance, smaller footprint).\nretina = torch.quantization.quantize_dynamic(retina, dtype=torch.qint8)\n\n# inference result is exactly the same like in mmdetection\nwith torch.no_grad():\n    result = retina.detect('demo.jpg')\n\nres = []\n\n# Look for cars in COCO dataset, with threshold 0.3\nfor r in result[2]:\n    if r[-1] \u003e= .3:\n        res.append(r[:-1].astype(dtype=np.int).tolist())\n\nif len(res) \u003e 0:\n    im = cv2.imread('demo.jpg')\n    for r in res:\n        cv2.rectangle(im, (r[0], r[1]), (r[2], r[3]), (0, 255, 255), 3)\n        cv2.putText(im, \"Car\", (r[0]-3, r[1]-3), cv2.FONT_HERSHEY_PLAIN, 2, (0, 255, 255), 3)\n\nim = cv2.cvtColor(im, cv2.COLOR_RGB2BGR)\n\nplt.figure(figsize=(20,11))\nplt.axis(\"off\")\nplt.imshow(im)\n```\n\n![GitHub Logo](demo/result.jpg)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakarazniewicz%2Fsmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakarazniewicz%2Fsmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakarazniewicz%2Fsmd/lists"}