Spaces:
Running
Running
ArrcttacsrjksX
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
def convert_image_to_dxf(image_path, output_path, debug_output):
|
5 |
+
try:
|
6 |
+
subprocess.run(["SimpleImageToDxfHavePass", "--use-lines", f"--imagePath={image_path}", f"--outputPath={output_path}", f"--debug-output={debug_output}"], check=True)
|
7 |
+
return f"DXF file saved to: {output_path}", debug_output
|
8 |
+
except subprocess.CalledProcessError as e:
|
9 |
+
return f"Error converting image to DXF: {e}", None
|
10 |
+
|
11 |
+
def main():
|
12 |
+
with gr.Blocks() as demo:
|
13 |
+
gr.Markdown("# SimpleImageToDxfHavePass")
|
14 |
+
with gr.Row():
|
15 |
+
image_input = gr.Image(label="Input Image")
|
16 |
+
dxf_output = gr.File(label="DXF Output")
|
17 |
+
with gr.Row():
|
18 |
+
debug_output = gr.Image(label="Debug Output")
|
19 |
+
convert_btn = gr.Button("Convert to DXF")
|
20 |
+
convert_btn.click(convert_image_to_dxf, inputs=[image_input, dxf_output, debug_output], outputs=[dxf_output, debug_output])
|
21 |
+
|
22 |
+
demo.launch()
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
main()
|