Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,11 @@ import numpy as np
|
|
5 |
from PIL import Image, ImageEnhance
|
6 |
from ultralytics import YOLO
|
7 |
|
8 |
-
|
9 |
model_path = "best.pt"
|
10 |
model = YOLO(model_path)
|
11 |
|
12 |
-
|
13 |
def preprocessing(image):
|
14 |
"""Apply three enhancement filters, including brightness reduction, and resize."""
|
15 |
image = Image.fromarray(np.array(image))
|
@@ -27,12 +27,12 @@ def preprocessing(image):
|
|
27 |
|
28 |
return image
|
29 |
|
30 |
-
|
31 |
def imageRotation(image):
|
32 |
"""Dummy function for image rotation."""
|
33 |
return image
|
34 |
|
35 |
-
|
36 |
def detect_document(image):
|
37 |
"""Detects front and back of the document using YOLO."""
|
38 |
image = np.array(image)
|
@@ -107,7 +107,7 @@ def predict(image):
|
|
107 |
"back": back_result
|
108 |
}
|
109 |
|
110 |
-
return
|
111 |
|
112 |
# ---------------- Gradio Interface ---------------- #
|
113 |
iface = gr.Interface(
|
|
|
5 |
from PIL import Image, ImageEnhance
|
6 |
from ultralytics import YOLO
|
7 |
|
8 |
+
|
9 |
model_path = "best.pt"
|
10 |
model = YOLO(model_path)
|
11 |
|
12 |
+
|
13 |
def preprocessing(image):
|
14 |
"""Apply three enhancement filters, including brightness reduction, and resize."""
|
15 |
image = Image.fromarray(np.array(image))
|
|
|
27 |
|
28 |
return image
|
29 |
|
30 |
+
|
31 |
def imageRotation(image):
|
32 |
"""Dummy function for image rotation."""
|
33 |
return image
|
34 |
|
35 |
+
|
36 |
def detect_document(image):
|
37 |
"""Detects front and back of the document using YOLO."""
|
38 |
image = np.array(image)
|
|
|
107 |
"back": back_result
|
108 |
}
|
109 |
|
110 |
+
return cropped_images, labels, api_results
|
111 |
|
112 |
# ---------------- Gradio Interface ---------------- #
|
113 |
iface = gr.Interface(
|