Skip to content

Commit

Permalink
Merge pull request #335 from Visual-Behavior/revert-332-torch_v2_unit…
Browse files Browse the repository at this point in the history
…test_setup

Revert "Fix unit test & setup.py"
  • Loading branch information
thibo73800 authored Mar 14, 2023
2 parents 2b7672b + 3d41b70 commit f084b9f
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 82 deletions.
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu20.04
#FROM nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04

ARG py=3.9
ARG pytorch=2.1.0.dev20230313+cu117
ARG torchvision=0.15.0.dev20230313+cu117
ARG torchaudio=2.0.0.dev20230313+cu117
ARG pytorch_lightning=1.9.3
ARG pytorch=1.13.1
ARG torchvision=0.14.1
ARG torchaudio=0.13.1
ARG pytorch_lightning=1.9.0
ARG pycyda=11.7

ENV TZ=Europe/Paris
Expand All @@ -30,11 +30,8 @@ ENV HOME /workspace
WORKDIR /workspace

# Pytorch & pytorch litning
#RUN conda install py pytorch-cuda=${pycuda} -c pytorch -c nvidia
RUN pip install --pre torch==${pytorch} torchvision==${torchvision} torchaudio==${torchaudio} --index-url https://download.pytorch.org/whl/nightly/cu117
RUN conda install pytorch==${pytorch} torchvision==${torchvision} torchaudio==${torchaudio} pytorch-cuda=${pycuda} -c pytorch -c nvidia
RUN pip install pytorch_lightning==${pytorch_lightning}

COPY requirements/requirements-torch2.1.txt /install/requirements-torch2.1.txt
RUN pip install -r /install/requirements-torch2.1.txt
COPY ./aloscene/utils /install/utils
RUN cd /install/utils/rotated_iou/cuda_op/; python setup.py install --user
COPY requirements-torch1.13.1.txt /install/requirements-torch1.13.1.txt
RUN pip install -r /install/requirements-torch1.13.1.txt
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ training pipelines with **augmented tensors**.
### Docker install

```
docker build -t aloception-oss:cuda-11.7-pytorch2.1.0-lightning1.9.3 .
docker build -t aloception-oss:cuda-11.3.1-pytorch1.13.1-lightning1.9.0 .
```

```
docker run --gpus all -it -v /YOUR/WORKSPACE/:/workspace --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix aloception-oss:cuda-11.7-pytorch2.1.0-lightning1.9.3
docker run --gpus all -it -v /YOUR/WORKSPACE/:/workspace --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix aloception-oss:cuda-11.3.1-pytorch1.13.1-lightning1.9.0
```

Or without building the image

```
docker run --gpus all -it -v /YOUR/WORKSPACE/:/workspace --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix visualbehaviorofficial/aloception-oss:cuda-11.7-pytorch2.1.0-lightning1.9.3
docker run --gpus all -it -v /YOUR/WORKSPACE/:/workspace --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix visualbehaviorofficial/aloception-oss:cuda-11.3.1-pytorch1.13.1-lightning1.9.0
```


Expand Down
2 changes: 1 addition & 1 deletion aloscene/depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def as_points3d(
target_names = tuple([n for n in self.names if n not in ("C", "H", "W")] + ["N", None])
if points is None:
y_points, x_points = torch.meshgrid(
torch.arange(self.H, device=self.device), torch.arange(self.W, device=self.device), indexing="ij"
torch.arange(self.H, device=self.device), torch.arange(self.W, device=self.device)
)
# Append batch & temporal dimensions
for _ in range(len(target_shape[:-1])):
Expand Down
8 changes: 3 additions & 5 deletions aloscene/tensors/spatial_augmented_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def _resize(self, size, interpolation=InterpolationMode.BILINEAR, **kwargs):
if ("N" in self.names and self.size("N") == 0) or ("C" in self.names and self.size("C") == 0):
shapes = list(self.shape)[:-2] + [h, w]
return self.rename(None).view(shapes).reset_names()
return F.resize(self.rename(None), (h, w), interpolation=interpolation, antialias=True).reset_names()
return F.resize(self.rename(None), (h, w), interpolation=interpolation).reset_names()

def _rotate(self, angle, center=None,**kwargs):
"""Rotate SpatialAugmentedTensor, but not its labels
Expand All @@ -548,7 +548,7 @@ def _rotate(self, angle, center=None,**kwargs):
), "rotation is not possible on an empty tensor"
return F.rotate(self.rename(None), angle,center=center).reset_names()

def _crop(self, H_crop: tuple, W_crop: tuple, warn_non_integer=True, **kwargs):
def _crop(self, H_crop: tuple, W_crop: tuple, **kwargs):
"""Crop the SpatialAugmentedTensor
Parameters
Expand All @@ -557,16 +557,14 @@ def _crop(self, H_crop: tuple, W_crop: tuple, warn_non_integer=True, **kwargs):
(start, end) between 0 and 1
W_crop: tuple
(start, end) between 0 and 1
warn_non_integer: bool
If True, warn if the crop is not integer
Returns
-------
cropped sa_tensor: aloscene.SpatialAugmentedTensor
cropped SpatialAugmentedTensor
"""

H_crop, W_crop = self._relative_to_absolute_hs_ws(H_crop, W_crop, assert_integer=False, warn_non_integer=warn_non_integer)
H_crop, W_crop = self._relative_to_absolute_hs_ws(H_crop, W_crop, assert_integer=False, warn_non_integer=True)
hmin, hmax = H_crop
wmin, wmax = W_crop
slices = self.get_slices({"H": slice(hmin, hmax), "W": slice(wmin, wmax)})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Metadata-Version: 2.1
Metadata-Version: 1.0
Name: sort-vertices
Version: 0.0.0
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

UNKNOWN

File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions requirements/requirements-torch2.1.txt

This file was deleted.

47 changes: 20 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,32 @@
setup(
name='aloception',
author='Visual Behavior',
version='0.5.1',
version='0.3.0',
description='Aloception is a set of package for computer vision: aloscene, alodataset, alonet.',
packages=find_packages(include=['aloscene', 'alodataset', 'alonet']),
url='https://visualbehavior.ai/',
download_url='https://github.com/Visual-Behavior/aloception-oss',
install_requires=[
'pycocotools==2.0.2',
'PyYAML==5.4.1',
'chardet==4.0.0',
'idna==2.10',

'scipy==1.10.0',

'more_itertools==8.8.0',
'requests==2.25.1',
'opencv-python==4.7.0.68',

'python-dateutil==2.8.2',
'urllib3==1.26.6',

'protobuf==4.21.12',
'wandb==0.13.9',

'matplotlib==3.5.3',
'more-itertools==8.8.0', # required for alodataset waymo
'onnx==1.12.0',
'onnx_graphsurgeon==0.0.1.dev5',
'onnxsim==0.4.8',
'opencv-python==4.5.3.56'
'Pillow==9.2.0',
'pycocotools==2.0.2', # required for alodataset coco
'pytorch_lightning==1.4.1',
'pytorch_quantization==0.0.1.dev5',
'Requests==2.28.1',
'scipy==1.4.1', # required for alonet/detr/matcher
'setuptools==63.4.1',
'tensorflow==2.10.0', # required for alodataset/prepare/waymo_converter
'tensorrt==0.0.1.dev5',
'torchvision==0.13.1',
'tqdm==4.62.3',
'captum==0.4.0',

'setuptools==59.5.0',

'numpy==1.23.5',

'pytest==7.2.2',
'Image==1.5.33'
],
'ts==0.5.1',
'wandb==0.12.2',
'waymo_open_dataset==1.0.1'],
setup_requires=['numpy', 'torch', 'nvidia-pyindex', 'pycuda'],
license_files=['LICENSE'],
keywords=['artificial intelligence', 'computer vision'],
Expand Down
5 changes: 0 additions & 5 deletions unittest/test_augmented_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,3 @@ def test_batch_list_intersection_unmergeable_child():
assert len(f.flow) == 2
assert f.flow[0].shape == (2, 10, 10)
assert f.flow[1] is None

if __name__ == "__main__":
test_batch_list_intersection_property()
test_batch_list_intersection_mergeable_child()
test_batch_list_intersection_unmergeable_child()
2 changes: 1 addition & 1 deletion unittest/test_oriented_boxes_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import aloscene
from aloscene import OrientedBoxes2D

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
device = torch.device("cpu")


def tensor_equal(tensor1, tensor2, threshold=1e-4):
Expand Down
7 changes: 2 additions & 5 deletions unittest/test_points2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ def test_crop_abs():
image = np.zeros((3, 843, 1500))
corners = [[298, 105], [1250, 105], [298, 705], [1250, 705]]
frame = aloscene.Frame(image)
labels = aloscene.Labels([0, 1, 2, 3], labels_names=["corners0", "corners1", "corners2", "corners3"])
labels = aloscene.Labels([0, 0, 0, 0], labels_names=["corners"])
corners = aloscene.Points2D(
corners, points_format="xy", frame_size=(frame.H, frame.W), absolute=True, labels=labels
)

frame.append_points2d(corners)

frame = frame.crop(H_crop=(0.0, 0.5), W_crop=(0.0, 0.5), warn_non_integer=False)

frame = frame.crop(H_crop=(0.0, 0.5), W_crop=(0.0, 0.5))
assert torch.allclose(frame.points2d[0].as_tensor(), corners[0].as_tensor())
assert np.allclose(frame.points2d.frame_size[0], frame.HW[0])
assert np.allclose(frame.points2d.frame_size[1], frame.HW[1])
Expand Down
7 changes: 4 additions & 3 deletions unittest/test_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def _test_disp_depth_points3d(depth, height, width, resize=True):
)

d = depth.resize((height * 2, width * 2))
v = depth.resize((height * 2, width * 2)).as_disp()#.resize((height, width)).as_depth()

v = depth.resize((height * 2, width * 2)).as_disp().resize((height, width)).as_depth()

assert torch.allclose(
depth.as_tensor(),
Expand Down Expand Up @@ -122,5 +123,5 @@ def test_disp_depth_points3d_projection4():

if __name__ == "__main__":
test_disp_depth_points3d_projection1()
#test_disp_depth_points3d_projection2()
#test_disp_depth_points3d_projection4()
test_disp_depth_points3d_projection2()
test_disp_depth_points3d_projection4()

0 comments on commit f084b9f

Please sign in to comment.