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

Tutorial 9 issue with generating detections #325

Closed Bergylta closed 7 months ago

Bergylta commented 7 months 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

A clear and concise description of what the bug is.

To Reproduce (REQUIRED)

Project: GU model: GU_crabs_gobies_wrasses1 Conf: 0,5 Experiment name: Testing_wandb_storage_location3 Input:

mlp.detect_yolo(
    source=pp.movies_paths,
    save_dir=save_dir.selected,
    conf_thres=conf_thres.value,
    artifact_dir=artifact_dir,
    save_output=True,
    project=mlp.project_name,
    name=exp_name.value,
    model=model.value,
    latest=False,
)

Output:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[15], line 1
----> 1 mlp.detect_yolo(
      2     source=pp.movies_paths,
      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=False,
     11 )

File /usr/src/app/kso-dev/kso_utils/project.py:1747, in MLProjectProcessor.detect_yolo(self, project, name, source, save_dir, conf_thres, artifact_dir, model, img_size, save_output, test, latest)
   1736 else:
   1737     self.modules["detect"].run(
   1738         weights=best_model,
   1739         source=source,
   (...)
   1745         nosave=not save_output,
   1746     )
-> 1747 self.save_detections(conf_thres, model.ckpt_path, self.eval_dir)

File /usr/src/app/kso-dev/kso_utils/project.py:1796, in MLProjectProcessor.save_detections(self, conf_thres, model, eval_dir)
   1794 def save_detections(self, conf_thres: float, model: str, eval_dir: str):
   1795     if self.registry == "wandb":
-> 1796         data_dict = self.run.rawconfig["data_dict"]
   1797         species_mapping = data_dict["names"]
   1798         self.modules["yolo_utils"].set_config(
   1799             conf=conf_thres,
   1800             model_name=model,
   1801             evaluation_directory=eval_dir,
   1802             species_map=species_mapping,
   1803         )

AttributeError: 'Run' object has no attribute 'rawconfig'

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.

Bergylta commented 7 months ago

New error, same spot:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[14], line 1
----> 1 mlp.detect_yolo(
      2     source=pp.movies_paths,
      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=False,
     11 )

File /usr/src/app/kso-dev/kso_utils/project.py:1746, in MLProjectProcessor.detect_yolo(self, project, name, source, save_dir, conf_thres, artifact_dir, model, img_size, save_output, test, latest)
   1735 else:
   1736     self.modules["detect"].run(
   1737         weights=best_model,
   1738         source=source,
   (...)
   1744         nosave=not save_output,
   1745     )
-> 1746 self.save_detections(conf_thres, model.ckpt_path, self.eval_dir)

File /usr/src/app/kso-dev/kso_utils/project.py:1802, in MLProjectProcessor.save_detections(self, conf_thres, model, eval_dir)
   1799         yaml_data = yaml.safe_load(file)
   1800     return yaml_data
-> 1802 data_dict = read_yaml_file(self.data_path)
   1803 species_mapping = data_dict["names"]
   1804 self.modules["yolo_utils"].set_config(
   1805     conf=conf_thres,
   1806     model_name=model,
   1807     evaluation_directory=eval_dir,
   1808     species_map=species_mapping,
   1809 )

File /usr/src/app/kso-dev/kso_utils/project.py:1798, in MLProjectProcessor.save_detections.<locals>.read_yaml_file(file_path)
   1797 def read_yaml_file(file_path):
-> 1798     with open(file_path, "r") as file:
   1799         yaml_data = yaml.safe_load(file)
   1800     return yaml_data

TypeError: expected str, bytes or os.PathLike object, not NoneType