torchvision 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +10 -10
- data/lib/torchvision/datasets/dataset_folder.rb +2 -0
- data/lib/torchvision/datasets/fashion_mnist.rb +10 -4
- data/lib/torchvision/datasets/kmnist.rb +10 -4
- data/lib/torchvision/datasets/mnist.rb +23 -6
- data/lib/torchvision/datasets/vision_dataset.rb +2 -1
- data/lib/torchvision/models/resnet.rb +5 -5
- data/lib/torchvision/models/vgg.rb +2 -2
- data/lib/torchvision/version.rb +1 -1
- data/lib/torchvision.rb +41 -41
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d83605afd88b375cddc9a57fed3e1c6f7654bd9657623a54c99d4b1d8f0ecb5
|
4
|
+
data.tar.gz: '09bf57d203ac64aceab4d4cbe2f72de93087d5f588a17fa37ac80b93c34a371b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a890bdeaca6a26af1d245b1b60d4e228b066303393fa25b6c08d83f2253e99c662fba5050205156d6dc80382531cb2236bdbaceb591305c227f66e61a9e5fa7b
|
7
|
+
data.tar.gz: 6d31e7adfc560c1571f1a986dc9f60cab62e00659f582321d52cff731898864ec3e47dbe476a7314e6df9633941475502e412a08a87f270c7e21739b5280f776
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# TorchVision
|
1
|
+
# TorchVision Ruby
|
2
2
|
|
3
3
|
:fire: Computer vision datasets, transforms, and models for Ruby
|
4
4
|
|
5
|
-
[![Build Status](https://github.com/ankane/torchvision/workflows/build/badge.svg?branch=master)](https://github.com/ankane/torchvision/actions)
|
5
|
+
[![Build Status](https://github.com/ankane/torchvision-ruby/workflows/build/badge.svg?branch=master)](https://github.com/ankane/torchvision-ruby/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -15,17 +15,17 @@ brew install vips
|
|
15
15
|
Add this line to your application’s Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem
|
18
|
+
gem "torchvision"
|
19
19
|
```
|
20
20
|
|
21
21
|
## Getting Started
|
22
22
|
|
23
|
-
This library follows the [Python API](https://pytorch.org/
|
23
|
+
This library follows the [Python API](https://pytorch.org/vision/). Many methods and options are missing at the moment. PRs welcome!
|
24
24
|
|
25
25
|
## Examples
|
26
26
|
|
27
27
|
- [MNIST](https://github.com/ankane/torch.rb/tree/master/examples/mnist)
|
28
|
-
- [Transfer learning](https://github.com/ankane/torch.rb/tree/master/
|
28
|
+
- [Transfer learning](https://github.com/ankane/torch.rb/tree/master/tutorials/transfer_learning/README.md)
|
29
29
|
- [Generative adversarial networks](https://github.com/ankane/torch.rb/tree/master/examples/gan)
|
30
30
|
|
31
31
|
## Datasets
|
@@ -161,22 +161,22 @@ If you’re a dataset owner and wish to update any details or remove it from thi
|
|
161
161
|
|
162
162
|
## History
|
163
163
|
|
164
|
-
View the [changelog](https://github.com/ankane/torchvision/blob/master/CHANGELOG.md)
|
164
|
+
View the [changelog](https://github.com/ankane/torchvision-ruby/blob/master/CHANGELOG.md)
|
165
165
|
|
166
166
|
## Contributing
|
167
167
|
|
168
168
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
169
169
|
|
170
|
-
- [Report bugs](https://github.com/ankane/torchvision/issues)
|
171
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/torchvision/pulls)
|
170
|
+
- [Report bugs](https://github.com/ankane/torchvision-ruby/issues)
|
171
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/torchvision-ruby/pulls)
|
172
172
|
- Write, clarify, or fix documentation
|
173
173
|
- Suggest or add new features
|
174
174
|
|
175
175
|
To get started with development:
|
176
176
|
|
177
177
|
```sh
|
178
|
-
git clone https://github.com/ankane/torchvision.git
|
179
|
-
cd torchvision
|
178
|
+
git clone https://github.com/ankane/torchvision-ruby.git
|
179
|
+
cd torchvision-ruby
|
180
180
|
bundle install
|
181
181
|
bundle exec rake test
|
182
182
|
```
|
@@ -5,22 +5,28 @@ module TorchVision
|
|
5
5
|
|
6
6
|
private
|
7
7
|
|
8
|
+
def mirrors
|
9
|
+
[
|
10
|
+
"http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/"
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
8
14
|
def resources
|
9
15
|
[
|
10
16
|
{
|
11
|
-
|
17
|
+
filename: "train-images-idx3-ubyte.gz",
|
12
18
|
sha256: "3aede38d61863908ad78613f6a32ed271626dd12800ba2636569512369268a84"
|
13
19
|
},
|
14
20
|
{
|
15
|
-
|
21
|
+
filename: "train-labels-idx1-ubyte.gz",
|
16
22
|
sha256: "a04f17134ac03560a47e3764e11b92fc97de4d1bfaf8ba1a3aa29af54cc90845"
|
17
23
|
},
|
18
24
|
{
|
19
|
-
|
25
|
+
filename: "t10k-images-idx3-ubyte.gz",
|
20
26
|
sha256: "346e55b948d973a97e58d2351dde16a484bd415d4595297633bb08f03db6a073"
|
21
27
|
},
|
22
28
|
{
|
23
|
-
|
29
|
+
filename: "t10k-labels-idx1-ubyte.gz",
|
24
30
|
sha256: "67da17c76eaffca5446c3361aaab5c3cd6d1c2608764d35dfb1850b086bf8dd5"
|
25
31
|
}
|
26
32
|
]
|
@@ -5,22 +5,28 @@ module TorchVision
|
|
5
5
|
|
6
6
|
private
|
7
7
|
|
8
|
+
def mirrors
|
9
|
+
[
|
10
|
+
"http://codh.rois.ac.jp/kmnist/dataset/kmnist/"
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
8
14
|
def resources
|
9
15
|
[
|
10
16
|
{
|
11
|
-
|
17
|
+
filename: "train-images-idx3-ubyte.gz",
|
12
18
|
sha256: "51467d22d8cc72929e2a028a0428f2086b092bb31cfb79c69cc0a90ce135fde4"
|
13
19
|
},
|
14
20
|
{
|
15
|
-
|
21
|
+
filename: "train-labels-idx1-ubyte.gz",
|
16
22
|
sha256: "e38f9ebcd0f3ebcdec7fc8eabdcdaef93bb0df8ea12bee65224341c8183d8e17"
|
17
23
|
},
|
18
24
|
{
|
19
|
-
|
25
|
+
filename: "t10k-images-idx3-ubyte.gz",
|
20
26
|
sha256: "edd7a857845ad6bb1d0ba43fe7e794d164fe2dce499a1694695a792adfac43c5"
|
21
27
|
},
|
22
28
|
{
|
23
|
-
|
29
|
+
filename: "t10k-labels-idx1-ubyte.gz",
|
24
30
|
sha256: "20bb9a0ef54c7db3efc55a92eef5582c109615df22683c380526788f98e42a1c"
|
25
31
|
}
|
26
32
|
]
|
@@ -52,8 +52,18 @@ module TorchVision
|
|
52
52
|
FileUtils.mkdir_p(processed_folder)
|
53
53
|
|
54
54
|
resources.each do |resource|
|
55
|
-
|
56
|
-
|
55
|
+
success = false
|
56
|
+
mirrors.each do |mirror|
|
57
|
+
begin
|
58
|
+
url = "#{mirror}#{resource[:filename]}"
|
59
|
+
download_file(url, download_root: raw_folder, filename: resource[:filename], sha256: resource[:sha256])
|
60
|
+
success = true
|
61
|
+
break
|
62
|
+
rescue Net::HTTPFatalError => e
|
63
|
+
puts "Failed to download (trying next): #{e.message}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
raise Error, "Error downloading #{resource[:filename]}" unless success
|
57
67
|
end
|
58
68
|
|
59
69
|
puts "Processing..."
|
@@ -75,22 +85,29 @@ module TorchVision
|
|
75
85
|
|
76
86
|
private
|
77
87
|
|
88
|
+
def mirrors
|
89
|
+
[
|
90
|
+
"http://yann.lecun.com/exdb/mnist/",
|
91
|
+
"https://ossci-datasets.s3.amazonaws.com/mnist/"
|
92
|
+
]
|
93
|
+
end
|
94
|
+
|
78
95
|
def resources
|
79
96
|
[
|
80
97
|
{
|
81
|
-
|
98
|
+
filename: "train-images-idx3-ubyte.gz",
|
82
99
|
sha256: "440fcabf73cc546fa21475e81ea370265605f56be210a4024d2ca8f203523609"
|
83
100
|
},
|
84
101
|
{
|
85
|
-
|
102
|
+
filename: "train-labels-idx1-ubyte.gz",
|
86
103
|
sha256: "3552534a0a558bbed6aed32b30c495cca23d567ec52cac8be1a0730e8010255c"
|
87
104
|
},
|
88
105
|
{
|
89
|
-
|
106
|
+
filename: "t10k-images-idx3-ubyte.gz",
|
90
107
|
sha256: "8d422c7b0a1c1c79245a5bcf07fe86e33eeafee792b84584aec276f5a2dbc4e6"
|
91
108
|
},
|
92
109
|
{
|
93
|
-
|
110
|
+
filename: "t10k-labels-idx1-ubyte.gz",
|
94
111
|
sha256: "f7ae60f92e00ec6debd23a6088c31dbd2371eca3ffa0defaefb259924204aec6"
|
95
112
|
}
|
96
113
|
]
|
@@ -37,12 +37,13 @@ module TorchVision
|
|
37
37
|
# of response bodies and automatically decompresses gzip
|
38
38
|
# and deflateresponses unless a Range header was sent.
|
39
39
|
# https://ruby-doc.org/stdlib-2.6.4/libdoc/net/http/rdoc/Net/HTTP.html
|
40
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
40
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https", open_timeout: 3) do |http|
|
41
41
|
request = Net::HTTP::Get.new(uri)
|
42
42
|
|
43
43
|
puts "Downloading #{url}..."
|
44
44
|
File.open(temp_path, "wb") do |f|
|
45
45
|
http.request(request) do |response|
|
46
|
+
response.value # raise error if not success
|
46
47
|
response.read_body do |chunk|
|
47
48
|
f.write(chunk)
|
48
49
|
end
|
@@ -2,11 +2,11 @@ module TorchVision
|
|
2
2
|
module Models
|
3
3
|
class ResNet < Torch::NN::Module
|
4
4
|
MODEL_URLS = {
|
5
|
-
"resnet18" => "https://download.pytorch.org/models/resnet18-
|
6
|
-
"resnet34" => "https://download.pytorch.org/models/resnet34-
|
7
|
-
"resnet50" => "https://download.pytorch.org/models/resnet50-
|
8
|
-
"resnet101" => "https://download.pytorch.org/models/resnet101-
|
9
|
-
"resnet152" => "https://download.pytorch.org/models/resnet152-
|
5
|
+
"resnet18" => "https://download.pytorch.org/models/resnet18-f37072fd.pth",
|
6
|
+
"resnet34" => "https://download.pytorch.org/models/resnet34-b627a593.pth",
|
7
|
+
"resnet50" => "https://download.pytorch.org/models/resnet50-0676ba61.pth",
|
8
|
+
"resnet101" => "https://download.pytorch.org/models/resnet101-63fe2227.pth",
|
9
|
+
"resnet152" => "https://download.pytorch.org/models/resnet152-394f9c45.pth",
|
10
10
|
"resnext50_32x4d" => "https://download.pytorch.org/models/resnext50_32x4d-7cdf4587.pth",
|
11
11
|
"resnext101_32x8d" => "https://download.pytorch.org/models/resnext101_32x8d-8ba56ff5.pth",
|
12
12
|
"wide_resnet50_2" => "https://download.pytorch.org/models/wide_resnet50_2-95faca4d.pth",
|
@@ -2,8 +2,8 @@ module TorchVision
|
|
2
2
|
module Models
|
3
3
|
class VGG < Torch::NN::Module
|
4
4
|
MODEL_URLS = {
|
5
|
-
"vgg11" => "https://download.pytorch.org/models/vgg11-
|
6
|
-
"vgg13" => "https://download.pytorch.org/models/vgg13-
|
5
|
+
"vgg11" => "https://download.pytorch.org/models/vgg11-8a719046.pth",
|
6
|
+
"vgg13" => "https://download.pytorch.org/models/vgg13-19584684.pth",
|
7
7
|
"vgg16" => "https://download.pytorch.org/models/vgg16-397923af.pth",
|
8
8
|
"vgg19" => "https://download.pytorch.org/models/vgg19-dcbb9e9d.pth",
|
9
9
|
"vgg11_bn" => "https://download.pytorch.org/models/vgg11_bn-6002323d.pth",
|
data/lib/torchvision/version.rb
CHANGED
data/lib/torchvision.rb
CHANGED
@@ -11,53 +11,53 @@ require "rubygems/package"
|
|
11
11
|
require "tmpdir"
|
12
12
|
|
13
13
|
# modules
|
14
|
-
|
15
|
-
|
14
|
+
require_relative "torchvision/utils"
|
15
|
+
require_relative "torchvision/version"
|
16
16
|
|
17
17
|
# datasets
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
require_relative "torchvision/datasets/vision_dataset"
|
19
|
+
require_relative "torchvision/datasets/dataset_folder"
|
20
|
+
require_relative "torchvision/datasets/image_folder"
|
21
|
+
require_relative "torchvision/datasets/cifar10"
|
22
|
+
require_relative "torchvision/datasets/cifar100"
|
23
|
+
require_relative "torchvision/datasets/mnist"
|
24
|
+
require_relative "torchvision/datasets/fashion_mnist"
|
25
|
+
require_relative "torchvision/datasets/kmnist"
|
26
26
|
|
27
27
|
# models
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
28
|
+
require_relative "torchvision/models/alexnet"
|
29
|
+
require_relative "torchvision/models/basic_block"
|
30
|
+
require_relative "torchvision/models/bottleneck"
|
31
|
+
require_relative "torchvision/models/resnet"
|
32
|
+
require_relative "torchvision/models/resnet18"
|
33
|
+
require_relative "torchvision/models/resnet34"
|
34
|
+
require_relative "torchvision/models/resnet50"
|
35
|
+
require_relative "torchvision/models/resnet101"
|
36
|
+
require_relative "torchvision/models/resnet152"
|
37
|
+
require_relative "torchvision/models/resnext50_32x4d"
|
38
|
+
require_relative "torchvision/models/resnext101_32x8d"
|
39
|
+
require_relative "torchvision/models/vgg"
|
40
|
+
require_relative "torchvision/models/vgg11"
|
41
|
+
require_relative "torchvision/models/vgg11_bn"
|
42
|
+
require_relative "torchvision/models/vgg13"
|
43
|
+
require_relative "torchvision/models/vgg13_bn"
|
44
|
+
require_relative "torchvision/models/vgg16"
|
45
|
+
require_relative "torchvision/models/vgg16_bn"
|
46
|
+
require_relative "torchvision/models/vgg19"
|
47
|
+
require_relative "torchvision/models/vgg19_bn"
|
48
|
+
require_relative "torchvision/models/wide_resnet50_2"
|
49
|
+
require_relative "torchvision/models/wide_resnet101_2"
|
50
50
|
|
51
51
|
# transforms
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
require_relative "torchvision/transforms/center_crop"
|
53
|
+
require_relative "torchvision/transforms/compose"
|
54
|
+
require_relative "torchvision/transforms/functional"
|
55
|
+
require_relative "torchvision/transforms/normalize"
|
56
|
+
require_relative "torchvision/transforms/random_horizontal_flip"
|
57
|
+
require_relative "torchvision/transforms/random_resized_crop"
|
58
|
+
require_relative "torchvision/transforms/random_vertical_flip"
|
59
|
+
require_relative "torchvision/transforms/resize"
|
60
|
+
require_relative "torchvision/transforms/to_tensor"
|
61
61
|
|
62
62
|
module TorchVision
|
63
63
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torchvision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.11.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.11.1
|
55
55
|
description:
|
56
56
|
email: andrew@ankane.org
|
57
57
|
executables: []
|
@@ -103,7 +103,7 @@ files:
|
|
103
103
|
- lib/torchvision/transforms/to_tensor.rb
|
104
104
|
- lib/torchvision/utils.rb
|
105
105
|
- lib/torchvision/version.rb
|
106
|
-
homepage: https://github.com/ankane/torchvision
|
106
|
+
homepage: https://github.com/ankane/torchvision-ruby
|
107
107
|
licenses:
|
108
108
|
- BSD-3-Clause
|
109
109
|
metadata: {}
|
@@ -115,14 +115,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements:
|
116
116
|
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '2.
|
118
|
+
version: '2.7'
|
119
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.4.1
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Computer vision datasets, transforms, and models for Ruby
|