adjust inference
This commit is contained in:
@@ -60,7 +60,7 @@ module Templates
|
||||
|
||||
# rubocop:disable Metrics, Style
|
||||
def call(io, attachment: nil, confidence: 0.3, temperature: 1, inference: Templates::ImageToFields, nms: 0.1,
|
||||
split_page: false, aspect_ratio: true, padding: inference.model_v2? ? nil : 20, regexp_type: true, &)
|
||||
split_page: false, aspect_ratio: true, padding: 20, regexp_type: true, &)
|
||||
fields, head_node =
|
||||
if attachment&.image?
|
||||
process_image_attachment(io, attachment:, confidence:, nms:, split_page:, inference:,
|
||||
|
||||
@@ -122,7 +122,7 @@ module Templates
|
||||
pad_w = (resolution - new_width) / 2
|
||||
pad_h = (resolution - new_height) / 2
|
||||
|
||||
padded = image.embed(pad_w, pad_h, resolution, resolution, background: [0, 0, 0])
|
||||
padded = image.embed(pad_w, pad_h, resolution, resolution, background: [255, 255, 255])
|
||||
|
||||
padded /= 255.0
|
||||
|
||||
@@ -245,6 +245,8 @@ module Templates
|
||||
|
||||
left, top, trim_width, trim_height = image.find_trim(threshold: 10, background: [255, 255, 255])
|
||||
|
||||
trim_width = [trim_width, image.width * 0.7].max
|
||||
|
||||
padded_left = [left - padding, 0].max
|
||||
padded_top = [top - padding, 0].max
|
||||
padded_right = [left + trim_width + padding, image.width].min
|
||||
|
||||
Reference in New Issue
Block a user