informers 1.0.3 → 1.1.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 +4 -0
- data/README.md +123 -0
- data/lib/informers/configs.rb +10 -8
- data/lib/informers/model.rb +2 -9
- data/lib/informers/models.rb +997 -12
- data/lib/informers/pipelines.rb +768 -8
- data/lib/informers/processors.rb +796 -0
- data/lib/informers/tokenizers.rb +154 -4
- data/lib/informers/utils/core.rb +4 -0
- data/lib/informers/utils/generation.rb +294 -0
- data/lib/informers/utils/image.rb +116 -0
- data/lib/informers/utils/math.rb +73 -0
- data/lib/informers/utils/tensor.rb +46 -0
- data/lib/informers/version.rb +1 -1
- data/lib/informers.rb +3 -0
- metadata +8 -5
@@ -22,5 +22,51 @@ module Informers
|
|
22
22
|
row.map { |v| v / norm }
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
def self.stack(tensors, dim = 0)
|
27
|
+
tensors
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.ones_like(tensor)
|
31
|
+
if tensor[0].is_a?(Array)
|
32
|
+
return tensor.map { |v| ones_like(v) }
|
33
|
+
end
|
34
|
+
tensor.map { |_| 1 }
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.dims(tensor)
|
38
|
+
dims = []
|
39
|
+
while tensor.is_a?(Array)
|
40
|
+
dims << tensor.size
|
41
|
+
tensor = tensor[0]
|
42
|
+
end
|
43
|
+
dims
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.interpolate(input, shape, mode = "bilinear", align_corners = false)
|
47
|
+
out_height, out_width = shape
|
48
|
+
|
49
|
+
# Input image dimensions
|
50
|
+
in_channels = dims(input)[-3] || 1
|
51
|
+
in_height = dims(input)[-2]
|
52
|
+
in_width = dims(input)[-1]
|
53
|
+
|
54
|
+
output = interpolate_data(
|
55
|
+
input.flatten,
|
56
|
+
[in_channels, in_height, in_width],
|
57
|
+
[out_height, out_width],
|
58
|
+
mode,
|
59
|
+
align_corners
|
60
|
+
)
|
61
|
+
reshape(output, [in_channels, out_height, out_width])
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.reshape(arr, dims)
|
65
|
+
arr = arr.flatten
|
66
|
+
dims[1..-1].reverse.each do |dim|
|
67
|
+
arr = arr.each_slice(dim)
|
68
|
+
end
|
69
|
+
arr.to_a
|
70
|
+
end
|
25
71
|
end
|
26
72
|
end
|
data/lib/informers/version.rb
CHANGED
data/lib/informers.rb
CHANGED
@@ -11,13 +11,16 @@ require "uri"
|
|
11
11
|
|
12
12
|
# modules
|
13
13
|
require_relative "informers/utils/core"
|
14
|
+
require_relative "informers/utils/generation"
|
14
15
|
require_relative "informers/utils/hub"
|
16
|
+
require_relative "informers/utils/image"
|
15
17
|
require_relative "informers/utils/math"
|
16
18
|
require_relative "informers/utils/tensor"
|
17
19
|
require_relative "informers/configs"
|
18
20
|
require_relative "informers/env"
|
19
21
|
require_relative "informers/model"
|
20
22
|
require_relative "informers/models"
|
23
|
+
require_relative "informers/processors"
|
21
24
|
require_relative "informers/tokenizers"
|
22
25
|
require_relative "informers/version"
|
23
26
|
require_relative "informers/pipelines"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: informers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.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: 2024-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: onnxruntime
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5.
|
33
|
+
version: 0.5.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.5.
|
40
|
+
version: 0.5.3
|
41
41
|
description:
|
42
42
|
email: andrew@ankane.org
|
43
43
|
executables: []
|
@@ -53,9 +53,12 @@ files:
|
|
53
53
|
- lib/informers/model.rb
|
54
54
|
- lib/informers/models.rb
|
55
55
|
- lib/informers/pipelines.rb
|
56
|
+
- lib/informers/processors.rb
|
56
57
|
- lib/informers/tokenizers.rb
|
57
58
|
- lib/informers/utils/core.rb
|
59
|
+
- lib/informers/utils/generation.rb
|
58
60
|
- lib/informers/utils/hub.rb
|
61
|
+
- lib/informers/utils/image.rb
|
59
62
|
- lib/informers/utils/math.rb
|
60
63
|
- lib/informers/utils/tensor.rb
|
61
64
|
- lib/informers/version.rb
|
@@ -78,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
81
|
- !ruby/object:Gem::Version
|
79
82
|
version: '0'
|
80
83
|
requirements: []
|
81
|
-
rubygems_version: 3.5.
|
84
|
+
rubygems_version: 3.5.16
|
82
85
|
signing_key:
|
83
86
|
specification_version: 4
|
84
87
|
summary: Fast transformer inference for Ruby
|