Class: StableDiffusionRuby::Backend::Modal
- Inherits:
-
Object
- Object
- StableDiffusionRuby::Backend::Modal
- Defined in:
- lib/stable_diffusion_ruby/backend/modal.rb
Constant Summary collapse
- LOCAL_ONLY_PARAMS =
Params that only make sense locally (stripped before sending to Modal)
%i[output_path output_dir].freeze
- ENDPOINT_SUFFIXES =
Maps commands to Modal endpoint suffixes (appended to subdomain, not path)
{ "outpaint_image" => "-outpaint", "inpaint_region" => "-inpaint", "generate_image" => "-generate" }.freeze
- OUTPUT_FILES =
Output files Modal will produce per command
{ "outpaint_image" => [ { upload_param: :output_upload_url, result_key: "output_path", filename: "output.png" } ], "inpaint_region" => [ { upload_param: :output_upload_url, result_key: "output_path", filename: "output.png" } ], "generate_image" => [ { upload_param: :output_upload_url, result_key: "output_path", filename: "output.png" } ] }.freeze
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command, params = {}) ⇒ Modal
constructor
A new instance of Modal.
Constructor Details
#initialize(command, params = {}) ⇒ Modal
Returns a new instance of Modal.
36 37 38 39 |
# File 'lib/stable_diffusion_ruby/backend/modal.rb', line 36 def initialize(command, params = {}) @command = command @params = params end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
34 35 36 |
# File 'lib/stable_diffusion_ruby/backend/modal.rb', line 34 def command @command end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
34 35 36 |
# File 'lib/stable_diffusion_ruby/backend/modal.rb', line 34 def params @params end |
Instance Method Details
#call ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/stable_diffusion_ruby/backend/modal.rb', line 41 def call validate_config! remote_params = upload_inputs create_output_targets(remote_params) result = post_to_modal(remote_params) download_outputs(result) ensure Storage::S3.delete(temp_keys) if temp_keys.any? end |