Socket
Book a DemoInstallSign in
Socket

torchvision

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

torchvision

0.4.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

TorchVision Ruby

:fire: Computer vision datasets, transforms, and models for Ruby

Build Status

Installation

First, install libvips. For Homebrew, use:

brew install vips

Add this line to your application’s Gemfile:

gem "torchvision"

Getting Started

This library follows the Python API. Many methods and options are missing at the moment. PRs welcome!

Examples

Datasets

Load a dataset

TorchVision::Datasets::MNIST.new("./data", train: true, download: true)

Supported datasets are:

  • CIFAR10
  • CIFAR100
  • FashionMNIST
  • KMNIST
  • MNIST

Transforms

TorchVision::Transforms::Compose.new([
  TorchVision::Transforms::ToTensor.new,
  TorchVision::Transforms::Normalize.new([0.1307], [0.3081])
])

Supported transforms are:

  • CenterCrop
  • Compose
  • Normalize
  • RandomHorizontalFlip
  • RandomResizedCrop
  • RandomVerticalFlip
  • Resize
  • ToTensor

Models

AlexNet

TorchVision::Models::AlexNet.new

ResNet

TorchVision::Models::ResNet18.new
TorchVision::Models::ResNet34.new
TorchVision::Models::ResNet50.new
TorchVision::Models::ResNet101.new
TorchVision::Models::ResNet152.new

ResNeXt

TorchVision::Models::ResNext52_32x4d.new
TorchVision::Models::ResNext101_32x8d.new

VGG

TorchVision::Models::VGG11.new
TorchVision::Models::VGG11BN.new
TorchVision::Models::VGG13.new
TorchVision::Models::VGG13BN.new
TorchVision::Models::VGG16.new
TorchVision::Models::VGG16BN.new
TorchVision::Models::VGG19.new
TorchVision::Models::VGG19BN.new

Wide ResNet

TorchVision::Models::WideResNet52_2.new
TorchVision::Models::WideResNet101_2.new

Pretrained Models

You can download pretrained models with this script

pip install torchvision
python pretrained.py

And load them

net = TorchVision::Models::ResNet18.new
net.load_state_dict(Torch.load("net.pth"))

libvips Installation

Linux

Check your package manager. For Ubuntu, use:

sudo apt install libvips

You can also build from source.

Mac

brew install vips

Windows

Check out the options.

Disclaimer

This library downloads and prepares public datasets. We don’t host any datasets. Be sure to adhere to the license for each dataset.

If you’re a dataset owner and wish to update any details or remove it from this project, let us know.

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/torchvision-ruby.git
cd torchvision-ruby
bundle install
bundle exec rake test

FAQs

Package last updated on 07 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.