Skip to content

Commit

Permalink
fix edge case for OCR
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonalaird committed Sep 9, 2024
1 parent 3df7748 commit 326c1a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vision_agent/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def ocr(image: np.ndarray) -> List[Dict[str, Any]]:

pil_image = Image.fromarray(image).convert("RGB")
image_size = pil_image.size[::-1]
if image_size[0] < 1 and image_size[1] < 1:
if image_size[0] < 1 or image_size[1] < 1:
return []
image_buffer = io.BytesIO()
pil_image.save(image_buffer, format="PNG")
Expand Down Expand Up @@ -1112,6 +1112,8 @@ def florence2_ocr(image: np.ndarray) -> List[Dict[str, Any]]:
"""

image_size = image.shape[:2]
if image_size[0] < 1 or image_size[1] < 1:
return []
image_b64 = convert_to_b64(image)
data = {
"image": image_b64,
Expand Down

0 comments on commit 326c1a3

Please sign in to comment.