File size: 1,163 Bytes
60249c6
3ac1768
60249c6
939d665
60249c6
cb3d26d
3ac1768
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys
import gradio as gr

#sys.path.append("./detr")
sys.path.append("./src")
from inference import TableExtractionPipeline

def image_classifier(inp):
    return {'cat': 0.3, 'dog': 0.7}

demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
demo.launch()

#def greet(name):
    #return "Hello " + name + "!!"
#
#iface = gr.Interface(fn=greet, inputs="text", outputs="text")
#iface.launch()
#
#from inference import TableExtractionPipeline
#
## Create inference pipeline
#pipe = TableExtractionPipeline(det_config_path='detection_config.json', det_model_path='../pubtables1m_detection_detr_r18.pth', det_device='cuda', str_config_path='structure_config.json', str_model_path='../pubtables1m_structure_detr_r18.pth', str_device='cuda')
#
## Recognize table(s) from image
#extracted_tables = pipe.recognize(img, tokens, out_objects=True, out_cells=True, out_html=True, out_csv=True)
#
## Select table (there could be more than one)
#extracted_table = extracted_tables[0]
#
## Get output in desired format
#objects = extracted_table['objects']
#cells = extracted_table['cells']
#csv = extracted_table['csv']
#html = extracted_table['html']