adjust image detect fields
This commit is contained in:
@@ -16,7 +16,12 @@ class TemplatesDetectFieldsController < ApplicationController
|
||||
page_number = params[:page].presence&.to_i
|
||||
|
||||
documents.each do |document|
|
||||
io = StringIO.new(document.download)
|
||||
io =
|
||||
if document.image?
|
||||
StringIO.new(document.preview_images.joins(:blob).find_by(blob: { filename: ['0.png', '0.jpg'] }).download)
|
||||
else
|
||||
StringIO.new(document.download)
|
||||
end
|
||||
|
||||
Templates::DetectFields.call(io, attachment: document, page_number:) do |(attachment_uuid, page, fields)|
|
||||
sse.write({ attachment_uuid:, page:, fields: })
|
||||
|
||||
@@ -77,7 +77,7 @@ module Templates
|
||||
split_page: false, aspect_ratio: false, padding: nil, page_number: nil)
|
||||
return [[], nil] if page_number && page_number != 0
|
||||
|
||||
image = ImageUtils.load_vips(io.read, content_type: attachment.content_type)
|
||||
image = ImageUtils.load_vips(io.read)
|
||||
|
||||
fields = inference.call(image, confidence:, nms:, nmm:, split_page:,
|
||||
temperature:, aspect_ratio:, padding:)
|
||||
|
||||
Reference in New Issue
Block a user