This Space is currently running without CUDA. " "TDATR needs ZeroGPU or another CUDA GPU hardware to run inference.
", "", None, ) image_path = _save_upload(image) runner = _get_runner(int(max_new_tokens), float(temperature), int(seed)) with _predict_lock: table_html, result, vis_path = runner.predict( image_path, int(max_new_tokens), float(temperature), int(seed), ) return table_html, json.dumps(result, ensure_ascii=False, indent=2), vis_path except gr.Error: raise except Exception: escaped = html.escape(traceback.format_exc()) return f"{escaped}", "", None
with gr.Blocks(title="TDATR") as demo:
gr.Markdown("# TDATR")
with gr.Row():
image_input = gr.Image(type="pil", label="Table image")
with gr.Column():
max_tokens = gr.Slider(256, 4096, value=2048, step=128, label="Max tokens")
temperature = gr.Slider(0.1, 1.0, value=0.5, step=0.1, label="Temperature")
seed = gr.Number(value=42, precision=0, label="Seed")
run_button = gr.Button("Run", variant="primary")
with gr.Row():
html_output = gr.HTML(label="HTML")
vis_output = gr.Image(type="filepath", label="Cell boxes")
json_output = gr.Code(language="json", label="Result JSON")
run_button.click(
fn=run_tdatr,
inputs=[image_input, max_tokens, temperature, seed],
outputs=[html_output, json_output, vis_output],
)
if __name__ == "__main__":
demo.queue(max_size=8).launch(show_error=True)