torchvision 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/torchvision/datasets/cifar10.rb +2 -2
- data/lib/torchvision/datasets/cifar100.rb +2 -2
- data/lib/torchvision/datasets/mnist.rb +1 -1
- data/lib/torchvision/datasets/vision_dataset.rb +14 -23
- data/lib/torchvision/transforms/functional.rb +1 -1
- data/lib/torchvision/version.rb +1 -1
- data/lib/torchvision.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 658be49c788bf6f989b0bf082b83cdb7e422adebab0ba1a29a18d863677af9a5
|
|
4
|
+
data.tar.gz: 04f2edb3628a315f81cc25e1fc0a47d9de7d16c212f3d82908f18594be84f0c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c60559ac4527348565c900d7cb725f7dac58f97275842db04092c35b90b56a02d55d5a6444ee440ad96d4562cd929eb24cffd513f5c0f82b3cd7ea2e411054b2
|
|
7
|
+
data.tar.gz: 17cb226cfadbf29896ab3ec1cf3aeb96fd0ea15cd509e47f0cb996ade9aec63aeaffb7ef005ca23ed258f200f84c71303539cc34ebbda7b4a9caae75a8347443
|
data/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module TorchVision
|
|
2
2
|
module Datasets
|
|
3
3
|
class CIFAR10 < VisionDataset
|
|
4
|
-
# https://
|
|
4
|
+
# https://cave.cs.toronto.edu/kriz/cifar.html
|
|
5
5
|
|
|
6
6
|
def initialize(root, train: true, download: false, transform: nil, target_transform: nil)
|
|
7
7
|
super(root, transform: transform, target_transform: target_transform)
|
|
@@ -82,7 +82,7 @@ module TorchVision
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
def url
|
|
85
|
-
"https://
|
|
85
|
+
"https://cave.cs.toronto.edu/kriz/cifar-10-binary.tar.gz"
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
def filename
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module TorchVision
|
|
2
2
|
module Datasets
|
|
3
3
|
class CIFAR100 < CIFAR10
|
|
4
|
-
# https://
|
|
4
|
+
# https://cave.cs.toronto.edu/kriz/cifar.html
|
|
5
5
|
|
|
6
6
|
private
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ module TorchVision
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def url
|
|
13
|
-
"https://
|
|
13
|
+
"https://cave.cs.toronto.edu/kriz/cifar-100-binary.tar.gz"
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def filename
|
|
@@ -59,7 +59,7 @@ module TorchVision
|
|
|
59
59
|
download_file(url, download_root: raw_folder, filename: resource[:filename], sha256: resource[:sha256])
|
|
60
60
|
success = true
|
|
61
61
|
break
|
|
62
|
-
rescue Errno::ECONNREFUSED
|
|
62
|
+
rescue Errno::ECONNREFUSED => e
|
|
63
63
|
puts "Failed to download (trying next): #{e.message}"
|
|
64
64
|
end
|
|
65
65
|
end
|
|
@@ -29,34 +29,25 @@ module TorchVision
|
|
|
29
29
|
dest = File.join(download_root, filename)
|
|
30
30
|
return dest if File.exist?(dest)
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
puts "Downloading #{url}..."
|
|
44
|
-
File.open(temp_path, "wb") do |f|
|
|
45
|
-
http.request(request) do |response|
|
|
46
|
-
response.value # raise error if not success
|
|
47
|
-
response.read_body do |chunk|
|
|
48
|
-
f.write(chunk)
|
|
49
|
-
end
|
|
32
|
+
uri = URI.parse(url)
|
|
33
|
+
raise "Invalid URL" unless uri.is_a?(URI::HTTP) # includes https
|
|
34
|
+
|
|
35
|
+
uri.open(open_timeout: 3, redirect: false) do |download|
|
|
36
|
+
digest =
|
|
37
|
+
if download.respond_to?(:path)
|
|
38
|
+
download.flush
|
|
39
|
+
Digest::SHA256.file(download.path).hexdigest
|
|
40
|
+
else
|
|
41
|
+
Digest::SHA256.hexdigest(download.string)
|
|
50
42
|
end
|
|
43
|
+
|
|
44
|
+
if digest != sha256
|
|
45
|
+
raise Error, "Bad hash"
|
|
51
46
|
end
|
|
52
|
-
end
|
|
53
47
|
|
|
54
|
-
|
|
55
|
-
raise Error, "Bad hash"
|
|
48
|
+
IO.copy_stream(download, dest.to_str)
|
|
56
49
|
end
|
|
57
50
|
|
|
58
|
-
FileUtils.mv(temp_path, dest)
|
|
59
|
-
|
|
60
51
|
dest
|
|
61
52
|
end
|
|
62
53
|
|
|
@@ -19,7 +19,7 @@ module TorchVision
|
|
|
19
19
|
std = Torch.tensor(std, dtype: dtype, device: tensor.device)
|
|
20
20
|
|
|
21
21
|
# TODO
|
|
22
|
-
if std.to_a.any?
|
|
22
|
+
if std.to_a.any?(0)
|
|
23
23
|
raise ArgumentError, "std evaluated to zero after conversion to #{dtype}, leading to division by zero."
|
|
24
24
|
end
|
|
25
25
|
if mean.ndim == 1
|
data/lib/torchvision/version.rb
CHANGED
data/lib/torchvision.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: torchvision
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
119
|
- !ruby/object:Gem::Version
|
|
120
120
|
version: '0'
|
|
121
121
|
requirements: []
|
|
122
|
-
rubygems_version: 4.0.
|
|
122
|
+
rubygems_version: 4.0.14
|
|
123
123
|
specification_version: 4
|
|
124
124
|
summary: Computer vision datasets, transforms, and models for Ruby
|
|
125
125
|
test_files: []
|