sloneckity commited on
Commit
7d41249
·
1 Parent(s): 4b664ae

Add enhanced logging for debugging nemaquant.py execution

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -91,11 +91,22 @@ def process_images():
91
 
92
  try:
93
  print(f"Running command: {' '.join(cmd)}") # Log the command
 
 
 
94
  # Run the script, capture output and errors
95
  # Timeout might be needed for long processes on shared infrastructure like HF Spaces
96
  result = subprocess.run(cmd, capture_output=True, text=True, check=True, timeout=300) # 5 min timeout
97
  status_log = f"NemaQuant Output:\n{result.stdout}\nNemaQuant Errors:\n{result.stderr}"
98
  print(status_log) # Log script output
 
 
 
 
 
 
 
 
99
 
100
  # --- Parse Results ---
101
  if not output_csv.exists():
@@ -113,6 +124,8 @@ def process_images():
113
  suffix = Path(original_filename).suffix
114
  annotated_filename = f"{stem}_annotated{suffix}"
115
  annotated_path = annotated_dir / annotated_filename
 
 
116
 
117
  results_list.append({
118
  "filename": original_filename,
@@ -142,7 +155,9 @@ def process_images():
142
  print(error_message)
143
  return jsonify({"error": "Could not find output file", "log": error_message}), 500
144
  except Exception as e:
145
- error_message = f"An unexpected error occurred: {str(e)}"
 
 
146
  print(error_message)
147
  return jsonify({"error": "An unexpected error occurred", "log": error_message}), 500
148
 
 
91
 
92
  try:
93
  print(f"Running command: {' '.join(cmd)}") # Log the command
94
+ print(f"Input directory contents: {os.listdir(str(job_input_dir))}")
95
+ print(f"Weights file exists: {os.path.exists(str(WEIGHTS_FILE))}")
96
+
97
  # Run the script, capture output and errors
98
  # Timeout might be needed for long processes on shared infrastructure like HF Spaces
99
  result = subprocess.run(cmd, capture_output=True, text=True, check=True, timeout=300) # 5 min timeout
100
  status_log = f"NemaQuant Output:\n{result.stdout}\nNemaQuant Errors:\n{result.stderr}"
101
  print(status_log) # Log script output
102
+
103
+ # Check output directory after command runs
104
+ print(f"Output directory exists: {os.path.exists(str(job_output_dir))}")
105
+ if os.path.exists(str(job_output_dir)):
106
+ print(f"Output directory contents: {os.listdir(str(job_output_dir))}")
107
+
108
+ # Check output file
109
+ print(f"Output CSV exists: {os.path.exists(str(output_csv))}")
110
 
111
  # --- Parse Results ---
112
  if not output_csv.exists():
 
124
  suffix = Path(original_filename).suffix
125
  annotated_filename = f"{stem}_annotated{suffix}"
126
  annotated_path = annotated_dir / annotated_filename
127
+
128
+ print(f"Looking for annotated file: {annotated_path}, exists: {annotated_path.exists()}")
129
 
130
  results_list.append({
131
  "filename": original_filename,
 
155
  print(error_message)
156
  return jsonify({"error": "Could not find output file", "log": error_message}), 500
157
  except Exception as e:
158
+ error_message = f"An unexpected error occurred: {str(e)}\n"
159
+ import traceback
160
+ error_message += traceback.format_exc()
161
  print(error_message)
162
  return jsonify({"error": "An unexpected error occurred", "log": error_message}), 500
163