breezedeus commited on
Commit
6df8db3
1 Parent(s): 2f5b9f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -27,6 +27,20 @@ def get_ocr_model():
27
  return CnOcr()
28
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  def main():
31
  st.sidebar.header('输出设置')
32
  char_reverse_ratio = st.sidebar.slider(
@@ -118,6 +132,8 @@ def main():
118
  )
119
  st.subheader('输出图片')
120
  st.image(out_img)
 
 
121
  st.markdown('**对输出图片进行OCR,结果如下(如果依旧出现敏感词,尝试重新生成图片):**')
122
  ocr_out = ocr.ocr(out_img)
123
  new_texts = [out['text'] for out in ocr_out]
 
27
  return CnOcr()
28
 
29
 
30
+ def save_image(img):
31
+ from io import BytesIO
32
+
33
+ buf = BytesIO()
34
+ img.save(buf, format="JPEG")
35
+ byte_im = buf.getvalue()
36
+ st.download_button(
37
+ label="下载图片",
38
+ data=byte_im,
39
+ file_name="antiOCR.jpeg",
40
+ mime="image/jpeg",
41
+ )
42
+
43
+
44
  def main():
45
  st.sidebar.header('输出设置')
46
  char_reverse_ratio = st.sidebar.slider(
 
132
  )
133
  st.subheader('输出图片')
134
  st.image(out_img)
135
+ save_image(out_img)
136
+
137
  st.markdown('**对输出图片进行OCR,结果如下(如果依旧出现敏感词,尝试重新生成图片):**')
138
  ocr_out = ocr.ocr(out_img)
139
  new_texts = [out['text'] for out in ocr_out]