Spaces:
Running
Running
ovi054
commited on
Commit
•
3f4cfaa
1
Parent(s):
daa7932
New Output Field
Browse files- .gitattributes +1 -0
- Util/Fonts/kalpurush.ttf +3 -0
- app.py +31 -4
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
*.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
*.data-00000-of-00001 filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.ttf filter=lfs diff=lfs merge=lfs -text
|
Util/Fonts/kalpurush.ttf
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:83613a03e53aad8337f2be9fb974409a23c1d99b3b4b494567ba9d156c492b01
|
3 |
+
size 314592
|
app.py
CHANGED
@@ -62,7 +62,10 @@ import cv2
|
|
62 |
# from myverify import verify
|
63 |
#from detect_frame import detect_frame
|
64 |
# import pathlib
|
65 |
-
|
|
|
|
|
|
|
66 |
|
67 |
#import more
|
68 |
import tensorflow as tf
|
@@ -528,7 +531,31 @@ def model_predict(word):
|
|
528 |
# os.makedirs(folderName)
|
529 |
# fileName = folderName+ "/" + time_now + ".png"
|
530 |
# cv2.imwrite(fileName,word)
|
531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
'''
|
533 |
output=''
|
534 |
for i in range(0,len(final)):
|
@@ -547,6 +574,6 @@ def model_predict(word):
|
|
547 |
import gradio as gr
|
548 |
|
549 |
|
550 |
-
demo = gr.Interface(fn=model_predict, inputs= "paint", outputs="text")
|
551 |
|
552 |
-
demo.launch()
|
|
|
62 |
# from myverify import verify
|
63 |
#from detect_frame import detect_frame
|
64 |
# import pathlib
|
65 |
+
HF_TOKEN = os.getenv('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')
|
66 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "ocr_flag")
|
67 |
+
from PIL import ImageFont, ImageDraw, Image
|
68 |
+
font = ImageFont.truetype("Util\Fonts\kalpurush.ttf", 35)
|
69 |
|
70 |
#import more
|
71 |
import tensorflow as tf
|
|
|
531 |
# os.makedirs(folderName)
|
532 |
# fileName = folderName+ "/" + time_now + ".png"
|
533 |
# cv2.imwrite(fileName,word)
|
534 |
+
pil_image = Image.fromarray(word)
|
535 |
+
#pil_image.convert("RGBA")
|
536 |
+
for i in range(0,15):
|
537 |
+
if mark[i]==0:
|
538 |
+
continue
|
539 |
+
x0=(detections['detection_boxes'][i][0])*row
|
540 |
+
y0=(detections['detection_boxes'][i][1])*col
|
541 |
+
x1=(detections['detection_boxes'][i][2])*row
|
542 |
+
y1=(detections['detection_boxes'][i][3])*col
|
543 |
+
pt1 = (y0,x0)
|
544 |
+
pt2 = (y1,x1)
|
545 |
+
# color = (0, 0, 255) # Red color in BGR format
|
546 |
+
# thickness = 2 # Border thickness in pixels
|
547 |
+
# word = cv2.rectangle(word, pt1, pt2, color, thickness)
|
548 |
+
draw = ImageDraw.Draw(pil_image,"RGBA")
|
549 |
+
curi=detections['detection_classes'][i]
|
550 |
+
classi=classes[curi]
|
551 |
+
shape = [(y0,x0), (y1, x1)]
|
552 |
+
draw.rectangle(shape,fill=(0, 100, 200, 127))
|
553 |
+
draw.rectangle(shape, outline=(0, 0, 0, 127), width=3)
|
554 |
+
bbox = draw.textbbox(pt1, classi, font=font)
|
555 |
+
draw.rectangle(bbox, fill=(200, 100, 0, 200))
|
556 |
+
draw.text(pt1, classi, font=font, fill=(0,0,0,255))
|
557 |
+
newWordImg = np.asarray(pil_image)
|
558 |
+
return newWordImg, output
|
559 |
'''
|
560 |
output=''
|
561 |
for i in range(0,len(final)):
|
|
|
574 |
import gradio as gr
|
575 |
|
576 |
|
577 |
+
demo = gr.Interface(fn=model_predict, inputs= "paint", outputs=["image","text"],allow_flagging="auto",flagging_callback=hf_writer)
|
578 |
|
579 |
+
demo.launch()
|