Skip to content

v0.5.0

Compare
Choose a tag to compare
@thibo73800 thibo73800 released this 16 Feb 16:36
· 82 commits to master since this release
033f45c
  • Fix bug #243 :
    AugTensors can be called without logging the Userwarning

Add the 'append_labels' method to 'BoundingBoxes3D'.

  • New feature 1 : Description
box3d = BoundingBoxes3D([[10, 10, 400, 80, 46, 18, 1]])
box3d.append_labels(label)

When labels names exist, display it next to the 2D bounding box instead of displaying IDs.


  • New feature : #249 Dataset from directory iterator. Main use : calibrating TRT engines.
path1 = "PATH/TO/DIR/WITH/IMAGES1"
path2 = "PATH/TO/DIR/WITH/IMAGES2"

dataset = FromDirectoryDataset(dirs={"right": [path1, path1], "left": [path2, path2]}, slice=[0.2, 0.3])

# Will return dictionary  {"right": img1, "left": img2}
sample1 = dataset[0]

  • Reduce the memory size required to export and run TRT engines.
  • Raise runtime error when a precision is not optimized in a device.

  • Fix bug : #15
>>frame = aloscene.Frame(np.random.uniform(0, 1, (3, 50, 100)), names=("C", "H", "W"))
>>frame = aloscene.Frame.batch_list([frame, frame.clone()])
>>frame = frame.temporal()
>>print(f"names: {frame.names}\nshape: {frame.shape}")
names: ('B', 'T', 'C', 'H', 'W')
shape: torch.Size([2, 1, 3, 50, 100])

  • New feature 1 : Sampler for train loader can be constructed before calling the method
sampler = torch.utils.data.RandomSampler(dataset, replacement=True)
loader = dataset.train_loader(sampler=sampler)
  • New feature 2 : Sampler kwargs can be given to train_loader method:
sampler = torch.utils.data.RandomSampler
loader = dataset.train_loader(sampler=sampler, sampler_kwargs={"replacement":True})

  • Check if the requested normalization is supported
  • Set the mean_std property to resnet_rgb_mean_std at instantiation when using normalization="resnet"

  • New feature 1 :
    When manipulating aug tensor, _saved_names can accumulate None values which could prevent proper concatenation. Note that this might not be an issue once we have a good merging policy of different properties within aug tensors.

  • ***Fix bug #271 *** : Duplicated function
  • Remove alonet.common.weights.vb_fodler
  • add create_if_not_found option to alonet.common.pl_helpers.vb_folder: if .aloception does not exist in home, mkdir is called.

  • Used the keyword arguments **kwargs to allow using different padding_mode & fill values
  • Updated the docstring

Closes #22


This PR improves the black square title displayed on views.
Issue: #12

  • Add parameter to activate/deactivate title (default to True)
    Test code (with add_title=False):
from aloscene import Frame
from alodataset import CocoBaseDataset

coco_dataset = CocoBaseDataset(sample=False, img_folder="test2017")
#checking if regular getitem works
stuff=coco_dataset.getitem(0)
stuff.get_view(add_title=False).render()

#check if dataloader works
for f, frames in enumerate(coco_dataset.train_loader(batch_size=2)):
    frames = Frame.batch_list(frames)
    frames.get_view().render()
    if f > 1:
        break
  • Improve title rendering: Use existing put_adapative_cv2_text() to add title in Renderer class. Improve the function to adapt text size to frame size. Decrease text size if text is too long.
    Test code:
from aloscene import Frame
from alodataset import CocoBaseDataset

coco_dataset = CocoBaseDataset(sample=False, img_folder="test2017")
#checking if regular getitem works
stuff=coco_dataset.getitem(0)
stuff.get_view(add_title=True).render()

#check if dataloader works
for f, frames in enumerate(coco_dataset.train_loader(batch_size=2)):
    frames = Frame.batch_list(frames)
    frames.get_view().render()
    if f > 1:
        break

General description of your pull request with the list of new features and/or bugs.

  • New feature 1 : Support for pytorch 1.13

__torch_function__ was about to not be supported anymore. Switching to classmethod was required. The current implementation seem to still be compatible with pytorch 1.10. Note that this change is touching to the most important/breakable part of the aug tensor pipeline.

Open discussion: Should be update the doc to make pytorch 1.13 the default ? I think not before to check for pytorch lightning support.

By the way: c8ed7f6b1cdfeeec369447517af7321349df1e25


All the named labels are displayed next to BoundingBoxes2D

  • Labels BoundingBoxes2D : Render Labels next to BoundingBoxes2D FIX #221
import numpy as np
from aloscene import Frame, BoundingBoxes2D, Labels

frame = Frame(np.zeros((3, 100, 500)), normalization="01")
label = Labels([0, 1, 0])
label2 = Labels([0, 0, 1], labels_names=["red", "green"])
box = BoundingBoxes2D([[100, 20, 400, 80], [200, 40, 400, 80], [100, 40, 300, 80]], boxes_format="xyxy", absolute=True, frame_size=frame.HW)

box.append_labels(label, name="label")
box.append_labels(label2, name="label2")

frame.append_boxes2d(box)

print(box)
frame.get_view().render()

  • First addition of issue #23 : being able to pad the tensor to the next multiple of multiple
  • unittest

Minimal example

>>> x = aloscene.Frame(torch.rand(1, 10, 10), names=('C', 'H', 'W'))
>>> x.pad(multiple=8).shape
torch.Size([1, 16, 16])
>>> x.pad(multiple=10).shape
torch.Size([1, 10, 10])
>>> x.pad(multiple=32).shape
torch.Size([1, 32, 32])

Fix the merging of tensor to allow torch.cat to accept a tuple of AugmentedTensor.


  • New feature : #260
# While overriding the exporter class
def __init__(dynamic: bool = False, **kwargs):
     if dynamic:
            # Keys are inputs names. Lists are indexes of axes that we want to set as dynamic.
            self.dynamic_axes = {"input1": [1, 2, 3], "input2":[1, 2, 3]}
    #....

  • New feature #269 : Flexible onnx version

General description of your pull request with the list of new features and/or bugs.

  • ***New feature 1 #85 *** : Now we can load a model directly from run_id without passing load_training and Lightning module.
  • weights has highest priority. if weights is None, load model from run_id is used.
  • We can choose to load best checkpoint or last checkpoint.
from alonet.common.weights import load_weights
from alonet.detr import DetrR50

model = DetrR50(num_classes=91, weights="detr-r50")

# load from downloaded weight
load_weights(model, weights="detr-r50")

# load from .pth file
load_weights(model, weights="~/.aloception/weights/detr-r50/detr-r50.pth")


# load from run_id
load_weights(model, run_id="your_run_id_heer", project_run_id="your_project_run_id",)

  • New feature 1 : Rotate frame around a custom center

Torchvision Rotate transform supports the possibility to pass a "center" argument to rotate around a given center (and not only around the image center). I added this functionality to our Rotate Alotransform

from alodataset.coco_base_dataset import CocoBaseDataset
from alodataset.transforms import Rotate

coco_dataset = CocoBaseDataset(sample=True)
x = coco_dataset[0]
angle = 15.0
x = Rotate(angle, center=[650, 0])(x)
x.get_view().render()

  1. fix getitem on augmentedTensor with augmented tensor as mask.
  2. reset name only if tensor aren't linearized (like in bbox unit test) else declass to classic tensor

  • Fix bug 309 : Wrong display of 3d boxes on padded images
    The error was in the camera_calib code where two variables were misplaced.

New feature 1 : Added wandb hyperparameters logging
Now the hyperparameters are logged by default in wandb. The config of the experiment can be viewed in wandb=>overwiev=>config (see image below)


  • Mean_std_norm no more uses resnet normalization and can be used for custom normalization :

Before, mean_std_norm used _resnet_mean_std by default, therefore you could only use resnet normalization. Now you can use any custom normalization.

import torch
import aloscene

x=torch.rand(3,600,600)
x=aloscene.Frame(x,mean_std=((0.333,0.333,0.333),(0.333,0.333,0.333)))
print("normalization de x ",x.normalization)
print("Mean_std de x",x.mean_std)

x=x.mean_std_norm(mean=(0.440,0.220,0.880), std=(0.333,0.333,0.333), name="my_norm")
print("normalization de x ",x.normalization)
print("Mean_std de x",x.mean_std)

Output :

normalization de x  255
Mean_std de x ((0.333, 0.333, 0.333), (0.333, 0.333, 0.333))
normalization de x  my_norm
Mean_std de x ((0.44, 0.22, 0.88), (0.333, 0.333, 0.333))
  • Conversion from mean_std_norm to minmax_sym and from minmax_sym to mean_std_norm
    Added this conversion which raised an Exception before
import torch
import aloscene

x=torch.rand(3,600,600)
x=aloscene.Frame(x,mean_std=((0.333,0.333,0.333),(0.333,0.333,0.333)))
x = x.norm_minmax_sym()
print("normalization de x ",x.normalization)
print("Mean_std de x",x.mean_std)
x = x.mean_std_norm(mean=(0.333,0.333,0.333), std=(0.333,0.333,0.333), name="custom")  # Exception raised
print("normalization de x ",x.normalization)
print("Mean_std de x",x.mean_std)

Output :

normalization de x  minmax_sym
Mean_std de x None
normalization de x  custom
Mean_std de x ((0.333, 0.333, 0.333), (0.333, 0.333, 0.333))

General description of your pull request with the list of new features and/or bugs.

  • Docker : New docker image with pytorch 1.13 support & pytorch lightning 1.9

  • Changed back transfrom to p=1.0 : transformation used to be apply automaticly on all frames. Last month we introduced a new parameter to randomly apply the transformation. The parameter was set to p=0.5 which might affect all the training pipeline. As of now we come back to p=1.0 as a default value (transformartion is always apply)


  • Fix bug 309 : Wrong display of 3d boxes on padded images
    The error was in the camera_calib code where two variables were misplaced.

What's Changed

New Contributors

Full Changelog: v0.4.0...v0.5.0-beta