{"id":21428301,"url":"https://github.com/mlverse/torchvisionlib","last_synced_at":"2025-07-14T10:31:51.518Z","repository":{"id":38080427,"uuid":"446549355","full_name":"mlverse/torchvisionlib","owner":"mlverse","description":"torchvision C++ library extensions","archived":false,"fork":false,"pushed_at":"2025-04-14T16:39:44.000Z","size":311,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-22T21:18:07.021Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlverse.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","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":"2022-01-10T19:06:29.000Z","updated_at":"2025-04-14T16:39:48.000Z","dependencies_parsed_at":"2024-11-22T22:12:41.219Z","dependency_job_id":"34db0399-d843-416c-be35-3cf3c2f5cc0e","html_url":"https://github.com/mlverse/torchvisionlib","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/mlverse/torchvisionlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorchvisionlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorchvisionlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorchvisionlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorchvisionlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlverse","download_url":"https://codeload.github.com/mlverse/torchvisionlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlverse%2Ftorchvisionlib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265280701,"owners_count":23739853,"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":[],"created_at":"2024-11-22T22:12:33.879Z","updated_at":"2025-07-14T10:31:46.912Z","avatar_url":"https://github.com/mlverse.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# torchvisionlib\n\n\u003c!-- badges: start --\u003e\n\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![R-CMD-check](https://github.com/mlverse/torchvisionlib/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mlverse/torchvisionlib/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/torchvisionlib)](https://CRAN.R-project.org/package=torchvisionlib)\n[![](https://cranlogs.r-pkg.org/badges/torchvisionlib)](https://cran.r-project.org/package=torchvisionlib)\n[![Discord](https://img.shields.io/discord/837019024499277855?logo=discord)](https://discord.com/invite/s3D5cKhBkx)\n\u003c!-- badges: end --\u003e\n\nThe goal of torchvisionlib is to provide access to C++ opeartions implemented in\n[torchvision](https://github.com/pytorch/vision). It provides plain R acesss to\nsome of those C++ operations but, most importantly it provides full support for \nJIT operators defined in [torchvision](https://github.com/pytorch/vision), allowing\nus to load 'scripted' object detection and image segmentation models.\n\n## Installation\n\ntorchvisionlib can be installed from CRAN with:\n\n```r\ninstall.packages(\"torchvisionlib\")\n```\n\nYou can also install the development version of torchvisionlib from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"mlverse/torchvisionlib\")\n```\n\n## Example\n\nSuppose that we want to load an image detection model implemented in torchvision.\nFirst, in Python, we can save JIT script and then save this model:\n\n```python\nimport torch\nimport torchvision\n\nmodel = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn(pretrained=True)\nmodel.eval()\n\njit_model = torch.jit.script(model)\ntorch.jit.save(jit_model, \"fasterrcnn_mobilenet_v3_large_320_fpn.pt\")\n```\n\nWe can then load this model in R. Simply loading torchvisionlib will register all\nJIT operators, and we can use `torch::jit_load()`.\n\n```{r include=FALSE}\nurl \u003c- \"https://storage.googleapis.com/torch-lantern-builds/testing-models/fasterrcnn_mobilenet_v3_large_320_fpn.pt\"\ndownload.file(url, destfile = \"fasterrcnn_mobilenet_v3_large_320_fpn.pt\", mode = \"wb\")\n```\n\n```{r}\nlibrary(torchvisionlib)\nmodel \u003c- torch::jit_load(\"fasterrcnn_mobilenet_v3_large_320_fpn.pt\")\nmodel\n```\n\nYou can then use this model to make preditions or even fine tuning.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlverse%2Ftorchvisionlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlverse%2Ftorchvisionlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlverse%2Ftorchvisionlib/lists"}