Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sronilsson committed Sep 18, 2024
2 parents f155298 + 8d9befd commit 842386a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
19 changes: 11 additions & 8 deletions simba/bounding_box_tools/yolo/geometries_to_annotations.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import json
import os
from typing import Optional, Union, Dict, Tuple
from pycocotools import mask
from datetime import datetime
from typing import Dict, Optional, Tuple, Union

import cv2
import json
from simba.utils.read_write import read_df, get_video_meta_data, read_frm_of_video
import numpy as np
from simba.mixins.geometry_mixin import GeometryMixin
from pycocotools import mask
from shapely.geometry import Polygon
from datetime import datetime
from simba.utils.checks import check_int, check_instance, check_valid_array
from simba.utils.enums import Formats
from skimage.draw import polygon

from simba.mixins.geometry_mixin import GeometryMixin
from simba.utils.checks import check_instance, check_int, check_valid_array
from simba.utils.enums import Formats
from simba.utils.read_write import (get_video_meta_data, read_df,
read_frm_of_video)


def geometry_to_rle(geometry: Union[np.ndarray, Polygon], img_size: Tuple[int, int]):
"""
Converts a geometry (polygon or NumPy array) into a Run-Length Encoding (RLE) mask, suitable for object detection or segmentation tasks.
Expand Down
14 changes: 9 additions & 5 deletions simba/bounding_box_tools/yolo/model.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import functools
import multiprocessing
import os
from typing import Optional, Tuple, Union

import numpy as np
import pandas as pd
import torch
from ultralytics import YOLO
from typing import Union, Optional, Tuple
import multiprocessing
import pandas as pd
import functools

from simba.utils.enums import Defaults
from simba.utils.read_write import get_video_meta_data, read_img_batch_from_video_gpu, find_core_cnt
from simba.utils.read_write import (find_core_cnt, get_video_meta_data,
read_img_batch_from_video_gpu)


def fit_yolo(initial_weights: Union[str, os.PathLike],
data: Union[str, os.PathLike],
Expand Down
6 changes: 4 additions & 2 deletions simba/data_processors/cuda/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
from numba import cuda

from simba.data_processors.cuda.utils import _cuda_mse
from simba.mixins.image_mixin import ImageMixin
from simba.utils.checks import (check_file_exist_and_readable, check_float,
check_if_dir_exists,
Expand All @@ -29,12 +30,13 @@
check_nvidea_gpu_available,
check_that_hhmmss_start_is_before_end,
check_valid_array, check_valid_boolean)
from simba.data_processors.cuda.utils import _cuda_mse
from simba.utils.data import find_frame_numbers_from_time_stamp
from simba.utils.enums import Formats
from simba.utils.errors import FFMPEGCodecGPUError, InvalidInputError
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.read_write import (check_if_hhmmss_timestamp_is_valid_part_of_video, get_fn_ext, get_video_meta_data, read_img_batch_from_video_gpu)
from simba.utils.read_write import (
check_if_hhmmss_timestamp_is_valid_part_of_video, get_fn_ext,
get_video_meta_data, read_img_batch_from_video_gpu)

PHOTOMETRIC = 'photometric'
DIGITAL = 'digital'
Expand Down
8 changes: 5 additions & 3 deletions simba/data_processors/cuda/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Tuple, Dict, Any
import numpy as np
from numba import cuda, guvectorize, float64
import math
from typing import Any, Dict, Tuple

import numpy as np
from numba import cuda, float64, guvectorize


@cuda.jit(device=True)
def _cuda_sum(x: np.ndarray):
Expand Down
22 changes: 15 additions & 7 deletions simba/third_party_label_appenders/BORIS_appender.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@
import glob
import os
from copy import deepcopy
import pandas as pd
from typing import Union

import pandas as pd

from simba.mixins.config_reader import ConfigReader
from simba.third_party_label_appenders.tools import is_new_boris_version, read_boris_annotation_files
from simba.utils.checks import (check_if_dir_exists, check_if_filepath_list_is_empty)
from simba.utils.errors import (ThirdPartyAnnotationEventCountError, ThirdPartyAnnotationOverlapError, NoDataError)
from simba.utils.printing import stdout_success, SimbaTimer
from simba.utils.read_write import get_fn_ext, read_df, write_df, find_files_of_filetypes_in_directory
from simba.utils.warnings import (ThirdPartyAnnotationsInvalidFileFormatWarning, ThirdPartyAnnotationsOutsidePoseEstimationDataWarning)
from simba.third_party_label_appenders.tools import (
is_new_boris_version, read_boris_annotation_files)
from simba.utils.checks import (check_if_dir_exists,
check_if_filepath_list_is_empty)
from simba.utils.errors import (NoDataError,
ThirdPartyAnnotationEventCountError,
ThirdPartyAnnotationOverlapError)
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.read_write import (find_files_of_filetypes_in_directory,
get_fn_ext, read_df, write_df)
from simba.utils.warnings import (
ThirdPartyAnnotationsInvalidFileFormatWarning,
ThirdPartyAnnotationsOutsidePoseEstimationDataWarning)

BEHAVIOR = 'BEHAVIOR'
class BorisAppender(ConfigReader):
Expand Down
5 changes: 3 additions & 2 deletions simba/utils/read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@
ParametersFileError, PermissionError)
from simba.utils.printing import SimbaTimer, stdout_success
from simba.utils.warnings import (
FileExistWarning, InvalidValueWarning, NoDataFoundWarning,
NoFileFoundWarning, ThirdPartyAnnotationsInvalidFileFormatWarning, FrameRangeWarning)
FileExistWarning, FrameRangeWarning, InvalidValueWarning,
NoDataFoundWarning, NoFileFoundWarning,
ThirdPartyAnnotationsInvalidFileFormatWarning)

# from simba.utils.keyboard_listener import KeyboardListener

Expand Down

0 comments on commit 842386a

Please sign in to comment.