ArrcttacsrjksX commited on
Commit
6de8e20
·
verified ·
1 Parent(s): 3a147ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -37,7 +37,7 @@ def convert_image_to_dxf(image_file, output_folder=None):
37
  if not os.path.exists(output_path):
38
  return "Conversion failed: DXF file was not created.", None, None
39
 
40
- # Prepare folder structure for upload
41
  date_folder = f"{current_date}"
42
 
43
  hf_token = os.getenv("HF_TOKEN")
@@ -74,10 +74,11 @@ def convert_image_to_dxf(image_file, output_folder=None):
74
  )
75
  uploaded_files.append(uploaded_debug)
76
 
77
- # Generate download links for each uploaded file
78
  links = [f"https://huggingface.co/{uploaded_file.repo_url}/blob/main/{uploaded_file.path_in_repo}" for uploaded_file in uploaded_files]
79
 
80
- return f"Files uploaded successfully. Download links:\n" + "\n".join(links), debug_output_path, output_path
 
81
 
82
  except subprocess.CalledProcessError as e:
83
  error_msg = f"Error converting image to DXF: {e.stderr.decode('utf-8') if e.stderr else e}"
@@ -98,7 +99,7 @@ def main():
98
  # Outputs: Debug image and DXF file download link
99
  with gr.Row():
100
  debug_output = gr.Image(type="filepath", label="Debug Output Preview")
101
- dxf_output = gr.Textbox(label="DXF File Download Link", placeholder="The link will appear here")
102
 
103
  # Conversion button with event binding
104
  convert_btn = gr.Button("Convert to DXF")
 
37
  if not os.path.exists(output_path):
38
  return "Conversion failed: DXF file was not created.", None, None
39
 
40
+ # Prepare folder structure for upload (optional, if uploading to Hugging Face)
41
  date_folder = f"{current_date}"
42
 
43
  hf_token = os.getenv("HF_TOKEN")
 
74
  )
75
  uploaded_files.append(uploaded_debug)
76
 
77
+ # Generate download links for each uploaded file (optional)
78
  links = [f"https://huggingface.co/{uploaded_file.repo_url}/blob/main/{uploaded_file.path_in_repo}" for uploaded_file in uploaded_files]
79
 
80
+ # Return files directly for download in Gradio interface
81
+ return output_path, debug_output_path, links
82
 
83
  except subprocess.CalledProcessError as e:
84
  error_msg = f"Error converting image to DXF: {e.stderr.decode('utf-8') if e.stderr else e}"
 
99
  # Outputs: Debug image and DXF file download link
100
  with gr.Row():
101
  debug_output = gr.Image(type="filepath", label="Debug Output Preview")
102
+ dxf_output = gr.File(label="DXF File Download")
103
 
104
  # Conversion button with event binding
105
  convert_btn = gr.Button("Convert to DXF")