Spaces:
Build error
Build error
Upload processor/pipeline.py with huggingface_hub
Browse files- processor/pipeline.py +22 -0
processor/pipeline.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .bg_removal import remove_background_and_crop
|
| 2 |
+
from .upscale import upscale_image
|
| 3 |
+
from .redaction import redact_names
|
| 4 |
+
|
| 5 |
+
def run_card_pipeline(image_bytes: bytes):
|
| 6 |
+
"""
|
| 7 |
+
Executes the full image processing pipeline.
|
| 8 |
+
1. Background Removal & Tight Crop
|
| 9 |
+
2. AI Upscaling
|
| 10 |
+
3. OCR Redaction
|
| 11 |
+
Returns the final processed OpenCV BGR image.
|
| 12 |
+
"""
|
| 13 |
+
# 1. Background removal and tight crop
|
| 14 |
+
img = remove_background_and_crop(image_bytes)
|
| 15 |
+
|
| 16 |
+
# 2. Upscale image
|
| 17 |
+
img = upscale_image(img)
|
| 18 |
+
|
| 19 |
+
# 3. Redact Names (Disabled for now per user feedback)
|
| 20 |
+
# img = redact_names(img)
|
| 21 |
+
|
| 22 |
+
return img
|