stability_sdk 0.3.2 → 0.3.3

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: 4bfbab3c7b0c366f01681d5adf54193d9473741c8616d3417628011f87e60bea
4
- data.tar.gz: f30748cc3ddefc1250b286f695cf039d8297970ef8757720620b9cec9d60e0cc
3
+ metadata.gz: 1bb93f79d9c09847cc8ee382f92cdf019137dbaa8b4c762bd1e24de392551a0f
4
+ data.tar.gz: a06818c77b6d490dec40047cf08b6b17e5ca72e09d8319499781dab3ef77a820
5
5
  SHA512:
6
- metadata.gz: 7f1eab7a664df5a09cd7785f9636e7e7542b87ed3ce475ceb5dd40005ec6ddc2e246346e258225d2e6f04b3472f28a316c91a32b3aa3e069acf031df5db20b82
7
- data.tar.gz: c74dffd4dcbffb5d3211d6bc4762d76384badef93c85e33432c93bf7c3b4c1f0eab2b934c8af0f4065f791e1fd3204408cdc50a5c16037c3cc26b44ef6bc449e
6
+ metadata.gz: 7ce00a0dcd937cdf0dbeb83b54d1437b5d26912b7139a99d125171f1364d3a03a377bef54698a9371b7b5dd44d6ad432bccfd01de9b02c3b7def1b01fec726f5
7
+ data.tar.gz: 84aa5aa534045145c9a4d6160b42e5cc2cdc5b41559e0c7122739f4720a00b36d757da57bab9cbef1b7936250e1a427b91014fa05b316ea45a33ade836c70261
data/README.md CHANGED
@@ -50,13 +50,13 @@ Options:
50
50
  -H, --height=VAL height of image in pixel. default 512
51
51
  -W, --width=VAL width of image in pixel. default 512
52
52
  -C, --cfg_scale=VAL CFG scale factor. default 7.0
53
- -A, --sampler=VAL ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_lms. default k_lms
54
- -s, --steps=VAL number of steps. default 50
53
+ -A, --sampler=VAL ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_lms, k_dpmpp_2s_ancestral, k_dpmpp_2m, k_dpmpp_sde. default auto-select
54
+ -s, --steps=VAL number of steps. default auto-select
55
55
  -S, --seed=VAL random seed to use in integer
56
56
  -p, --prefix=VAL output prefixes for artifacts. default `generation`
57
57
  --no-store do not write out artifacts
58
- -n, --num_samples=VAL number of samples to generate
59
- -e, --engine=VAL engine to use for inference. default `stable-diffusion-v1`
58
+ -n, --num_samples=VAL number of samples to generate. default 1
59
+ -e, --engine=VAL engine to use for inference. default `stable-diffusion-v1-5`
60
60
  -i, --init_image=VAL path to init image
61
61
  -m, --mask_image=VAL path to mask image
62
62
  --start_schedule=VAL start schedule for init image (must be greater than 0, 1 is full strength text prompt, no trace of image). default 1.0
data/exe/stability-client CHANGED
@@ -21,8 +21,8 @@ opt.on("--api_key=VAL", "api key of DreamStudio account. You can also specify by
21
21
  opt.on("-H", "--height=VAL", Integer, "height of image in pixel. default 512") {|v| options[:height] = v }
22
22
  opt.on("-W", "--width=VAL", Integer, "width of image in pixel. default 512") {|v| options[:width] = v }
23
23
  opt.on("-C", "--cfg_scale=VAL", Float, "CFG scale factor. default 7.0") {|v| options[:cfg_scale] = v }
24
- opt.on("-A", "--sampler=VAL", String, "ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_lms. default k_lms") {|v| options[:sampler] = v }
25
- opt.on("-s", "--steps=VAL", Integer, "number of steps. default 50") {|v| options[:steps] = v }
24
+ opt.on("-A", "--sampler=VAL", String, "ddim, plms, k_euler, k_euler_ancestral, k_heun, k_dpm_2, k_dpm_2_ancestral, k_lms, k_dpmpp_2s_ancestral, k_dpmpp_2m, k_dpmpp_sde. default auto-select") {|v| options[:sampler] = v }
25
+ opt.on("-s", "--steps=VAL", Integer, "number of steps. default auto-select") {|v| options[:steps] = v }
26
26
  opt.on("-S", "--seed=VAL", Integer, "random seed to use in integer") {|v| options[:seed] = v }
27
27
  opt.on("-p", "--prefix=VAL", String, "output prefixes for artifacts. default `generation`") {|v| options[:prefix] = v }
28
28
  opt.on("--no-store", "do not write out artifacts") {|v| options[:no_store] = v }
@@ -37,6 +37,7 @@ opt.on("--guidance_cuts=VAL", Integer, "Number of cuts to use for guidance. defa
37
37
  opt.on("--guidance_strength=VAL", Float, "Strength of the guidance. We recommend values in range [0.0,1.0]. A good default is 0.25. default nil") {|v| options[:guidance_strength] = v }
38
38
  opt.on("--guidance_prompt=VAL", String, "Prompt to use for guidance, defaults to `YOUR_PROMPT_TEXT` argument (above) if not specified.") {|v| options[:guidance_prompt] = v }
39
39
  opt.on("--guidance_models=VAL", Array, "Models to use for guidance. default nil") {|v| options[:guidance_models] = v }
40
+ opt.on("-t", "--artifact_types=VAL", Array, "filter artifacts by type (ARTIFACT_IMAGE, ARTIFACT_TEXT, ARTIFACT_CLASSIFICATIONS, etc)") {|v| options[:artifact_types] = v }
40
41
  opt.on("-v", "--verbose") { logger.level = Logger::DEBUG }
41
42
  opt.parse!(ARGV)
42
43
 
data/lib/generation_pb.rb CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'google/protobuf'
5
5
 
6
+ require 'google/protobuf/struct_pb'
6
7
  require 'tensors_pb'
7
8
 
8
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
@@ -52,6 +53,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
52
53
  proto3_optional :downsampling_factor, :uint64, 4
53
54
  proto3_optional :cfg_scale, :float, 5
54
55
  proto3_optional :init_noise_scale, :float, 6
56
+ proto3_optional :step_noise_scale, :float, 7
55
57
  end
56
58
  add_message "gooseai.ConditionerParameters" do
57
59
  proto3_optional :vector_adjust_prior, :string, 1
@@ -114,6 +116,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
114
116
  repeated :parameters, :message, 7, "gooseai.StepParameter"
115
117
  proto3_optional :masked_area_init, :enum, 8, "gooseai.MaskedAreaInit"
116
118
  proto3_optional :weight_method, :enum, 9, "gooseai.WeightMethod"
119
+ proto3_optional :quantize, :bool, 10
117
120
  end
118
121
  add_message "gooseai.ClassifierConcept" do
119
122
  optional :concept, :string, 1
@@ -131,6 +134,49 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
131
134
  repeated :exceeds, :message, 2, "gooseai.ClassifierCategory"
132
135
  proto3_optional :realized_action, :enum, 3, "gooseai.Action"
133
136
  end
137
+ add_message "gooseai.InterpolateParameters" do
138
+ repeated :ratios, :float, 1
139
+ proto3_optional :mode, :enum, 2, "gooseai.InterpolateMode"
140
+ end
141
+ add_message "gooseai.TransformBlend" do
142
+ optional :amount, :float, 1
143
+ optional :target, :message, 2, "gooseai.Artifact"
144
+ end
145
+ add_message "gooseai.TransformColorAdjust" do
146
+ proto3_optional :brightness, :float, 1
147
+ proto3_optional :contrast, :float, 2
148
+ proto3_optional :hue, :float, 3
149
+ proto3_optional :saturation, :float, 4
150
+ proto3_optional :lightness, :float, 5
151
+ end
152
+ add_message "gooseai.TransformColorMatch" do
153
+ optional :color_mode, :enum, 1, "gooseai.ColorMatchMode"
154
+ optional :image, :message, 2, "gooseai.Artifact"
155
+ end
156
+ add_message "gooseai.TransformDepthCalc" do
157
+ proto3_optional :blend_weight, :float, 1
158
+ proto3_optional :blur_radius, :uint32, 2
159
+ proto3_optional :reverse, :bool, 3
160
+ end
161
+ add_message "gooseai.TransformMatrix" do
162
+ repeated :data, :float, 1
163
+ end
164
+ add_message "gooseai.TransformResample" do
165
+ optional :border_mode, :enum, 1, "gooseai.BorderMode"
166
+ optional :transform, :message, 2, "gooseai.TransformMatrix"
167
+ proto3_optional :prev_transform, :message, 3, "gooseai.TransformMatrix"
168
+ proto3_optional :depth_warp, :float, 4
169
+ proto3_optional :export_mask, :bool, 5
170
+ end
171
+ add_message "gooseai.TransformParameters" do
172
+ oneof :transform do
173
+ optional :blend, :message, 1, "gooseai.TransformBlend"
174
+ optional :color_adjust, :message, 2, "gooseai.TransformColorAdjust"
175
+ optional :color_match, :message, 3, "gooseai.TransformColorMatch"
176
+ optional :depth_calc, :message, 4, "gooseai.TransformDepthCalc"
177
+ optional :resample, :message, 5, "gooseai.TransformResample"
178
+ end
179
+ end
134
180
  add_message "gooseai.AssetParameters" do
135
181
  optional :action, :enum, 1, "gooseai.AssetAction"
136
182
  optional :project_id, :string, 2
@@ -156,10 +202,13 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
156
202
  optional :requested_type, :enum, 3, "gooseai.ArtifactType"
157
203
  repeated :prompt, :message, 4, "gooseai.Prompt"
158
204
  proto3_optional :conditioner, :message, 6, "gooseai.ConditionerParameters"
205
+ proto3_optional :extras, :message, 2047, "google.protobuf.Struct"
159
206
  oneof :params do
160
207
  optional :image, :message, 5, "gooseai.ImageParameters"
161
208
  optional :classifier, :message, 7, "gooseai.ClassifierParameters"
162
209
  optional :asset, :message, 8, "gooseai.AssetParameters"
210
+ optional :interpolate, :message, 11, "gooseai.InterpolateParameters"
211
+ optional :transform, :message, 12, "gooseai.TransformParameters"
163
212
  end
164
213
  end
165
214
  add_message "gooseai.OnStatus" do
@@ -194,6 +243,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
194
243
  value :ARTIFACT_MASK, 7
195
244
  value :ARTIFACT_LATENT, 8
196
245
  value :ARTIFACT_TENSOR, 9
246
+ value :ARTIFACT_DEPTH, 10
197
247
  end
198
248
  add_enum "gooseai.MaskedAreaInit" do
199
249
  value :MASKED_AREA_INIT_ZERO, 0
@@ -215,6 +265,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
215
265
  value :SAMPLER_K_LMS, 7
216
266
  value :SAMPLER_K_DPMPP_2S_ANCESTRAL, 8
217
267
  value :SAMPLER_K_DPMPP_2M, 9
268
+ value :SAMPLER_K_DPMPP_SDE, 10
218
269
  end
219
270
  add_enum "gooseai.Upscaler" do
220
271
  value :UPSCALER_RGB, 0
@@ -248,6 +299,23 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
248
299
  value :CLSFR_MODE_ZEROSHOT, 0
249
300
  value :CLSFR_MODE_MULTICLASS, 1
250
301
  end
302
+ add_enum "gooseai.InterpolateMode" do
303
+ value :INTERPOLATE_LINEAR, 0
304
+ value :INTERPOLATE_RIFE, 1
305
+ value :INTERPOLATE_VAE_LINEAR, 2
306
+ value :INTERPOLATE_VAE_SLERP, 3
307
+ end
308
+ add_enum "gooseai.BorderMode" do
309
+ value :BORDER_REFLECT, 0
310
+ value :BORDER_REPLICATE, 1
311
+ value :BORDER_WRAP, 2
312
+ value :BORDER_ZERO, 3
313
+ end
314
+ add_enum "gooseai.ColorMatchMode" do
315
+ value :COLOR_MATCH_HSV, 0
316
+ value :COLOR_MATCH_LAB, 1
317
+ value :COLOR_MATCH_RGB, 2
318
+ end
251
319
  add_enum "gooseai.AssetAction" do
252
320
  value :ASSET_PUT, 0
253
321
  value :ASSET_GET, 1
@@ -288,6 +356,14 @@ module Gooseai
288
356
  ClassifierConcept = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierConcept").msgclass
289
357
  ClassifierCategory = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierCategory").msgclass
290
358
  ClassifierParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierParameters").msgclass
359
+ InterpolateParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.InterpolateParameters").msgclass
360
+ TransformBlend = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformBlend").msgclass
361
+ TransformColorAdjust = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformColorAdjust").msgclass
362
+ TransformColorMatch = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformColorMatch").msgclass
363
+ TransformDepthCalc = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformDepthCalc").msgclass
364
+ TransformMatrix = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformMatrix").msgclass
365
+ TransformResample = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformResample").msgclass
366
+ TransformParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.TransformParameters").msgclass
291
367
  AssetParameters = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AssetParameters").msgclass
292
368
  AnswerMeta = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AnswerMeta").msgclass
293
369
  Answer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Answer").msgclass
@@ -305,6 +381,9 @@ module Gooseai
305
381
  ModelArchitecture = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ModelArchitecture").enummodule
306
382
  Action = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.Action").enummodule
307
383
  ClassifierMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ClassifierMode").enummodule
384
+ InterpolateMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.InterpolateMode").enummodule
385
+ BorderMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.BorderMode").enummodule
386
+ ColorMatchMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.ColorMatchMode").enummodule
308
387
  AssetAction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AssetAction").enummodule
309
388
  AssetUse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.AssetUse").enummodule
310
389
  StageAction = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("gooseai.StageAction").enummodule
@@ -4,12 +4,22 @@ module StabilitySDK
4
4
  logger.debug "received answer: #{answer}"
5
5
  return if options[:no_store]
6
6
 
7
+ allowed_artifact_types = []
8
+ if options.has_key?(:artifact_types)
9
+ allowed_artifact_types = options[:artifact_types].map(&:to_sym)
10
+ end
11
+
7
12
  answer.artifacts.each_with_index do |artifact, idx|
8
13
  filename_base = "#{options[:prefix] || "generation"}-#{answer.request_id}-#{answer.answer_id}-#{idx}"
9
14
 
10
15
  filename = ""
11
16
  contents = ""
12
17
 
18
+ if allowed_artifact_types.size > 0 && !allowed_artifact_types.include?(artifact.type)
19
+ logger.info "skipping #{artifact.type} due to artifact type filter"
20
+ next
21
+ end
22
+
13
23
  case artifact.type
14
24
  when :ARTIFACT_IMAGE
15
25
  ext = MIME::Types[artifact.mime].first.preferred_extension
@@ -8,10 +8,8 @@ module StabilitySDK
8
8
  DEFAULT_IMAGE_WIDTH = 512
9
9
  DEFAULT_IMAGE_HEIGHT = 512
10
10
  DEFAULT_SAMPLE_SIZE = 1
11
- DEFAULT_STEPS = 50
12
11
  DEFAULT_ENGINE_ID = "stable-diffusion-v1-5"
13
12
  DEFAULT_CFG_SCALE = 7.0
14
- DEFAULT_SAMPLER_ALGORITHM = Gooseai::DiffusionSampler::SAMPLER_K_LMS
15
13
  DEFAULT_START_SCHEDULE = 1.0
16
14
  DEFAULT_END_SCHEDULE = 0.01
17
15
 
@@ -24,6 +22,9 @@ module StabilitySDK
24
22
  "k_dpm_2": Gooseai::DiffusionSampler::SAMPLER_K_DPM_2,
25
23
  "k_dpm_2_ancestral": Gooseai::DiffusionSampler::SAMPLER_K_DPM_2_ANCESTRAL,
26
24
  "k_lms": Gooseai::DiffusionSampler::SAMPLER_K_LMS,
25
+ "k_dpmpp_2s_ancestral": Gooseai::DiffusionSampler::SAMPLER_K_DPMPP_2S_ANCESTRAL,
26
+ "k_dpmpp_2m": Gooseai::DiffusionSampler::SAMPLER_K_DPMPP_2M,
27
+ "k_dpmpp_sde": Gooseai::DiffusionSampler::SAMPLER_K_DPMPP_SDE,
27
28
  }
28
29
 
29
30
  def initialize(options={})
@@ -57,10 +58,10 @@ module StabilitySDK
57
58
  end
58
59
 
59
60
  samples = options.has_key?(:num_samples) ? options[:num_samples] : DEFAULT_SAMPLE_SIZE
60
- steps = options.has_key?(:steps) ? options[:steps] : DEFAULT_STEPS
61
+ steps = options.has_key?(:steps) ? options[:steps] : nil
61
62
  seed = options.has_key?(:seed) ? [options[:seed]] : [rand(4294967295)]
62
63
  transform = Gooseai::TransformType.new(
63
- diffusion: options.has_key?(:sampler) ? SAMPLER_ALGORITHMS[options[:sampler].to_sym] : DEFAULT_SAMPLER_ALGORITHM,
64
+ diffusion: options.has_key?(:sampler) ? SAMPLER_ALGORITHMS[options[:sampler].to_sym] : nil,
64
65
  )
65
66
  step_parameter = Gooseai::StepParameter.new(
66
67
  scaled_step: 0,
@@ -1,3 +1,3 @@
1
1
  module StabilitySDK
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  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.3.2
4
+ version: 0.3.3
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-12-02 00:00:00.000000000 Z
11
+ date: 2023-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.1.6
143
+ rubygems_version: 3.1.4
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Ruby client for interacting with stability.ai APIs (e.g. stable diffusion