Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -203,10 +203,15 @@ def blur_im(img,bounds,target_lang,trans_lang):
|
|
203 |
w = int(p2[0]) - int(x)
|
204 |
h = int(p2[1]) - int(y)
|
205 |
draw = ImageDraw.Draw(im)
|
206 |
-
font_size=int(int(w)*0.
|
207 |
font = ImageFont.truetype("./fonts/unifont-15.0.01.ttf", int(font_size))
|
208 |
text = this(bound[1],target_lang,trans_lang)
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
210 |
else:
|
211 |
pass
|
212 |
return im
|
@@ -215,7 +220,7 @@ def draw_boxes(image, bounds, width=1):
|
|
215 |
draw = ImageDraw.Draw(image)
|
216 |
for bound in bounds:
|
217 |
if bound[2]>=0.3:
|
218 |
-
color = "
|
219 |
else:
|
220 |
color = "red"
|
221 |
p0, p1, p2, p3 = bound[0]
|
|
|
203 |
w = int(p2[0]) - int(x)
|
204 |
h = int(p2[1]) - int(y)
|
205 |
draw = ImageDraw.Draw(im)
|
206 |
+
font_size=int(int(w)*0.2)
|
207 |
font = ImageFont.truetype("./fonts/unifont-15.0.01.ttf", int(font_size))
|
208 |
text = this(bound[1],target_lang,trans_lang)
|
209 |
+
|
210 |
+
bw, bh = (w,h)
|
211 |
+
tw, th = draw.textsize(text)
|
212 |
+
draw.text(((bw-tw)/2,(bh-th)/2), text, font=font, fill="black")
|
213 |
+
|
214 |
+
#draw.text((x, y),text, font = font, fill=(0,0,0))
|
215 |
else:
|
216 |
pass
|
217 |
return im
|
|
|
220 |
draw = ImageDraw.Draw(image)
|
221 |
for bound in bounds:
|
222 |
if bound[2]>=0.3:
|
223 |
+
color = "blue"
|
224 |
else:
|
225 |
color = "red"
|
226 |
p0, p1, p2, p3 = bound[0]
|