alessandro trinca tornidor commited on
Commit
dd85bba
·
1 Parent(s): 4913772

[refactor] use nh3 instead than bleach to prepare input_str

Browse files
Files changed (1) hide show
  1. app.py +27 -3
app.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  import re
4
  import sys
5
 
6
- import bleach
7
  import cv2
8
  import gradio as gr
9
  import numpy as np
@@ -206,7 +206,31 @@ Preprint Paper
206
  ## to be implemented
207
  def inference(input_str, input_image):
208
  ## filter out special chars
209
- input_str = bleach.clean(input_str)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
  print("input_str: ", input_str, "input_image: ", input_image)
212
 
@@ -328,4 +352,4 @@ demo = gr.Interface(
328
  )
329
 
330
  demo.queue()
331
- demo.launch()
 
3
  import re
4
  import sys
5
 
6
+ import nh3
7
  import cv2
8
  import gradio as gr
9
  import numpy as np
 
206
  ## to be implemented
207
  def inference(input_str, input_image):
208
  ## filter out special chars
209
+
210
+ input_str = nh3.clean(
211
+ input_str,
212
+ tags={
213
+ "a",
214
+ "abbr",
215
+ "acronym",
216
+ "b",
217
+ "blockquote",
218
+ "code",
219
+ "em",
220
+ "i",
221
+ "li",
222
+ "ol",
223
+ "strong",
224
+ "ul",
225
+ },
226
+ attributes={
227
+ "a": {"href", "title"},
228
+ "abbr": {"title"},
229
+ "acronym": {"title"},
230
+ },
231
+ url_schemes={"http", "https", "mailto"},
232
+ link_rel=None,
233
+ )
234
 
235
  print("input_str: ", input_str, "input_image: ", input_image)
236
 
 
352
  )
353
 
354
  demo.queue()
355
+ demo.launch()