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

Issue with generating tracking individual in tutorial 6 #317

Closed Bergylta closed 7 months ago

Bergylta commented 7 months ago

🐛 Bug

To Reproduce (REQUIRED)

Input:

mlp.track_individuals(
    source=source_value,
    artifact_dir=artifact_dir,
    eval_dir=eval_dir,
    conf_thres=conf_thres.value,
    img_size=(540, 540),
    name="track",

Output:

TypeError                                 Traceback (most recent call last)
Cell In[17], line 1
----> 1 mlp.track_individuals(
      2     source=source_value,
      3     artifact_dir=artifact_dir,
      4     eval_dir=eval_dir,
      5     conf_thres=conf_thres.value,
      6     img_size=(540, 540),
      7     name="track",
      8 )

File /usr/src/app/kso-dev/kso_utils/project.py:1367, in MLProjectProcessor.track_individuals(self, name, source, artifact_dir, eval_dir, conf_thres, img_size)
   1358 def track_individuals(
   1359     self,
   1360     name: str,
   (...)
   1365     img_size: tuple = (540, 540),
   1366 ):
-> 1367     latest_tracker = self.modules["yolo_utils"].track_objects(
   1368         name=name,
   1369         source_dir=source,
   1370         artifact_dir=artifact_dir,
   1371         tracker_folder=eval_dir,
   1372         conf_thres=conf_thres,
   1373         img_size=img_size,
   1374         gpu=True if self.modules["torch"].cuda.is_available() else False,
   1375     )
   1376     # Create a new run for tracking only if necessary
   1377     self.run = self.modules["wandb"].init(
   1378         entity=self.team_name,
   1379         project="model-evaluations",
   1380         name="track",
   1381         settings=self.modules["wandb"].Settings(start_method="thread"),
   1382     )

File /usr/src/app/kso-dev/kso_utils/yolo_utils.py:1217, in track_objects(name, source_dir, artifact_dir, tracker_folder, conf_thres, img_size, gpu)
   1206     return None
   1208 model_path = [
   1209     f
   1210     for f in Path(artifact_dir).iterdir()
   (...)
   1214     and "best" in str(f)
   1215 ]
-> 1217 best_model = Path(model_path)
   1219 if not gpu:
   1220     track.run(
   1221         name=name,
   1222         source=source_dir,
   (...)
   1230         save_txt=True,
   1231     )

File /usr/lib/python3.8/pathlib.py:1042, in Path.__new__(cls, *args, **kwargs)
   1040 if cls is Path:
   1041     cls = WindowsPath if os.name == 'nt' else PosixPath
-> 1042 self = cls._from_parts(args, init=False)
   1043 if not self._flavour.is_supported:
   1044     raise NotImplementedError("cannot instantiate %r on your system"
   1045                               % (cls.__name__,))

File /usr/lib/python3.8/pathlib.py:683, in PurePath._from_parts(cls, args, init)
    678 @classmethod
    679 def _from_parts(cls, args, init=True):
    680     # We need to call _parse_args on the instance, so as to get the
    681     # right flavour.
    682     self = object.__new__(cls)
--> 683     drv, root, parts = self._parse_args(args)
    684     self._drv = drv
    685     self._root = root

File /usr/lib/python3.8/pathlib.py:667, in PurePath._parse_args(cls, args)
    665     parts += a._parts
    666 else:
--> 667     a = os.fspath(a)
    668     if isinstance(a, str):
    669         # Force-cast str subclasses to str (issue #21127)
    670         parts.append(str(a))

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

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.