Class: Kreuzberg::Config::PaddleOcr

Inherits:
Object
  • Object
show all
Defined in:
lib/kreuzberg/config.rb

Overview

PaddleOCR engine configuration

Examples:

Basic usage

paddle = PaddleOcr.new(language: 'en', cache_dir: '/tmp/paddle')

Advanced configuration

paddle = PaddleOcr.new(
  language: 'en',
  cache_dir: '/tmp/paddle',
  use_angle_cls: true,
  det_db_thresh: 0.3,
  rec_batch_num: 32
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language: nil, cache_dir: nil, use_angle_cls: nil, enable_table_detection: nil, det_db_thresh: nil, det_db_box_thresh: nil, det_db_unclip_ratio: nil, det_limit_side_len: nil, rec_batch_num: nil) ⇒ PaddleOcr

Returns a new instance of PaddleOcr.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/kreuzberg/config.rb', line 107

def initialize(
  language: nil,
  cache_dir: nil,
  use_angle_cls: nil,
  enable_table_detection: nil,
  det_db_thresh: nil,
  det_db_box_thresh: nil,
  det_db_unclip_ratio: nil,
  det_limit_side_len: nil,
  rec_batch_num: nil
)
  @language = language&.to_s
  @cache_dir = cache_dir&.to_s
  @use_angle_cls = boolean_or_nil(use_angle_cls)
  @enable_table_detection = boolean_or_nil(enable_table_detection)
  @det_db_thresh = det_db_thresh&.to_f
  @det_db_box_thresh = det_db_box_thresh&.to_f
  @det_db_unclip_ratio = det_db_unclip_ratio&.to_f
  @det_limit_side_len = det_limit_side_len&.to_i
  @rec_batch_num = rec_batch_num&.to_i
end

Instance Attribute Details

#cache_dirObject (readonly)

Returns the value of attribute cache_dir.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def cache_dir
  @cache_dir
end

#det_db_box_threshObject (readonly)

Returns the value of attribute det_db_box_thresh.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def det_db_box_thresh
  @det_db_box_thresh
end

#det_db_threshObject (readonly)

Returns the value of attribute det_db_thresh.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def det_db_thresh
  @det_db_thresh
end

#det_db_unclip_ratioObject (readonly)

Returns the value of attribute det_db_unclip_ratio.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def det_db_unclip_ratio
  @det_db_unclip_ratio
end

#det_limit_side_lenObject (readonly)

Returns the value of attribute det_limit_side_len.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def det_limit_side_len
  @det_limit_side_len
end

#enable_table_detectionObject (readonly)

Returns the value of attribute enable_table_detection.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def enable_table_detection
  @enable_table_detection
end

#languageObject (readonly)

Returns the value of attribute language.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def language
  @language
end

#rec_batch_numObject (readonly)

Returns the value of attribute rec_batch_num.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def rec_batch_num
  @rec_batch_num
end

#use_angle_clsObject (readonly)

Returns the value of attribute use_angle_cls.



103
104
105
# File 'lib/kreuzberg/config.rb', line 103

def use_angle_cls
  @use_angle_cls
end

Instance Method Details

#to_hObject



129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/kreuzberg/config.rb', line 129

def to_h
  {
    language: @language,
    cache_dir: @cache_dir,
    use_angle_cls: @use_angle_cls,
    enable_table_detection: @enable_table_detection,
    det_db_thresh: @det_db_thresh,
    det_db_box_thresh: @det_db_box_thresh,
    det_db_unclip_ratio: @det_db_unclip_ratio,
    det_limit_side_len: @det_limit_side_len,
    rec_batch_num: @rec_batch_num
  }.compact
end