Spaces:
Sleeping
Sleeping
Download app/preprocess.py from vamsi1103/flask-ocr-api: direct link, hf CLI and curl.
- Browser
- Download file 352 Bytes
-
https://huggingface.co/spaces/vamsi1103/flask-ocr-api/resolve/main/app/preprocess.py
- Command line
-
hf download hf://spaces/vamsi1103/flask-ocr-api/app/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/spaces/vamsi1103/flask-ocr-api/resolve/main/app/preprocess.py
352 Bytes
| import cv2 | |
| import numpy as np | |
| def preprocess_image(image_np): | |
| # RapidOCR utilizes DBNet for differentiable binarization text detection. | |
| # We maintain color/grayscale channels and apply a gentle scaling to preserve edge clarity. | |
| image_np = cv2.resize(image_np, None, fx=1.5, fy=1.5, interpolation=cv2.INTER_CUBIC) | |
| return image_np |