nickgambirasi commited on
Commit
c211276
1 Parent(s): 1fb28c8

update app

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -38,25 +38,18 @@ def process_document(image):
38
  # postprocess
39
  sequence = processor.batch_decode(outputs.sequences)[0]
40
  sequence = sequence.replace(processor.tokenizer.eos_token, "").replace(processor.tokenizer.pad_token, "")
41
- sequence = re.sub(r"<.*?>", "", sequence, count=1).strip() # remove first task start token
42
 
43
- json = processor.token2json(sequence)
44
- json_flatten = list(dict(**json).values())
45
- out = ""
46
- for value in json_flatten:
47
- out += value + "\n"
48
-
49
- return {'output': out}
50
 
51
  demo = gradio.Interface(
52
  fn=process_document,
53
  inputs="image",
54
- outputs="json",
55
  title="Document Parsing Demo",
56
  description=None,
57
  article=None,
58
- enable_queue=True,
59
  examples=None,
60
  cache_examples=False)
61
 
62
- demo.launch()
 
38
  # postprocess
39
  sequence = processor.batch_decode(outputs.sequences)[0]
40
  sequence = sequence.replace(processor.tokenizer.eos_token, "").replace(processor.tokenizer.pad_token, "")
41
+ sequence = re.sub(r"<.*?>", "", sequence).strip() # remove first task start token
42
 
43
+ return sequence
 
 
 
 
 
 
44
 
45
  demo = gradio.Interface(
46
  fn=process_document,
47
  inputs="image",
48
+ outputs="string",
49
  title="Document Parsing Demo",
50
  description=None,
51
  article=None,
 
52
  examples=None,
53
  cache_examples=False)
54
 
55
+ demo.launch(enable_queue=True)