File size: 1,003 Bytes
6be5e70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import subprocess

def convert_image_to_dxf(image_path, output_path, debug_output):
    try:
        subprocess.run(["SimpleImageToDxfHavePass", "--use-lines", f"--imagePath={image_path}", f"--outputPath={output_path}", f"--debug-output={debug_output}"], check=True)
        return f"DXF file saved to: {output_path}", debug_output
    except subprocess.CalledProcessError as e:
        return f"Error converting image to DXF: {e}", None

def main():
    with gr.Blocks() as demo:
        gr.Markdown("# SimpleImageToDxfHavePass")
        with gr.Row():
            image_input = gr.Image(label="Input Image")
            dxf_output = gr.File(label="DXF Output")
        with gr.Row():
            debug_output = gr.Image(label="Debug Output")
        convert_btn = gr.Button("Convert to DXF")
        convert_btn.click(convert_image_to_dxf, inputs=[image_input, dxf_output, debug_output], outputs=[dxf_output, debug_output])

    demo.launch()

if __name__ == "__main__":
    main()