ocean-data-factory-sweden / kso

Notebooks to upload/download marine footage, connect to a citizen science project, train machine learning models and publish marine biological observations.
GNU General Public License v3.0
4 stars 12 forks source link

Encounter error when running trained model on footage #404

Closed donkyjohn closed 1 month ago

donkyjohn commented 1 month ago

Before submitting a bug report, please be aware that your issue must be reproducible with all of the following, otherwise it is non-actionable, and we can not help you:

If this is a custom dataset/training question you must include your train*.jpg, test*.jpg and results.png figures, or we can not help you. You can generate these with utils.plot_results().

🐛 Bug

Running the model on Saga's footage returns value errors.

To Reproduce (REQUIRED)

Input:

Goto notebook 9 and run the model KSO_SEG_1 on the footage in folder /buckets/kso/input/kristineberg_2024_april_SA/. 

Output:

ValueError                                Traceback (most recent call last)
Cell In[17], line 2
      1 # Get the paths of the movies selected
----> 2 mlp.detect_yolo(
      3     save_dir=save_dir.selected,
      4     conf_thres=conf_thres.value,
      5     artifact_dir=artifact_dir,
      6     save_output=True,
      7     project=mlp.project_name,
      8     name=exp_name.value,
      9     model=model.value,
     10     latest=True,
     11     source=(
     12         pp.selected_movies_paths
     13         if isinstance(pp.selected_movies_paths, str)
     14         else pp.selected_movies_paths[0]
     15     ),
     16 )

File ~/.local/lib/python3.10/site-packages/kso_utils/project.py:2067, in MLProjectProcessor.detect_yolo(self, project, name, source, save_dir, conf_thres, artifact_dir, model, img_size, save_output, test, latest)
   2043     return
   2044     # if isinstance(source, list):
   2045     #     for src in source:
   2046     #         self.modules["detect"].run(
   (...)
   2065     #         nosave=not save_output,
   2066     #     )
-> 2067 self.save_detections(conf_thres, model.ckpt_path, self.eval_dir)

File ~/.local/lib/python3.10/site-packages/kso_utils/project.py:2126, in MLProjectProcessor.save_detections(self, conf_thres, model, eval_dir)
   2119     self.modules["yolo_utils"].add_data(
   2120         Path(eval_dir, "labels"),
   2121         "detection_output",
   2122         self.registry,
   2123         self.run,
   2124     )
   2125 elif self.registry == "mlflow":
-> 2126     self.csv_report = self.modules["yolo_utils"].generate_csv_report(
   2127         evaluation_path=eval_dir,
   2128         run=self.run,
   2129         log=True,
   2130         registry=self.registry,
   2131         movie_csv_df=self.local_movies_csv,
   2132     )
   2133     self.modules["yolo_utils"].add_data(
   2134         path=Path(eval_dir, "annotations.csv"),
   2135         name="detection_output",
   2136         registry=self.registry,
   2137         run=self.run,
   2138     )
   2139     import shutil

File ~/.local/lib/python3.10/site-packages/kso_utils/yolo_utils.py:1086, in generate_csv_report(evaluation_path, movie_csv_df, run, log, registry)
   1084         for line in lines:
   1085             parts = line.split()
-> 1086             class_id, x, y, w, h, conf = parts[:6]
   1087             data_dict.setdefault(str(label_file), []).append(
   1088                 [class_id, frame_no, x, y, w, h, float(conf)]
   1089             )
   1091 dlist = [[key, *i] for key, values in data_dict.items() for i in values]

ValueError: not enough values to unpack (expected 6, got 2)

Expected behavior

A clear and concise description of what you expected to happen.

Environment

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.