Module: RubyLLM::Agents::ImageUpscaler::DSL
- Includes:
- Concerns::ImageOperationDSL
- Defined in:
- lib/ruby_llm/agents/image/upscaler/dsl.rb
Overview
DSL for configuring image upscalers
Provides class-level methods to configure model, scale factor, and other upscaling parameters.
Constant Summary collapse
- VALID_SCALES =
[2, 4, 8].freeze
Instance Method Summary collapse
-
#denoise_strength(value = nil) ⇒ Float
Set or get denoise strength.
-
#face_enhance(value = nil) ⇒ Boolean
Set or get face enhancement.
-
#scale(value = nil) ⇒ Integer
Set or get the upscale factor.
Methods included from Concerns::ImageOperationDSL
#cache_enabled?, #cache_for, #cache_ttl, #description, #model
Instance Method Details
#denoise_strength(value = nil) ⇒ Float
Set or get denoise strength
Controls how much noise reduction is applied. Higher values remove more noise but may lose detail.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ruby_llm/agents/image/upscaler/dsl.rb', line 64 def denoise_strength(value = nil) if value unless value.is_a?(Numeric) && value.between?(0.0, 1.0) raise ArgumentError, "Denoise strength must be between 0.0 and 1.0" end @denoise_strength = value.to_f else @denoise_strength || inherited_or_default(:denoise_strength, 0.5) end end |
#face_enhance(value = nil) ⇒ Boolean
Set or get face enhancement
When enabled, applies additional enhancement to detected faces. Uses models like GFPGAN for face restoration.
47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_llm/agents/image/upscaler/dsl.rb', line 47 def face_enhance(value = nil) if value.nil? result = @face_enhance result = inherited_or_default(:face_enhance, false) if result.nil? result else @face_enhance = value end end |
#scale(value = nil) ⇒ Integer
Set or get the upscale factor
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby_llm/agents/image/upscaler/dsl.rb', line 29 def scale(value = nil) if value unless VALID_SCALES.include?(value) raise ArgumentError, "Scale must be one of: #{VALID_SCALES.join(", ")}" end @scale = value else @scale || inherited_or_default(:scale, 4) end end |