Skip to content

Commit

Permalink
fix: handle TypeError in predict_is_ready caused by non-string message
Browse files Browse the repository at this point in the history
Resolved an issue in  where a  object
was being checked with the  operator, causing a .
Converted  to a string before performing the check to ensure
compatibility. Added safeguards to handle non-string message types
gracefully.
  • Loading branch information
healthonrails committed Nov 26, 2024
1 parent 69347aa commit bcaa3cd
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions annolid/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,22 +1162,26 @@ def predict_is_ready(self, messege):
"background-color: green; color: white;")
self.stepSizeWidget.predict_button.setEnabled(True)
self.stop_prediction_flag = False
if messege is not None and "last frame" in messege:
QtWidgets.QMessageBox.information(
self, "Stop early",
messege
)
else:
if self.video_loader is not None:
num_json_files = count_json_files(self.video_results_folder)
logger.info(
f"Number of predicted frames: {num_json_files} in total {self.num_frames}")
if num_json_files >= self.num_frames:
# convert json labels to csv file
self.convert_json_to_tracked_csv()
QtWidgets.QMessageBox.information(
self, "Prediction Ready",
"Predictions for the video frames have been generated!")
try:
if messege is not None and "last frame" in str(messege):
QtWidgets.QMessageBox.information(
self, "Stop early",
messege
)
else:
if self.video_loader is not None:
num_json_files = count_json_files(
self.video_results_folder)
logger.info(
f"Number of predicted frames: {num_json_files} in total {self.num_frames}")
if num_json_files >= self.num_frames:
# convert json labels to csv file
self.convert_json_to_tracked_csv()
QtWidgets.QMessageBox.information(
self, "Prediction Ready",
"Predictions for the video frames have been generated!")
except RuntimeError as e:
print(f"RuntimeError occurred: {e}")

def loadFlags(self, flags):
for key, flag in flags.items():
Expand Down

0 comments on commit bcaa3cd

Please sign in to comment.