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

ZeroDivisionError in Tutorial 6 #316

Closed Bergylta closed 7 months ago

Bergylta commented 7 months ago

🐛 Bug

A clear and concise description of what the bug is.

To Reproduce (REQUIRED)

Input: Model: GU_black_round_gobies_model3 Movie: /mimer/NOBACKUP/groups/snic2021-6-9/project_movies/movies_GU/Testing_model_movie/ Confidence Threshold: 0,5

# @title <font size="5">↓ ឵឵<i>Run model over selected custom footage</font> { vertical-output: true }
eval_dir = mlp.detect_yolov5(
    source=source_value,
    save_dir=save_dir.selected,
    conf_thres=conf_thres.value,
    artifact_dir=artifact_dir,
    save_output=True,
    exp_name="detect",

Output:

wandb version 0.16.0 is available! To upgrade, please run: $ pip install wandb --upgrade
Tracking run with wandb version 0.13.2
Run data is saved locally in /mimer/NOBACKUP/groups/snic2021-6-9/wandb/run-20231115_142310-4cyx310m
Syncing run [predict](https://wandb.ai/koster/model-evaluations/runs/4cyx310m) to [Weights & Biases](https://wandb.ai/koster/model-evaluations) ([docs](https://wandb.me/run))
YOLOv5 🚀 2023-10-30 Python-3.8.10 torch-2.1.0+cu121 CUDA:0 (NVIDIA A40, 45626MiB)

Fusing layers... 
Model summary: 226 layers, 21041679 parameters, 0 gradients
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In[16], line 2
      1 # @title <font size="5">↓ ឵឵<i>Run model over selected custom footage</font> { vertical-output: true }
----> 2 eval_dir = mlp.detect_yolov5(
      3     source=source_value,
      4     save_dir=save_dir.selected,
      5     conf_thres=conf_thres.value,
      6     artifact_dir=artifact_dir,
      7     save_output=True,
      8     exp_name="detect",
      9 )

File /usr/src/app/kso-dev/kso_utils/project.py:1334, in MLProjectProcessor.detect_yolov5(self, exp_name, source, save_dir, conf_thres, artifact_dir, img_size, save_output)
   1325 eval_dir = increment_path(Path(save_dir) / exp_name, exist_ok=False)
   1326 weights_path = [
   1327     f
   1328     for f in Path(artifact_dir).iterdir()
   (...)
   1332     and "best" in str(f)
   1333 ][0]
-> 1334 self.modules["detect"].run(
   1335     weights=weights_path,
   1336     source=source,
   1337     conf_thres=conf_thres,
   1338     save_txt=True,
   1339     save_conf=True,
   1340     project=save_dir,
   1341     name=exp_name,
   1342     nosave=not save_output,
   1343 )
   1344 self.save_detections_wandb(conf_thres, weights_path, eval_dir)
   1345 if wandb.run is not None:

File /usr/local/lib/python3.8/dist-packages/torch/utils/_contextlib.py:115, in context_decorator.<locals>.decorate_context(*args, **kwargs)
    112 @functools.wraps(func)
    113 def decorate_context(*args, **kwargs):
    114     with ctx_factory():
--> 115         return func(*args, **kwargs)

File /usr/src/app/kso-dev/yolov5/detect.py:265, in run(weights, source, data, imgsz, conf_thres, iou_thres, max_det, device, view_img, save_txt, save_conf, save_crop, nosave, classes, agnostic_nms, augment, visualize, update, project, name, exist_ok, line_thickness, hide_labels, hide_conf, half, dnn, vid_stride)
    260     LOGGER.info(
    261         f"{s}{'' if len(det) else '(no detections), '}{dt[1].dt * 1E3:.1f}ms"
    262     )
    264 # Print results
--> 265 t = tuple(x.t / seen * 1e3 for x in dt)  # speeds per image
    266 LOGGER.info(
    267     f"Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {(1, 3, *imgsz)}"
    268     % t
    269 )
    270 if save_txt or save_img:

File /usr/src/app/kso-dev/yolov5/detect.py:265, in <genexpr>(.0)
    260     LOGGER.info(
    261         f"{s}{'' if len(det) else '(no detections), '}{dt[1].dt * 1E3:.1f}ms"
    262     )
    264 # Print results
--> 265 t = tuple(x.t / seen * 1e3 for x in dt)  # speeds per image
    266 LOGGER.info(
    267     f"Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {(1, 3, *imgsz)}"
    268     % t
    269 )
    270 if save_txt or save_img:

ZeroDivisionError: float division by zero

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

image image

image