stability_sdk 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27bb9b00352e1cf979dedd17438a5dc2a3dae93ed0d74a747e30f297152e81a2
4
- data.tar.gz: c125901e07cc2f6d0704a423e2dad2541c3e31efbeb1ff69993f65bf804dcabb
3
+ metadata.gz: 0b45f00aa32974424860512f59fb3c1745b6c3b8b08f359e95ccd603f637642d
4
+ data.tar.gz: a67397bdc2b10b0bc49b7a508e3283c20fa4d7ea4ae4b4598b086b0ecc43b323
5
5
  SHA512:
6
- metadata.gz: 4b79d8290c5c958f10a00f103efe6959b8e1f408d8ca3393453afb0a7433eda250252edab93195a1dd7885b9a3860aeffccd27833289f38ea373ff3bf1a274f0
7
- data.tar.gz: 4481b59d12990bf00e5b716611dbd8055df7d4d262a4f1647ea2b217c9122cd790b671e76d51f1c082e83f2a0cebb1d62e2a80d7cb08f1ae96755db299a89dcb
6
+ metadata.gz: f2fe617756b1d720e1d3a5c63807a7dbde52b70df2eb7a3c11a2bde803245f0e00c25b29d0d1893359de2243d333cf82ce274e23e03f220dadcad1d6f661261c
7
+ data.tar.gz: e50e38e2260d9e376581c03555468273c4378dea33cefdce1fb3e00e0d32db8aa592a63ba0e87f9685d0c89cdbd95c75af5093fc3e724711d862727d346028ba
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
10
+ .DS_Store
data/exe/stability-client CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "optparse"
4
4
  require "mime/types"
5
+ require "fastimage"
5
6
  require "logger"
6
7
  require "stability_sdk"
7
8
 
@@ -42,6 +43,11 @@ raise StabilitySDK::InsufficientParameter, "api key is required" if !options.has
42
43
 
43
44
  raise StabilitySDK::InsufficientParameter, "init_image is required if mask_image is provided" if options.has_key?(:mask_image) && !options.has_key?(:init_image)
44
45
 
46
+ if options.has_key?(:init_image)
47
+ size = FastImage.size(options[:init_image])
48
+ raise StabilitySDK::InvalidParameter, "width and height of init_image must be a multiple of 64" if size[0] % 64 != 0 || size[1] % 64 != 0
49
+ end
50
+
45
51
  client = StabilitySDK::Client.new(api_key: options[:api_key])
46
52
 
47
53
  client.generate(prompt, options) do |answer|
@@ -42,6 +42,11 @@ module StabilitySDK
42
42
  def generate(prompt, options, &block)
43
43
  width = options.has_key?(:width) ? options[:width].to_i : DEFAULT_IMAGE_WIDTH
44
44
  height = options.has_key?(:height) ? options[:height].to_i : DEFAULT_IMAGE_HEIGHT
45
+
46
+ if width % 64 != 0 || height % 64 != 0
47
+ raise InvalidParameter, "width and height must be a multiple of 64"
48
+ end
49
+
45
50
  samples = options.has_key?(:num_samples) ? options[:num_samples].to_i : DEFAULT_SAMPLE_SIZE
46
51
  steps = options.has_key?(:steps) ? options[:steps].to_i : DEFAULT_STEPS
47
52
  seed = options.has_key?(:seed) ? [options[:seed].to_i] : [rand(4294967295)]
@@ -1,3 +1,3 @@
1
1
  module StabilitySDK
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.10"
3
3
  end
data/lib/stability_sdk.rb CHANGED
@@ -5,4 +5,5 @@ require "stability_sdk/cli"
5
5
  module StabilitySDK
6
6
  class Error < StandardError; end
7
7
  class InsufficientParameter < StandardError; end
8
+ class InvalidParameter < StandardError; end
8
9
  end
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency "grpc", ">= 1.41.1"
29
29
  spec.add_dependency "mime-types", ">= 3.0.0"
30
+ spec.add_dependency "fastimage", "~> 2.2", ">= 2.2.6"
30
31
  spec.add_development_dependency "grpc-tools"
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stability_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kosei Moriyama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2022-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -38,6 +38,26 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastimage
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.2'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.2.6
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '2.2'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.2.6
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: grpc-tools
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -65,7 +85,6 @@ files:
65
85
  - ".gitmodules"
66
86
  - ".travis.yml"
67
87
  - Gemfile
68
- - Gemfile.lock
69
88
  - LICENSE
70
89
  - README.md
71
90
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- stability_sdk (0.2.9)
5
- grpc (>= 1.41.1)
6
- mime-types (>= 3.0.0)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- google-protobuf (3.21.7)
12
- googleapis-common-protos-types (1.4.0)
13
- google-protobuf (~> 3.14)
14
- grpc (1.49.1)
15
- google-protobuf (~> 3.21)
16
- googleapis-common-protos-types (~> 1.0)
17
- grpc-tools (1.48.0)
18
- mime-types (3.4.1)
19
- mime-types-data (~> 3.2015)
20
- mime-types-data (3.2022.0105)
21
- minitest (5.16.3)
22
- rake (12.3.3)
23
-
24
- PLATFORMS
25
- arm64-darwin-20
26
- ruby
27
-
28
- DEPENDENCIES
29
- grpc-tools
30
- minitest (~> 5.0)
31
- rake (~> 12.0)
32
- stability_sdk!
33
-
34
- BUNDLED WITH
35
- 2.2.2