mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
refactor(ocr): update OCR schema and response structure to use individual coordinates instead of bounding box, and adjust related service and repository files
This commit is contained in:
parent
46ef02342d
commit
df36a09cd3
7 changed files with 66 additions and 34 deletions
|
|
@ -34,13 +34,17 @@ class PaddleOCRecognizer(InferenceModel):
|
|||
valid_texts_and_scores = [
|
||||
(text, score, box)
|
||||
for result in results
|
||||
for text, score, box in zip(result['rec_texts'], result['rec_scores'], result['rec_boxes'].tolist())
|
||||
for text, score, box in zip(result['rec_texts'], result['rec_scores'], result['rec_polys'])
|
||||
if score >= self.min_score
|
||||
]
|
||||
if not valid_texts_and_scores:
|
||||
return []
|
||||
|
||||
return [
|
||||
OCROutput(text=text, confidence=score, boundingBox={"x1": box[0], "y1": box[1], "x2": box[2], "y2": box[3]})
|
||||
OCROutput(
|
||||
text=text, confidence=score,
|
||||
x1=box[0][0], y1=box[0][1], x2=box[1][0], y2=box[1][1],
|
||||
x3=box[2][0], y3=box[2][1], x4=box[3][0], y4=box[3][1]
|
||||
)
|
||||
for text, score, box in valid_texts_and_scores
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue