Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -182,16 +182,7 @@ ocr_id = {
|
|
| 182 |
def blur_im(img,bounds,target_lang,trans_lang):
|
| 183 |
im = cv2.imread(img)
|
| 184 |
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
|
| 185 |
-
|
| 186 |
-
im_w = im.shape[1]
|
| 187 |
-
if im_w > im_h:
|
| 188 |
-
rato=im_h/im_w
|
| 189 |
-
im = cv2.resize(im, (1000,(int(1000*float(rato)))))
|
| 190 |
-
elif im_w < im_h:
|
| 191 |
-
rato=im_w/im_h
|
| 192 |
-
im = cv2.resize(im, (int(1000*float(rato)),1000))
|
| 193 |
-
elif im_w == im_h:
|
| 194 |
-
im = cv2.resize(im,(1000,1000))
|
| 195 |
for bound in bounds:
|
| 196 |
if bound[2]>=0.3:
|
| 197 |
p0, p1, p2, p3 = bound[0]
|
|
@@ -271,6 +262,16 @@ def detect(img, target_lang,trans_lang,target_lang2=None):
|
|
| 271 |
lang=[f"{ocr_id[target_lang]}"]
|
| 272 |
pass
|
| 273 |
#global bounds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
reader = easyocr.Reader(lang)
|
| 275 |
bounds = reader.readtext(img)
|
| 276 |
im = PIL.Image.open(img)
|
|
|
|
| 182 |
def blur_im(img,bounds,target_lang,trans_lang):
|
| 183 |
im = cv2.imread(img)
|
| 184 |
im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
|
| 185 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
for bound in bounds:
|
| 187 |
if bound[2]>=0.3:
|
| 188 |
p0, p1, p2, p3 = bound[0]
|
|
|
|
| 262 |
lang=[f"{ocr_id[target_lang]}"]
|
| 263 |
pass
|
| 264 |
#global bounds
|
| 265 |
+
im_h = img.shape[0]
|
| 266 |
+
im_w = img.shape[1]
|
| 267 |
+
if im_w > im_h:
|
| 268 |
+
rato=im_h/im_w
|
| 269 |
+
img = cv2.resize(img, (1000,(int(1000*float(rato)))))
|
| 270 |
+
elif im_w < im_h:
|
| 271 |
+
rato=im_w/im_h
|
| 272 |
+
img = cv2.resize(img, (int(1000*float(rato)),1000))
|
| 273 |
+
elif im_w == im_h:
|
| 274 |
+
img = cv2.resize(img,(1000,1000))
|
| 275 |
reader = easyocr.Reader(lang)
|
| 276 |
bounds = reader.readtext(img)
|
| 277 |
im = PIL.Image.open(img)
|