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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e769d6e2716a72256fc6f0360a429a5d61bc9df8ca9fd0182330303957e8bd65
4
- data.tar.gz: c1e52d021196b77db9d1ec7cd7be5a5ed41277c2a8c6a5ffd59f05782690ef43
3
+ metadata.gz: 658be49c788bf6f989b0bf082b83cdb7e422adebab0ba1a29a18d863677af9a5
4
+ data.tar.gz: 04f2edb3628a315f81cc25e1fc0a47d9de7d16c212f3d82908f18594be84f0c4
5
5
  SHA512:
6
- metadata.gz: a45a3566061ed0683d7d47ed52aec0fd1921a07d1b4ca2d798409e1b08931a1dd6065b6c8df9d49fa06c09d51b4f6d42e12621832aec04ec23a5ee84e916abaf
7
- data.tar.gz: 88e1669aa4ea9256ddf1c3b6bcfb6df93e313331b5de1b32c12b348c2e32f981f9333d3bad54f7577063c17361d0841e823e8d2cb67df3d8916a3527991a9cca
6
+ metadata.gz: c60559ac4527348565c900d7cb725f7dac58f97275842db04092c35b90b56a02d55d5a6444ee440ad96d4562cd929eb24cffd513f5c0f82b3cd7ea2e411054b2
7
+ data.tar.gz: 17cb226cfadbf29896ab3ec1cf3aeb96fd0ea15cd509e47f0cb996ade9aec63aeaffb7ef005ca23ed258f200f84c71303539cc34ebbda7b4a9caae75a8347443
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.1 (2026-06-29)
2
+
3
+ - Fixed download for CIFAR datasets
4
+
1
5
  ## 0.5.0 (2026-04-07)
2
6
 
3
7
  - Switched to `numo-narray-alt`
@@ -1,7 +1,7 @@
1
1
  module TorchVision
2
2
  module Datasets
3
3
  class CIFAR10 < VisionDataset
4
- # https://www.cs.toronto.edu/~kriz/cifar.html
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://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz"
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://www.cs.toronto.edu/~kriz/cifar.html
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://www.cs.toronto.edu/~kriz/cifar-100-binary.tar.gz"
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, Net::HTTPFatalError, Net::HTTPClientException => e
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
- temp_path = "#{Dir.tmpdir}/#{Time.now.to_f}" # TODO better name
33
-
34
- uri = URI(url)
35
-
36
- # Net::HTTP automatically adds Accept-Encoding for compression
37
- # of response bodies and automatically decompresses gzip
38
- # and deflateresponses unless a Range header was sent.
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", open_timeout: 3) do |http|
41
- request = Net::HTTP::Get.new(uri)
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
- unless check_integrity(temp_path, sha256)
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? { |v| v == 0 }
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
@@ -1,3 +1,3 @@
1
1
  module TorchVision
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/lib/torchvision.rb CHANGED
@@ -6,7 +6,7 @@ require "torch"
6
6
  # stdlib
7
7
  require "digest"
8
8
  require "fileutils"
9
- require "net/http"
9
+ require "open-uri"
10
10
  require "rubygems/package"
11
11
  require "tmpdir"
12
12
 
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.0
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.6
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: []