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

Notebook 9 issue with processing detections #388

Closed Bergylta closed 3 months ago

Bergylta commented 3 months ago

🐛 Bug

A clear and concise description of what the bug is.

To Reproduce (REQUIRED)

Input: Movie path: /data/album/kso/Xhoni_model1/Testing_zip4/gp_greb_c_1.mp4

dets_df = pp.process_detections(
    project=pp.project,
    db_connection=pp.db_connection,
    csv_paths=pp.csv_paths,
    annotations_csv_path=mlp.eval_dir,
    model_registry=mlp.registry,
    model=model.value,
    team_name=mlp.team_name,
    project_name=mlp.project_name,
)

Output:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
Cell In[20], line 1
----> 1 dets_df = pp.process_detections(
      2     project=pp.project,
      3     db_connection=pp.db_connection,
      4     csv_paths=pp.csv_paths,
      5     annotations_csv_path=mlp.eval_dir,
      6     model_registry=mlp.registry,
      7     model=model.value,
      8     team_name=mlp.team_name,
      9     project_name=mlp.project_name,
     10 )

File ~/kso/kso_utils/project.py:1119, in ProjectProcessor.process_detections(self, project, db_connection, csv_paths, annotations_csv_path, model_registry, model, project_name, team_name)
   1104 def process_detections(
   1105     self,
   1106     project,
   (...)
   1113     team_name,
   1114 ):
   1115     """
   1116     > This function computes the given statistics over the detections obtained by a model on different footages for the species of interest,
   1117     and saves the results in different csv files.
   1118     """
-> 1119     return yolo_utils.process_detections(
   1120         project=project,
   1121         db_connection=db_connection,
   1122         csv_paths=csv_paths,
   1123         annotations_csv_path=annotations_csv_path,
   1124         model_registry=model_registry,
   1125         selected_movies_id=self.selected_movies_ids,
   1126         model=model,
   1127         project_name=project_name,
   1128         team_name=team_name,
   1129         source_movies=self.selected_movies_paths,
   1130     )

File ~/kso/kso_utils/yolo_utils.py:2111, in process_detections(project, db_connection, csv_paths, annotations_csv_path, model_registry, selected_movies_id, model, project_name, team_name, source_movies)
   2108 from kso_utils.movie_utils import get_fps_duration
   2110 # Get the fps of the movie
-> 2111 df["fps"], _ = get_fps_duration(movie_path=source_movies)
   2113 # Set the movie id to 0
   2114 df["movie_id"] = 0

File ~/kso/kso_utils/movie_utils.py:48, in get_fps_duration(movie_path)
     41 def get_fps_duration(movie_path: str):
     42     """
     43     This function takes the path (or url) of a movie and returns its fps and duration information
     44 
     45     :param movie_path: a string containing the path (or url) where the movie of interest can be access from
     46     :return: Two integers, the fps and duration of the movie
     47     """
---> 48     cap = cv2.VideoCapture(movie_path)
     49     fps = cap.get(cv2.CAP_PROP_FPS)
     50     frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'VideoCapture'
> Overload resolution failed:
>  - Can't convert object of type 'list' to 'str' for 'filename'
>  - VideoCapture() missing required argument 'apiPreference' (pos 2)
>  - Argument 'index' is required to be an integer
>  - VideoCapture() missing required argument 'apiPreference' (pos 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.