Tayaba171 commited on
Commit
eb29ff3
1 Parent(s): 34c2d11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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
- '''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,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('/content/gdrive/My Drive/CALText_Demo/res.png')
125
- frames.append(Image.fromarray(cv2.imread('/content/gdrive/My Drive/CALText_Demo/res.png'), 'RGB'))'''
126
  ind=ind+1
127
- '''frame_one = frames[0]
128
- frame_one.save("/content/gdrive/My Drive/CALText_Demo/'vis.gif", format="GIF", append_images=frames,save_all=True, duration=300, loop=0)
129
- gif_image="/content/gdrive/My Drive/CALText_Demo/'vis.gif"'''
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