ArrcttacsrjksX commited on
Commit
ed4a78a
·
verified ·
1 Parent(s): 18c4e00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -77,33 +77,23 @@ def convert_image_to_dxf(image_file, output_folder=None, use_lines=False):
77
  uploaded_files.append(uploaded_dxf)
78
 
79
  # If the checkbox is ticked, upload debug image
80
- debug_file = debug_output_path if use_lines else None
81
- if debug_file:
82
  uploaded_debug = upload_file(
83
- path_or_fileobj=debug_file,
84
- path_in_repo=f"datasets/ArrcttacsrjksX/ImageToAutocadData/{date_folder}/{os.path.basename(debug_file)}",
85
  repo_id="ArrcttacsrjksX/ImageToAutocadData",
86
  token=hf_token
87
  )
88
  uploaded_files.append(uploaded_debug)
89
 
90
  # Return files directly for download in Gradio interface
91
- return output_path, debug_file, uploaded_files
92
 
93
  except subprocess.CalledProcessError as e:
94
  error_msg = f"Error converting image to DXF: {e.stderr.decode('utf-8') if e.stderr else e}"
95
  return error_msg, None, None
96
 
97
  def main():
98
- # Ensure the SimpleImageToDxfHavePass has execute permissions
99
- if not os.access('./SimpleImageToDxfHavePass', os.X_OK):
100
- print("SimpleImageToDxfHavePass is not executable. Trying to set permissions.")
101
- try:
102
- subprocess.run(['chmod', '+x', './SimpleImageToDxfHavePass'], check=True)
103
- except subprocess.CalledProcessError as e:
104
- print(f"Error setting permissions: {e}")
105
- exit(1)
106
-
107
  with gr.Blocks() as demo:
108
  with gr.Tabs():
109
  # Tab for conversion
@@ -138,5 +128,9 @@ def main():
138
  demo.launch(share=True)
139
 
140
  if __name__ == "__main__":
141
- # Execute the main function
 
 
 
 
142
  main()
 
77
  uploaded_files.append(uploaded_dxf)
78
 
79
  # If the checkbox is ticked, upload debug image
80
+ if use_lines:
 
81
  uploaded_debug = upload_file(
82
+ path_or_fileobj=debug_output_path,
83
+ path_in_repo=f"datasets/ArrcttacsrjksX/ImageToAutocadData/{date_folder}/{os.path.basename(debug_output_path)}",
84
  repo_id="ArrcttacsrjksX/ImageToAutocadData",
85
  token=hf_token
86
  )
87
  uploaded_files.append(uploaded_debug)
88
 
89
  # Return files directly for download in Gradio interface
90
+ return output_path, debug_output_path if use_lines else None, uploaded_files
91
 
92
  except subprocess.CalledProcessError as e:
93
  error_msg = f"Error converting image to DXF: {e.stderr.decode('utf-8') if e.stderr else e}"
94
  return error_msg, None, None
95
 
96
  def main():
 
 
 
 
 
 
 
 
 
97
  with gr.Blocks() as demo:
98
  with gr.Tabs():
99
  # Tab for conversion
 
128
  demo.launch(share=True)
129
 
130
  if __name__ == "__main__":
131
+ try:
132
+ subprocess.run(['chmod', '+x', './SimpleImageToDxfHavePass'], check=True)
133
+ except subprocess.CalledProcessError as e:
134
+ print(f"Error setting permissions: {e}")
135
+ exit(1)
136
  main()