Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,10 +15,10 @@ def ocr_image_doctr_cv2(image):
|
|
| 15 |
gray = cv2.cvtColor(img_cv, cv2.COLOR_BGR2GRAY)
|
| 16 |
_, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
|
| 17 |
|
| 18 |
-
# กลับเป็น PIL.Image
|
| 19 |
processed_pil = Image.fromarray(cv2.cvtColor(thresh, cv2.COLOR_GRAY2RGB))
|
| 20 |
|
| 21 |
-
# ✅
|
| 22 |
doc = DocumentFile.from_images([processed_pil])
|
| 23 |
result = predictor(doc)
|
| 24 |
|
|
|
|
| 15 |
gray = cv2.cvtColor(img_cv, cv2.COLOR_BGR2GRAY)
|
| 16 |
_, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
|
| 17 |
|
| 18 |
+
# แปลงกลับเป็น PIL.Image
|
| 19 |
processed_pil = Image.fromarray(cv2.cvtColor(thresh, cv2.COLOR_GRAY2RGB))
|
| 20 |
|
| 21 |
+
# ✅ ส่งเป็น list ของ PIL.Image เสมอ
|
| 22 |
doc = DocumentFile.from_images([processed_pil])
|
| 23 |
result = predictor(doc)
|
| 24 |
|