{"id":18474186,"url":"https://github.com/dneprdroid/deformconv2d-metal","last_synced_at":"2025-04-08T12:32:13.402Z","repository":{"id":241301075,"uuid":"805793733","full_name":"dneprDroid/DeformConv2d-Metal","owner":"dneprDroid","description":"CoreML custom layer (GPU-accelerated) and converter for torchvision.ops.deform_conv2d","archived":false,"fork":false,"pushed_at":"2025-02-01T20:02:22.000Z","size":37134,"stargazers_count":10,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-23T12:41:25.987Z","etag":null,"topics":["coreml","coremltools","gpu","ios","metal","pytorch","torch","torchvision"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/dneprDroid.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-25T13:27:23.000Z","updated_at":"2025-02-01T20:02:26.000Z","dependencies_parsed_at":"2025-02-01T20:23:33.015Z","dependency_job_id":"878cf467-a3fe-413b-a7d1-52a63995ee86","html_url":"https://github.com/dneprDroid/DeformConv2d-Metal","commit_stats":null,"previous_names":["dneprdroid/deformconv2d-metal"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dneprDroid%2FDeformConv2d-Metal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dneprDroid%2FDeformConv2d-Metal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dneprDroid%2FDeformConv2d-Metal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dneprDroid%2FDeformConv2d-Metal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dneprDroid","download_url":"https://codeload.github.com/dneprDroid/DeformConv2d-Metal/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247842735,"owners_count":21005339,"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":["coreml","coremltools","gpu","ios","metal","pytorch","torch","torchvision"],"created_at":"2024-11-06T10:28:25.528Z","updated_at":"2025-04-08T12:32:08.393Z","avatar_url":"https://github.com/dneprDroid.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeformConv2d-Metal\n\nCoreML custom layer (GPU-accelerated) and converter for [`torchvision.ops.deform_conv2d`](https://pytorch.org/vision/main/generated/torchvision.ops.deform_conv2d.html).\n\n\n## Demo \n\nConvert [the demo ml-model](converter/demo/convert.py) with `torchvision.ops.deform_conv2d` operation to CoreML format:\n\n``` bash \n# Run in the root dir:\n\npython3 -m converter.demo\n```\nIt'll save the ml-model and example input/output tensors to the `DemoApp/generated` directory \nso the demo app can validate the CoreML output results and compare them with the PyTorch output.\n\nThe converted ML-model contains custom layers:\n\n\n![Screenshot 2024-05-27 at 12 55 43](https://github.com/dneprDroid/DeformConv2d-Metal/assets/13742733/d9044a31-e598-4072-bab9-53c2e7da20a4)\n\n\n\n### iOS and macOS demo apps\nOpen `DemoApp/DemoApp.xcodeproj` in Xcode and run the demo app.\n\nThe `Test-iOS` target contains the demo for iOS.\n\nThe `Test-macOS` target contains the demo for macOS.\n\nIn `MLModelTestWorker` it loads the generated CoreML model and the example input tensor from the `DemoApp/generated` directory \nand compares the calculated CoreML output tensor with the PyTorch example output tensor from the `DemoApp/generated` directory:\n\n![Screenshot 2024-05-28 at 12 21 52](https://github.com/dneprDroid/DeformConv2d-Metal/assets/13742733/8905de5b-ab83-42e2-bf1e-0f28f9f6ca7c)\n\n\n \n\n### Custom layers\nCustom layers are located in [`DeformConv2dMetal/Sources/CustomOps`](DeformConv2dMetal/Sources/CustomOps).\n\n\n## Use in your project\n\n\nInstall this pip package and import it in your converter script:\n\n```bash \n\npip install git+https://github.com/dneprDroid/DeformConv2d-Metal.git\n\n```\n\n```python\nimport DeformConv2dConvert\n\n...\n\n# register op so CoreML Tools can find the converter function  \nDeformConv2dConvert.register_op()\n\n# and convert your model...\n...\n\n```\n\n**NOTE**: In the `coremltools.convert` function you need to set `convert_to=\"neuralnetwork\"`:\n\n```python\nmlmodel = coremltools.convert(\n    traced_model,\n    inputs=...,\n    outputs=...,\n    convert_to=\"neuralnetwork\"\n)\n```\n#### iOS/macOS app\n\nIn your iOS/macOS app add the SwiftPM package from this repository:\n\n```\nhttps://github.com/dneprDroid/DeformConv2d-Metal.git\n```\nCoreML should find and load the custom layers from the `DeformConv2dMetal` module automatically, so you don't need to do anything.  \n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdneprdroid%2Fdeformconv2d-metal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdneprdroid%2Fdeformconv2d-metal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdneprdroid%2Fdeformconv2d-metal/lists"}