Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Oct 24, 2024
2 parents 7dedbc1 + 11425eb commit 7544b54
Show file tree
Hide file tree
Showing 98 changed files with 239 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fail_fast: true
#exclude: '^exclude'
repos:
- repo: https://github.com/ambv/black
rev: 23.7.0
rev: 24.10.0
hooks:
- id: black
language_version: python3.10
Expand Down
80 changes: 14 additions & 66 deletions neodroidvision/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import datetime
import os
from importlib import resources
from importlib.metadata import PackageNotFoundError
from warnings import warn
from apppath import AppPath

try:
from importlib.resources import files
from importlib.metadata import PackageNotFoundError
except (ModuleNotFoundError, ImportError) as e:
from importlib_metadata import PackageNotFoundError
from importlib_resources import files

from warg import package_is_editable, clean_string, get_version

from apppath import AppPath
from warg import package_is_editable

__project__ = "NeodroidVision"
__author__ = "Christian Heider Nielsen"
Expand All @@ -29,75 +31,21 @@
# __all__ = ['PROJECT_APP_PATH', 'PROJECT_NAME', 'PROJECT_VERSION', 'get_version']


from typing import Any


PROJECT_NAME = __project__.lower().strip().replace(" ", "_")
PROJECT_NAME = clean_string(__project__)
PROJECT_VERSION = __version__
PROJECT_YEAR = 2018
PROJECT_AUTHOR = __author__.lower().strip().replace(" ", "_")
PROJECT_ORGANISATION = "Neodroid"
PROJECT_AUTHOR = clean_string(__author__)
PROJECT_ORGANISATION = clean_string("Neodroid")
PROJECT_APP_PATH = AppPath(app_name=PROJECT_NAME, app_author=PROJECT_AUTHOR)
INCLUDE_PROJECT_READMES = False

PACKAGE_DATA_PATH = resources.files(PROJECT_NAME) / "data"
PACKAGE_DATA_PATH = files(PROJECT_NAME) / "data"

try:
DEVELOP = package_is_editable(PROJECT_NAME)
except PackageNotFoundError as e:
DEVELOP = True


def get_version(append_time: Any = DEVELOP) -> str:
"""
Args:
append_time:
Returns:
"""
version = __version__
if not version:
version = os.getenv("VERSION", "0.0.0")

if append_time:
now = datetime.datetime.utcnow()
date_version = now.strftime("%Y%m%d%H%M%S")
# date_version = time.time()

if version:
# Most git tags are prefixed with 'v' (example: v1.2.3) this is
# never desirable for artifact repositories, so we strip the
# leading 'v' if it's present.
version = (
version[1:]
if isinstance(version, str) and version.startswith("v")
else version
)
else:
# Default version is an ISO8601 compliant datetime. PyPI doesn't allow
# the colon ':' character in its versions, and time is required to allow
# for multiple publications to master in one day. This datetime string
# uses the 'basic' ISO8601 format for both its date and time components
# to avoid issues with the colon character (ISO requires that date and
# time components of a date-time string must be uniformly basic or
# extended, which is why the date component does not have dashes.
#
# Publications using datetime versions should only be made from master
# to represent the HEAD moving forward.
warn(
f"Environment variable VERSION is not set, only using datetime: {date_version}"
)

# warn(f'Environment variable VERSION is not set, only using timestamp: {version}')

version = f"{version}.{date_version}"

return version


if __version__ is None:
__version__ = get_version(append_time=True)

__version__ = get_version(__version__, append_time=DEVELOP)
__version_info__ = tuple(int(segment) for segment in __version__.split("."))
5 changes: 3 additions & 2 deletions neodroidvision/classification/procedures/deprec/procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
from matplotlib import pyplot
from munin.generate_report import ReportEntry, generate_html, generate_pdf
from munin.html_embeddings import ReportFormatEnum, generate_math_html, plt_html
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
from warg import NOD

from neodroidvision.data.neodroid_environments.classification.data import (
default_torch_retransform,
)
from sklearn.metrics import accuracy_score, precision_recall_fscore_support
from warg import NOD

__all__ = ["test_model", "predictor_response_train_model_neodroid_observations"]

Expand Down
5 changes: 3 additions & 2 deletions neodroidvision/data/classification/imagenet/imagenet_2012.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
from draugr.torch_utilities import SupervisedDataset
from draugr.visualisation import progress_bar
from matplotlib import pyplot
from torch.utils import data
from torchvision import transforms

from neodroidvision.data.classification.imagenet.imagenet_2012_id import categories_id
from neodroidvision.data.classification.imagenet.imagenet_2012_names import (
categories_names,
)
from torch.utils import data
from torchvision import transforms

__all__ = ["ImageNet2012"]

Expand Down
3 changes: 2 additions & 1 deletion neodroidvision/data/classification/nlet/pair_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
from draugr.numpy_utilities import SplitEnum
from draugr.torch_utilities import SupervisedDataset, global_pin_memory, to_tensor
from matplotlib import pyplot
from neodroidvision.data.classification import DictImageFolder, SplitDictImageFolder
from torch.utils.data import DataLoader
from warg import drop_unused_kws, passes_kws_to

from neodroidvision.data.classification import DictImageFolder, SplitDictImageFolder

__all__ = ["PairDataset"]


Expand Down
1 change: 1 addition & 0 deletions neodroidvision/data/detection/coco/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from PIL import Image
from draugr.numpy_utilities import SplitEnum
from draugr.opencv_utilities import xywh_to_minmax

from neodroidvision.data.detection.object_detection_dataset import (
ObjectDetectionDataset,
)
Expand Down
1 change: 1 addition & 0 deletions neodroidvision/data/detection/coco/deprec/s_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from PIL import Image
from draugr.numpy_utilities import SplitEnum
from draugr.opencv_utilities import xywh_to_minmax

from neodroidvision.data.detection.object_detection_dataset import (
ObjectDetectionDataset,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy
from PIL import Image, ImageEnhance
from draugr.visualisation import progress_bar

from neodroidvision.data.synthesis.conversion.mnist.json_generation.mask_json_utilities import (
MaskJsonUtils,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import torchvision.datasets
from draugr.numpy_utilities import SplitEnum

from neodroidvision import PROJECT_APP_PATH


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cv2
import numpy
import tqdm

from neodroidvision import PROJECT_APP_PATH

filename = [
Expand Down
1 change: 1 addition & 0 deletions neodroidvision/data/synthesis/conversion/mnist/seg_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy
import tqdm
from matplotlib import pyplot

from neodroidvision import PROJECT_APP_PATH

filename = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import numpy
from draugr.numpy_utilities import SplitEnum
from neodroidvision import PROJECT_APP_PATH
from tqdm import trange

from neodroidvision import PROJECT_APP_PATH
from .augmentation import rotate_y
from .gen import img_to_point_cloud, make_voxel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from typing import List, Tuple

import torch
from torch import nn

from neodroidvision.detection.single_stage.ssd.architecture.backbones.ssd_backbone import (
SSDBackbone,
)
Expand All @@ -27,7 +29,6 @@
from neodroidvision.utilities.torch_utilities.persistence.custom_model_caching import (
load_state_dict_from_url,
)
from torch import nn

__all__ = ["EfficientNet"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

from typing import List

from torch import Tensor, nn

from neodroidvision.detection.single_stage.ssd.architecture.backbones.ssd_backbone import (
SSDBackbone,
)
from torch import Tensor, nn

__all__ = ["MobileNetV2"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
from enum import Enum
from typing import List, Union

from torch import Tensor, nn
from torch.nn.functional import relu

from neodroidvision.detection.single_stage.ssd.architecture.backbones.ssd_backbone import (
SSDBackbone,
)
from neodroidvision.utilities.torch_utilities import L2Norm
from torch import Tensor, nn
from torch.nn.functional import relu

__all__ = ["VGG"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@

import torch
from draugr.torch_utilities import to_tensor
from torch import nn
from torch.nn import Parameter, functional

from neodroidvision.detection.single_stage.ssd.architecture.nms_box_heads.box_predictor import (
BoxPredictor,
)
from neodroidvision.detection.single_stage.ssd.bounding_boxes import conversion
from neodroidvision.detection.single_stage.ssd.bounding_boxes.ssd_priors import (
build_priors,
)
from torch import nn
from torch.nn import Parameter, functional

__all__ = ["SSDNmsBoxHead", "SSDOut"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
Created on 11/05/2020
"""

from torch import nn

from neodroidvision.detection.single_stage.ssd.architecture.nms_box_heads.box_predictor import (
BoxPredictor,
)
from torch import nn

__all__ = ["SSDBoxPredictor"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
Created on 11/05/2020
"""

from torch import nn

from neodroidvision.detection.single_stage.ssd.architecture.nms_box_heads.box_predictor import (
BoxPredictor,
)
from neodroidvision.utilities import SeparableConv2d
from torch import nn

__all__ = ["SSDLiteBoxPredictor"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
SubtractMeans,
)
from draugr.torch_utilities import CV2ToTensor
from warg import NOD

from neodroidvision.detection.single_stage.ssd.bounding_boxes.ssd_priors import (
build_priors,
ssd_assign_priors,
)
from warg import NOD

from .conversion import (
center_to_corner_form,
convert_boxes_to_locations,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

from pathlib import Path

from warg import NOD

from neodroidvision import PROJECT_APP_PATH
from neodroidvision.detection import SSDBoxPredictor
from neodroidvision.detection.single_stage.ssd.architecture.backbones import vgg_factory
from warg import NOD

base_cfg = NOD()

Expand Down
7 changes: 4 additions & 3 deletions neodroidvision/detection/single_stage/ssd/multi_box_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

import torch
from draugr.torch_utilities import ReductionMethodEnum
from neodroidvision.detection.single_stage.ssd.bounding_boxes import (
hard_negative_mining,
)
from torch import nn
from torch.nn import functional
from warg import Number

from neodroidvision.detection.single_stage.ssd.bounding_boxes import (
hard_negative_mining,
)

__all__ = ["MultiBoxLoss"]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import torch
from draugr.numpy_utilities import SplitEnum
from draugr.torch_utilities import LimitedBatchResampler
from torch.utils.data import ConcatDataset, DataLoader
from warg import NOD

from neodroidvision.data.detection.multi_dataset import MultiDataset
from neodroidvision.utilities import (
BatchCollator,
DistributedSampler,
)
from torch.utils.data import ConcatDataset, DataLoader
from warg import NOD

__all__ = ["object_detection_data_loaders"]

Expand Down
7 changes: 4 additions & 3 deletions neodroidvision/detection/single_stage/ssd/ssd_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import torch
import torch.utils.data
from draugr.visualisation import progress_bar
from torch.nn import Module
from torch.utils.data import DataLoader
from warg import NOD

from neodroidvision import PROJECT_APP_PATH
from neodroidvision.data.detection.coco import COCODataset, coco_evaluation
from neodroidvision.data.detection.voc import VOCDataset, voc_evaluation
Expand All @@ -25,9 +29,6 @@
is_main_process,
synchronise_torch_barrier,
)
from torch.nn import Module
from torch.utils.data import DataLoader
from warg import NOD

__all__ = ["do_ssd_evaluation"]

Expand Down
Loading

0 comments on commit 7544b54

Please sign in to comment.