Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,6 +52,8 @@ def draw_boxes(image, bounds, color='yellow', width=2):
|
|
| 52 |
def inference(filepath, lang, labels):
|
| 53 |
img = cv2.imread(filepath)
|
| 54 |
width, height, _ = img.shape
|
|
|
|
|
|
|
| 55 |
reader = easyocr.Reader(lang)
|
| 56 |
bounds = reader.readtext(filepath)
|
| 57 |
new_bounds=[]
|
|
@@ -72,10 +74,6 @@ def inference(filepath, lang, labels):
|
|
| 72 |
max_y = max(tl[1], tr[1], br[1], bl[1])
|
| 73 |
max_y = min(height-1, max_y)
|
| 74 |
# crop the region of interest (ROI)
|
| 75 |
-
print(min_x)
|
| 76 |
-
print(min_y)
|
| 77 |
-
print(max_x)
|
| 78 |
-
print(max_y)
|
| 79 |
|
| 80 |
|
| 81 |
|
|
|
|
| 52 |
def inference(filepath, lang, labels):
|
| 53 |
img = cv2.imread(filepath)
|
| 54 |
width, height, _ = img.shape
|
| 55 |
+
if width>height:
|
| 56 |
+
height, width, _ = img.shape
|
| 57 |
reader = easyocr.Reader(lang)
|
| 58 |
bounds = reader.readtext(filepath)
|
| 59 |
new_bounds=[]
|
|
|
|
| 74 |
max_y = max(tl[1], tr[1], br[1], bl[1])
|
| 75 |
max_y = min(height-1, max_y)
|
| 76 |
# crop the region of interest (ROI)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
|
| 79 |
|