Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -109,7 +109,7 @@ def test_error( images, x_mask):
|
|
109 |
while (ind<len(ss)-1):
|
110 |
k=(len(ss)-2)-ind
|
111 |
outstr=outstr+worddicts_r[int(ss[k])]
|
112 |
-
|
113 |
drawtext = ImageDraw.Draw(textimg)
|
114 |
drawtext.text((20, 20), outstr ,(0,0,0),font=font)
|
115 |
fig,axes=plt.subplots(2,1)
|
@@ -121,13 +121,13 @@ def test_error( images, x_mask):
|
|
121 |
axes[1].imshow(255-(255 * visualization), alpha=0.2)
|
122 |
plt.axis('off')
|
123 |
|
124 |
-
plt.savefig('
|
125 |
-
frames.append(Image.fromarray(cv2.imread('
|
126 |
ind=ind+1
|
127 |
-
|
128 |
-
frame_one.save("
|
129 |
-
gif_image="
|
130 |
-
return outstr
|
131 |
|
132 |
|
133 |
|
@@ -155,7 +155,7 @@ article = "<p style='text-align: center'></p>"
|
|
155 |
css = "#0 {object-fit: contain;} #1 {object-fit: contain;}"
|
156 |
inputs = gr.inputs.Image(label="Input Image")
|
157 |
|
158 |
-
demo = gr.Interface(fn=recognize_text,inputs=inputs,outputs=[gr.Textbox(label="Output")],title=title,
|
159 |
description=description,
|
160 |
article=article,allow_flagging='never')
|
161 |
|
|
|
109 |
while (ind<len(ss)-1):
|
110 |
k=(len(ss)-2)-ind
|
111 |
outstr=outstr+worddicts_r[int(ss[k])]
|
112 |
+
textimg = Image.new('RGB', (1400,100),(255,255,255))
|
113 |
drawtext = ImageDraw.Draw(textimg)
|
114 |
drawtext.text((20, 20), outstr ,(0,0,0),font=font)
|
115 |
fig,axes=plt.subplots(2,1)
|
|
|
121 |
axes[1].imshow(255-(255 * visualization), alpha=0.2)
|
122 |
plt.axis('off')
|
123 |
|
124 |
+
plt.savefig('res.png')
|
125 |
+
frames.append(Image.fromarray(cv2.imread('res.png'), 'RGB'))
|
126 |
ind=ind+1
|
127 |
+
frame_one = frames[0]
|
128 |
+
frame_one.save("vis.gif", format="GIF", append_images=frames,save_all=True, duration=300, loop=0)
|
129 |
+
gif_image="vis.gif"
|
130 |
+
return outstr,gif_image
|
131 |
|
132 |
|
133 |
|
|
|
155 |
css = "#0 {object-fit: contain;} #1 {object-fit: contain;}"
|
156 |
inputs = gr.inputs.Image(label="Input Image")
|
157 |
|
158 |
+
demo = gr.Interface(fn=recognize_text,inputs=inputs,outputs=[gr.Textbox(label="Output"), gr.Image(label="Attended Regions")],title=title,
|
159 |
description=description,
|
160 |
article=article,allow_flagging='never')
|
161 |
|