ArrcttacsrjksX commited on
Commit
3ee6e2d
·
verified ·
1 Parent(s): ee74ec2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
app.py CHANGED
@@ -1,25 +1,31 @@
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()
 
1
  import gradio as gr
2
  import subprocess
3
+ import os
4
 
5
  def convert_image_to_dxf(image_path, output_path, debug_output):
6
  try:
7
+ subprocess.run(["./SimpleImageToDxfHavePass", "--use-lines", f"--imagePath={image_path}", f"--outputPath={output_path}", f"--debug-output={debug_output}"], check=True)
8
+ return f"DXF file saved to: {output_path}", debug_output, output_path
9
  except subprocess.CalledProcessError as e:
10
+ return f"Error converting image to DXF: {e}", None, None
11
 
12
  def main():
13
+ with gr.Blocks(theme=gr.themes.Minimal()) as demo:
14
+ with gr.Tabs():
15
+ with gr.TabItem("Image to DXF"):
16
+ gr.Markdown("# SimpleImageToDxfHavePass")
17
+ with gr.Row():
18
+ image_input = gr.Image(label="Input Image")
19
+ dxf_output = gr.File(label="DXF Output")
20
+ with gr.Row():
21
+ debug_output = gr.Image(label="Debug Output")
22
+ dxf_preview = gr.HTML(label="DXF Preview")
23
+ convert_btn = gr.Button("Convert to DXF")
24
+ convert_btn.click(convert_image_to_dxf, inputs=[image_input, dxf_output, debug_output], outputs=[dxf_output, debug_output, dxf_preview])
25
+ with gr.TabItem("About"):
26
+ gr.Markdown("This Gradio app allows users to convert an image to a DXF file using the SimpleImageToDxfHavePass command-line tool.")
27
 
28
  demo.launch()
29
 
30
+ if __name__ == "__main=="__main__":
31
  main()