ArrcttacsrjksX commited on
Commit
38ed12e
·
verified ·
1 Parent(s): ab24a8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -5,7 +5,7 @@ import tempfile
5
  import datetime
6
  from huggingface_hub import upload_file
7
 
8
- def convert_image_to_dxf(image_file, output_folder=None):
9
  try:
10
  # Validate input image
11
  if image_file is None:
@@ -23,9 +23,19 @@ def convert_image_to_dxf(image_file, output_folder=None):
23
  output_path = os.path.join(output_folder, f"{current_date}_output.dxf")
24
  debug_output_path = os.path.join(output_folder, f"{current_date}_debug.png")
25
 
 
 
 
 
 
 
 
 
 
 
26
  # Execute conversion command
27
  result = subprocess.run(
28
- ["./SimpleImageToDxfHavePass", "--use-lines", f"--imagePath={image_path}", f"--outputPath={output_path}", f"--debug-output={debug_output_path}"],
29
  check=True,
30
  capture_output=True
31
  )
@@ -94,6 +104,9 @@ def main():
94
  image_input = gr.Image(type="filepath", label="Input Image (PNG/JPG)")
95
  output_folder = gr.Textbox(label="Output Folder (optional)", placeholder="Leave blank to use a temporary folder")
96
 
 
 
 
97
  # Outputs: Debug image and DXF file download link
98
  with gr.Row():
99
  debug_output = gr.Image(type="filepath", label="Debug Output Preview")
@@ -103,7 +116,7 @@ def main():
103
  convert_btn = gr.Button("Convert to DXF")
104
  convert_btn.click(
105
  convert_image_to_dxf,
106
- inputs=[image_input, output_folder],
107
  outputs=[dxf_output, debug_output, dxf_output]
108
  )
109
 
 
5
  import datetime
6
  from huggingface_hub import upload_file
7
 
8
+ def convert_image_to_dxf(image_file, output_folder=None, use_lines=False):
9
  try:
10
  # Validate input image
11
  if image_file is None:
 
23
  output_path = os.path.join(output_folder, f"{current_date}_output.dxf")
24
  debug_output_path = os.path.join(output_folder, f"{current_date}_debug.png")
25
 
26
+ # Prepare the command arguments
27
+ command_args = ["./SimpleImageToDxfHavePass"]
28
+
29
+ # Add --use-lines if the checkbox is checked
30
+ if use_lines:
31
+ command_args.append("--use-lines")
32
+
33
+ # Add other arguments
34
+ command_args.extend([f"--imagePath={image_path}", f"--outputPath={output_path}", f"--debug-output={debug_output_path}"])
35
+
36
  # Execute conversion command
37
  result = subprocess.run(
38
+ command_args,
39
  check=True,
40
  capture_output=True
41
  )
 
104
  image_input = gr.Image(type="filepath", label="Input Image (PNG/JPG)")
105
  output_folder = gr.Textbox(label="Output Folder (optional)", placeholder="Leave blank to use a temporary folder")
106
 
107
+ # Checkbox to decide whether to use --use-lines
108
+ use_lines_checkbox = gr.Checkbox(label="Use --use-lines for conversion", value=False) # Default is False
109
+
110
  # Outputs: Debug image and DXF file download link
111
  with gr.Row():
112
  debug_output = gr.Image(type="filepath", label="Debug Output Preview")
 
116
  convert_btn = gr.Button("Convert to DXF")
117
  convert_btn.click(
118
  convert_image_to_dxf,
119
+ inputs=[image_input, output_folder, use_lines_checkbox],
120
  outputs=[dxf_output, debug_output, dxf_output]
121
  )
122