=begin #FastAPI #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 0.1.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 3.0.60 =end require 'date' module StableDiffusion class ExtrasBatchImagesRequest # Sets the resize mode: 0 to upscale by upscaling_resize amount, 1 to upscale up to upscaling_resize_h x upscaling_resize_w. attr_accessor :resize_mode # Should the backend return the generated image? attr_accessor :show_extras_results # Sets the visibility of GFPGAN, values should be between 0 and 1. attr_accessor :gfpgan_visibility # Sets the visibility of CodeFormer, values should be between 0 and 1. attr_accessor :codeformer_visibility # Sets the weight of CodeFormer, values should be between 0 and 1. attr_accessor :codeformer_weight # By how much to upscale the image, only used when resize_mode=0. attr_accessor :upscaling_resize # Target width for the upscaler to hit. Only used when resize_mode=1. attr_accessor :upscaling_resize_w # Target height for the upscaler to hit. Only used when resize_mode=1. attr_accessor :upscaling_resize_h # Should the upscaler crop the image to fit in the chosen size? attr_accessor :upscaling_crop # The name of the main upscaler to use, it has to be one of this list: None , Lanczos , Nearest , ESRGAN_4x , LDSR , R-ESRGAN 4x+ , R-ESRGAN 4x+ Anime6B , ScuNET GAN , ScuNET PSNR , SwinIR 4x attr_accessor :upscaler_1 # The name of the secondary upscaler to use, it has to be one of this list: None , Lanczos , Nearest , ESRGAN_4x , LDSR , R-ESRGAN 4x+ , R-ESRGAN 4x+ Anime6B , ScuNET GAN , ScuNET PSNR , SwinIR 4x attr_accessor :upscaler_2 # Sets the visibility of secondary upscaler, values should be between 0 and 1. attr_accessor :extras_upscaler_2_visibility # Should the upscaler run before restoring faces? attr_accessor :upscale_first # List of images to work on. Must be Base64 strings attr_accessor :image_list class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @allowable_values = allowable_values.map do |value| case datatype.to_s when /Integer/i value.to_i when /Float/i value.to_f else value end end end def valid?(value) !value || allowable_values.include?(value) end end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'resize_mode' => :'resize_mode', :'show_extras_results' => :'show_extras_results', :'gfpgan_visibility' => :'gfpgan_visibility', :'codeformer_visibility' => :'codeformer_visibility', :'codeformer_weight' => :'codeformer_weight', :'upscaling_resize' => :'upscaling_resize', :'upscaling_resize_w' => :'upscaling_resize_w', :'upscaling_resize_h' => :'upscaling_resize_h', :'upscaling_crop' => :'upscaling_crop', :'upscaler_1' => :'upscaler_1', :'upscaler_2' => :'upscaler_2', :'extras_upscaler_2_visibility' => :'extras_upscaler_2_visibility', :'upscale_first' => :'upscale_first', :'image_list' => :'imageList' } end # Attribute type mapping. def self.openapi_types { :'resize_mode' => :'Object', :'show_extras_results' => :'Object', :'gfpgan_visibility' => :'Object', :'codeformer_visibility' => :'Object', :'codeformer_weight' => :'Object', :'upscaling_resize' => :'Object', :'upscaling_resize_w' => :'Object', :'upscaling_resize_h' => :'Object', :'upscaling_crop' => :'Object', :'upscaler_1' => :'Object', :'upscaler_2' => :'Object', :'extras_upscaler_2_visibility' => :'Object', :'upscale_first' => :'Object', :'image_list' => :'Object' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ ]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `StableDiffusion::ExtrasBatchImagesRequest` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `StableDiffusion::ExtrasBatchImagesRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'resize_mode') self.resize_mode = attributes[:'resize_mode'] else self.resize_mode = 0 end if attributes.key?(:'show_extras_results') self.show_extras_results = attributes[:'show_extras_results'] else self.show_extras_results = true end if attributes.key?(:'gfpgan_visibility') self.gfpgan_visibility = attributes[:'gfpgan_visibility'] else self.gfpgan_visibility = 0 end if attributes.key?(:'codeformer_visibility') self.codeformer_visibility = attributes[:'codeformer_visibility'] else self.codeformer_visibility = 0 end if attributes.key?(:'codeformer_weight') self.codeformer_weight = attributes[:'codeformer_weight'] else self.codeformer_weight = 0 end if attributes.key?(:'upscaling_resize') self.upscaling_resize = attributes[:'upscaling_resize'] else self.upscaling_resize = 2 end if attributes.key?(:'upscaling_resize_w') self.upscaling_resize_w = attributes[:'upscaling_resize_w'] else self.upscaling_resize_w = 512 end if attributes.key?(:'upscaling_resize_h') self.upscaling_resize_h = attributes[:'upscaling_resize_h'] else self.upscaling_resize_h = 512 end if attributes.key?(:'upscaling_crop') self.upscaling_crop = attributes[:'upscaling_crop'] else self.upscaling_crop = true end if attributes.key?(:'upscaler_1') self.upscaler_1 = attributes[:'upscaler_1'] else self.upscaler_1 = 'None' end if attributes.key?(:'upscaler_2') self.upscaler_2 = attributes[:'upscaler_2'] else self.upscaler_2 = 'None' end if attributes.key?(:'extras_upscaler_2_visibility') self.extras_upscaler_2_visibility = attributes[:'extras_upscaler_2_visibility'] else self.extras_upscaler_2_visibility = 0 end if attributes.key?(:'upscale_first') self.upscale_first = attributes[:'upscale_first'] else self.upscale_first = false end if attributes.key?(:'image_list') if (value = attributes[:'image_list']).is_a?(Array) self.image_list = value end end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new if @image_list.nil? invalid_properties.push('invalid value for "image_list", image_list cannot be nil.') end invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? resize_mode_validator = EnumAttributeValidator.new('Object', [0, 1]) return false unless resize_mode_validator.valid?(@resize_mode) return false if @image_list.nil? true end # Custom attribute writer method checking allowed values (enum). # @param [Object] resize_mode Object to be assigned def resize_mode=(resize_mode) validator = EnumAttributeValidator.new('Object', [0, 1]) unless validator.valid?(resize_mode) fail ArgumentError, "invalid value for \"resize_mode\", must be one of #{validator.allowable_values}." end @resize_mode = resize_mode end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && resize_mode == o.resize_mode && show_extras_results == o.show_extras_results && gfpgan_visibility == o.gfpgan_visibility && codeformer_visibility == o.codeformer_visibility && codeformer_weight == o.codeformer_weight && upscaling_resize == o.upscaling_resize && upscaling_resize_w == o.upscaling_resize_w && upscaling_resize_h == o.upscaling_resize_h && upscaling_crop == o.upscaling_crop && upscaler_1 == o.upscaler_1 && upscaler_2 == o.upscaler_2 && extras_upscaler_2_visibility == o.extras_upscaler_2_visibility && upscale_first == o.upscale_first && image_list == o.image_list end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [resize_mode, show_extras_results, gfpgan_visibility, codeformer_visibility, codeformer_weight, upscaling_resize, upscaling_resize_w, upscaling_resize_h, upscaling_crop, upscaler_1, upscaler_2, extras_upscaler_2_visibility, upscale_first, image_list].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) new.build_from_hash(attributes) end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) end end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model StableDiffusion.const_get(type).build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end end end