Update mdr_pdf_parser.py
Browse files- mdr_pdf_parser.py +3 -3
mdr_pdf_parser.py
CHANGED
|
@@ -1577,7 +1577,7 @@ def mdr_get_rotated_crop(img, points):
|
|
| 1577 |
h = int(max(np.linalg.norm(pts[0] - pts[3]), np.linalg.norm(pts[1] - pts[2])))
|
| 1578 |
std = np.float32([[0, 0], [w, 0], [w, h], [0, h]])
|
| 1579 |
M = cv2.getPerspectiveTransform(pts, std)
|
| 1580 |
-
dst = cv2.warpPerspective(img, M, (w, h), borderMode=cv2.
|
| 1581 |
dh, dw = dst.shape[0:2]
|
| 1582 |
if dh > 0 and dw > 0 and dh * 1.0 / dw >= 1.5:
|
| 1583 |
dst = cv2.rotate(dst, cv2.ROTATE_90_CLOCKWISE)
|
|
@@ -2171,7 +2171,7 @@ class MDRLayoutReader:
|
|
| 2171 |
layoutreader_cache_dir = Path(self._model_path) # self._model_path is like "./mdr_models/layoutreader"
|
| 2172 |
mdr_ensure_directory(str(layoutreader_cache_dir)) # Ensure this specific directory exists
|
| 2173 |
|
| 2174 |
-
name = "
|
| 2175 |
|
| 2176 |
print(f"MDRLayoutReader: Attempting to load LayoutLMv3 model '{name}'. Cache dir: {layoutreader_cache_dir}")
|
| 2177 |
try:
|
|
@@ -2822,7 +2822,7 @@ class MDRExtractionEngine:
|
|
| 2822 |
ori_im_cv = cv2.cvtColor(np.array(image.convert("RGB")), cv2.COLOR_RGB2BGR)
|
| 2823 |
|
| 2824 |
gray_cv = cv2.cvtColor(ori_im_cv, cv2.COLOR_BGR2GRAY)
|
| 2825 |
-
clahe_obj = cv2.createCLAHE(clipLimit=
|
| 2826 |
enhanced_gray_cv = clahe_obj.apply(gray_cv)
|
| 2827 |
# Convert back to BGR for downstream components that might expect 3 channels
|
| 2828 |
# (even if they only use one, like the detector)
|
|
|
|
| 1577 |
h = int(max(np.linalg.norm(pts[0] - pts[3]), np.linalg.norm(pts[1] - pts[2])))
|
| 1578 |
std = np.float32([[0, 0], [w, 0], [w, h], [0, h]])
|
| 1579 |
M = cv2.getPerspectiveTransform(pts, std)
|
| 1580 |
+
dst = cv2.warpPerspective(img, M, (w, h), borderMode=cv2.BORDER_CONSTANT, borderValue=(128, 128, 128), flags=cv2.INTER_CUBIC)
|
| 1581 |
dh, dw = dst.shape[0:2]
|
| 1582 |
if dh > 0 and dw > 0 and dh * 1.0 / dw >= 1.5:
|
| 1583 |
dst = cv2.rotate(dst, cv2.ROTATE_90_CLOCKWISE)
|
|
|
|
| 2171 |
layoutreader_cache_dir = Path(self._model_path) # self._model_path is like "./mdr_models/layoutreader"
|
| 2172 |
mdr_ensure_directory(str(layoutreader_cache_dir)) # Ensure this specific directory exists
|
| 2173 |
|
| 2174 |
+
name = "lakshya-rawat/document-qa-model"
|
| 2175 |
|
| 2176 |
print(f"MDRLayoutReader: Attempting to load LayoutLMv3 model '{name}'. Cache dir: {layoutreader_cache_dir}")
|
| 2177 |
try:
|
|
|
|
| 2822 |
ori_im_cv = cv2.cvtColor(np.array(image.convert("RGB")), cv2.COLOR_RGB2BGR)
|
| 2823 |
|
| 2824 |
gray_cv = cv2.cvtColor(ori_im_cv, cv2.COLOR_BGR2GRAY)
|
| 2825 |
+
clahe_obj = cv2.createCLAHE(clipLimit=1.0, tileGridSize=(8, 8))
|
| 2826 |
enhanced_gray_cv = clahe_obj.apply(gray_cv)
|
| 2827 |
# Convert back to BGR for downstream components that might expect 3 channels
|
| 2828 |
# (even if they only use one, like the detector)
|