Spaces:
Runtime error
Runtime error
BilalSardar
commited on
Commit
·
7d4cb84
1
Parent(s):
2ec286a
Rename RemoveText.py to ap.py.py
Browse files- RemoveText.py → ap.py.py +10 -7
RemoveText.py → ap.py.py
RENAMED
@@ -1,12 +1,10 @@
|
|
1 |
|
2 |
-
|
3 |
from cv2 import threshold
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
import keras_ocr
|
6 |
import cv2
|
7 |
import math
|
8 |
import numpy as np
|
9 |
-
|
10 |
|
11 |
def midpoint(x1, y1, x2, y2):
|
12 |
x_mid = int((x1 + x2)/2)
|
@@ -62,9 +60,14 @@ def inpaint_text(img_path, pipeline):
|
|
62 |
# keras-ocr will automatically download pretrained
|
63 |
# weights for the detector and recognizer.
|
64 |
pipeline = keras_ocr.pipeline.Pipeline()
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
69 |
|
70 |
-
cv2.imwrite('text_removed_image.jpg', cv2.cvtColor(img_text_removed, cv2.COLOR_BGR2RGB))
|
|
|
1 |
|
|
|
2 |
from cv2 import threshold
|
|
|
3 |
import keras_ocr
|
4 |
import cv2
|
5 |
import math
|
6 |
import numpy as np
|
7 |
+
import gradio as gr
|
8 |
|
9 |
def midpoint(x1, y1, x2, y2):
|
10 |
x_mid = int((x1 + x2)/2)
|
|
|
60 |
# keras-ocr will automatically download pretrained
|
61 |
# weights for the detector and recognizer.
|
62 |
pipeline = keras_ocr.pipeline.Pipeline()
|
63 |
+
def RemoveText(image):
|
64 |
+
img_text_removed = inpaint_text(image, pipeline)
|
65 |
+
return cv2.cvtColor(img_text_removed, cv2.COLOR_BGR2RGB)
|
66 |
|
67 |
+
iface = gr.Interface(fn=ApplyChange,
|
68 |
+
inputs=gr.inputs.Image(label="Image to Remove Text From", type="numpy"),
|
69 |
+
outputs="image",
|
70 |
+
examples=[["1.jpg"]],
|
71 |
+
title="Remove Text for Image")
|
72 |
+
iface.launch(debug=True)
|
73 |
|
|