Spaces:
Runtime error
Runtime error
Commit
•
9240006
1
Parent(s):
44268fe
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,10 @@ import math
|
|
11 |
from numpy import asarray
|
12 |
import numpy as np
|
13 |
|
14 |
-
torch.hub.download_url_to_file('https://i.pinimg.com/
|
|
|
|
|
|
|
15 |
|
16 |
def midpoint(x1, y1, x2, y2):
|
17 |
x_mid = int((x1 + x2)/2)
|
@@ -21,9 +24,6 @@ def midpoint(x1, y1, x2, y2):
|
|
21 |
def draw_mask(img, bounds):
|
22 |
mask = np.zeros(img.shape[:2], dtype="uint8")
|
23 |
for bound in bounds:
|
24 |
-
boxes.append(count)
|
25 |
-
count = count + 1
|
26 |
-
box0, box1, box2, box3 = bound[0]
|
27 |
|
28 |
x0, y0 = box0
|
29 |
x1, y1 = box1
|
@@ -37,7 +37,7 @@ def draw_mask(img, bounds):
|
|
37 |
|
38 |
cv.line(mask, (x_mid0, y_mid0), (x_mid1, y_mi1), 255, thickness)
|
39 |
img = cv.inpaint(img, mask, 3, cv.INPAINT_TELEA)
|
40 |
-
return(img
|
41 |
|
42 |
def inference(img, lang):
|
43 |
if lang == "english":
|
@@ -60,11 +60,11 @@ def inference(img, lang):
|
|
60 |
|
61 |
return ['box.jpg', 'result.jpg', pd.DataFrame(bounds). iloc[: , 1:2]]
|
62 |
|
63 |
-
title = '
|
64 |
-
description = '
|
65 |
-
article = "<p style='text-align: center'><a href='https://www.jaided.ai/easyocr/'>Ready-to-use
|
66 |
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
67 |
-
examples = [['korean.jpg',"korean"]]
|
68 |
choices = [
|
69 |
"chinese",
|
70 |
"english",
|
|
|
11 |
from numpy import asarray
|
12 |
import numpy as np
|
13 |
|
14 |
+
torch.hub.download_url_to_file('https://i.pinimg.com/736x/93/d3/54/93d354497ea26d5dc181055b9356cf79.jpg', 'korean.jpg')
|
15 |
+
torch.hub.download_url_to_file('https://64.media.tumblr.com/1a5796817934a179664508693cae82d3/67c2ea7948c385cc-1b/s1280x1920/a70d4fcc0a5528de415b024db4ee6036da9c4c35.jpg', 'chinese.jpg')
|
16 |
+
torch.hub.download_url_to_file('https://digistatement.com/wp-content/uploads/2020/06/12a7c208-33bb-4a91-bfc2-1510a18499e9.jpg', 'japanese.jpg')
|
17 |
+
torch.hub.download_url_to_file('https://img.mghubcdn.com/file/imghub/moriarty-the-patriot/68/10.jpg', 'english.jpg')
|
18 |
|
19 |
def midpoint(x1, y1, x2, y2):
|
20 |
x_mid = int((x1 + x2)/2)
|
|
|
24 |
def draw_mask(img, bounds):
|
25 |
mask = np.zeros(img.shape[:2], dtype="uint8")
|
26 |
for bound in bounds:
|
|
|
|
|
|
|
27 |
|
28 |
x0, y0 = box0
|
29 |
x1, y1 = box1
|
|
|
37 |
|
38 |
cv.line(mask, (x_mid0, y_mid0), (x_mid1, y_mi1), 255, thickness)
|
39 |
img = cv.inpaint(img, mask, 3, cv.INPAINT_TELEA)
|
40 |
+
return(img)
|
41 |
|
42 |
def inference(img, lang):
|
43 |
if lang == "english":
|
|
|
60 |
|
61 |
return ['box.jpg', 'result.jpg', pd.DataFrame(bounds). iloc[: , 1:2]]
|
62 |
|
63 |
+
title = 'Manga Image Cleaner'
|
64 |
+
description = 'Image inpainting and text detection demo with the use of EasyOCR and CV2. To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to test the program.'
|
65 |
+
article = "<p style='text-align: center'><a href='https://www.jaided.ai/easyocr/'>Ready-to-use image inpainting with supported languages such as: Chinese, English, Japanese, and Korean</a> | <a href='https://github.com/JaidedAI/EasyOCR'>Github OCR Repo</a> | <a href='https://towardsdatascience.com/remove-text-from-images-using-cv2-and-keras-ocr-24e7612ae4f4'>CV2 Reference</a></p>"
|
66 |
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
67 |
+
examples = [['chinese.jpg',"chinese"], ['english.jpg',"english"], ['japanese.jpg',"japanese"], ['korean.jpg',"korean"]]
|
68 |
choices = [
|
69 |
"chinese",
|
70 |
"english",
|