Skip to content

Commit

Permalink
update to numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin de La Gorce committed Oct 23, 2024
1 parent 57c13aa commit ac17886
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 35 deletions.
7 changes: 4 additions & 3 deletions create_venv.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
python.exe -m venv python_venv
.\python_venv\scripts\python.exe -m pip install --upgrade pip
.\python_venv\scripts\pip.exe install -r requirements.txt
.\python_venv\scripts\pip.exe install -e .
call %~dp0/python_venv/Scripts/activate.bat
pip install uv
uv pip sync requirements.txt
uv pip install -e .
4 changes: 2 additions & 2 deletions deodr/examples/depth_image_hand_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from deodr import ColoredTriMesh
from deodr.mesh_fitter import MeshDepthFitter
from deodr.pytorch import MeshDepthFitter as PytorchMeshDepthFitter
from deodr.tensorflow import MeshDepthFitter as TensorFlowMeshDepthFitter
# from deodr.tensorflow import MeshDepthFitter as TensorFlowMeshDepthFitter


def run(
Expand Down Expand Up @@ -47,7 +47,7 @@ def run(
mesh_depth_fitter_selector = {
"none": MeshDepthFitter,
"pytorch": PytorchMeshDepthFitter,
"tensorflow": TensorFlowMeshDepthFitter,
# "tensorflow": TensorFlowMeshDepthFitter,
}

hand_fitter: MeshDepthFitter = mesh_depth_fitter_selector[dl_library]( # type: ignore
Expand Down
8 changes: 4 additions & 4 deletions deodr/examples/rgb_image_hand_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from deodr.mesh_fitter import MeshRGBFitterWithPose
from deodr.meshlab_io import export_meshlab
from deodr.pytorch import MeshRGBFitterWithPose as PyTorchMeshRGBFitterWithPose
from deodr.tensorflow import (
MeshRGBFitterWithPose as TensorflowTorchMeshRGBFitterWithPose,
)
# from deodr.tensorflow import (
# MeshRGBFitterWithPose as TensorflowTorchMeshRGBFitterWithPose,
# )

DlLibraryType = Literal["pytorch", "tensorflow", "none"]

Expand All @@ -36,7 +36,7 @@ def run(
mesh_fitter_selector = {
"none": MeshRGBFitterWithPose,
"pytorch": PyTorchMeshRGBFitterWithPose,
"tensorflow": TensorflowTorchMeshRGBFitterWithPose,
# "tensorflow": TensorflowTorchMeshRGBFitterWithPose,
}

hand_image = imread(os.path.join(deodr.data_path, "hand.png")).astype(np.double) / 255
Expand Down
1 change: 1 addition & 0 deletions deodr/tensorflow/differentiable_renderer_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .. import differentiable_renderer_cython # type: ignore
from ..differentiable_renderer import Camera, Scene3D

raise NotImplementedError("Tensorflow support has been dropped starting from version 0.2.3 until tensorflow-intel support numpy 2.0")

class CameraTensorflow(Camera):
"""Tensorflow implementation of the camera class."""
Expand Down
26 changes: 26 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-f https://download.pytorch.org/whl/cu121

numpy>=2.0.2
scipy
Cython
scikit-learn
matplotlib
imageio
trimesh
opencv-python>=4.8
torch
torchvision
# tensorflow does not support numpy 2.0 yet https://github.com/tensorflow/tensorflow/issues/67291
# tensorflow
moderngl
pyrr
pyrender
pytest-xvfb

# devloppement
radon
pip-tools
mypy
ruff


177 changes: 154 additions & 23 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,154 @@
numpy
scipy
Cython
scikit-learn
matplotlib
imageio
trimesh
opencv-python
torch -f https://download.pytorch.org/whl/cu117
torchvision -f https://download.pytorch.org/whl/cu117
tensorflow
moderngl
pyrr
pyrender
pytest-xvfb

# devloppement
radon
pip-tools
mypy
ruff


# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt
build==1.2.2.post1
# via pip-tools
click==8.1.7
# via pip-tools
colorama==0.4.6
# via
# build
# click
# pytest
# radon
contourpy==1.3.0
# via matplotlib
cycler==0.12.1
# via matplotlib
cython==3.0.11
# via -r requirements.in
filelock==3.16.1
# via torch
fonttools==4.54.1
# via matplotlib
freetype-py==2.5.1
# via pyrender
fsspec==2024.10.0
# via torch
glcontext==3.0.0
# via moderngl
imageio==2.36.0
# via
# -r requirements.in
# pyrender
iniconfig==2.0.0
# via pytest
jinja2==3.1.4
# via torch
joblib==1.4.2
# via scikit-learn
kiwisolver==1.4.7
# via matplotlib
mando==0.7.1
# via radon
markupsafe==3.0.2
# via jinja2
matplotlib==3.9.2
# via -r requirements.in
moderngl==5.12.0
# via -r requirements.in
mpmath==1.3.0
# via sympy
multipledispatch==1.0.0
# via pyrr
mypy==1.13.0
# via -r requirements.in
mypy-extensions==1.0.0
# via mypy
networkx==3.4.2
# via
# pyrender
# torch
numpy==2.1.2
# via
# -r requirements.in
# contourpy
# imageio
# matplotlib
# opencv-python
# pyrender
# pyrr
# scikit-learn
# scipy
# torchvision
# trimesh
opencv-python==4.10.0.84
# via -r requirements.in
packaging==24.1
# via
# build
# matplotlib
# pytest
pillow==11.0.0
# via
# imageio
# matplotlib
# pyrender
# torchvision
pip==24.2
# via pip-tools
pip-tools==7.4.1
# via -r requirements.in
pluggy==1.5.0
# via pytest
pyglet==2.0.18
# via pyrender
pyopengl==3.1.0
# via pyrender
pyparsing==3.2.0
# via matplotlib
pyproject-hooks==1.2.0
# via
# build
# pip-tools
pyrender==0.1.45
# via -r requirements.in
pyrr==0.10.3
# via -r requirements.in
pytest==8.3.3
# via pytest-xvfb
pytest-xvfb==3.0.0
# via -r requirements.in
python-dateutil==2.9.0.post0
# via matplotlib
pyvirtualdisplay==3.0
# via pytest-xvfb
radon==6.0.1
# via -r requirements.in
ruff==0.7.0
# via -r requirements.in
scikit-learn==1.5.2
# via -r requirements.in
scipy==1.14.1
# via
# -r requirements.in
# pyrender
# scikit-learn
setuptools==75.2.0
# via
# pip-tools
# torch
six==1.16.0
# via
# mando
# pyrender
# python-dateutil
sympy==1.13.1
# via torch
threadpoolctl==3.5.0
# via scikit-learn
torch==2.5.0
# via
# -r requirements.in
# torchvision
torchvision==0.20.0
# via -r requirements.in
trimesh==4.5.1
# via
# -r requirements.in
# pyrender
typing-extensions==4.12.2
# via
# mypy
# torch
wheel==0.44.0
# via pip-tools
2 changes: 1 addition & 1 deletion requirements_build.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
numpy==2.0.2
cython==0.29.32
cython
5 changes: 4 additions & 1 deletion tests/test_depth_image_hand_fitting.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Test using depth image hand fitting."""

import numpy as np
import tensorflow as tf

from deodr.examples.depth_image_hand_fitting import run
import pytest


def test_depth_image_hand_fitting_pytorch() -> None:
Expand Down Expand Up @@ -42,7 +42,10 @@ def test_depth_image_hand_fitting_numpy() -> None:
assert np.any(np.abs(np.array(possible_results) - energies[49]) < 1e-5)


@pytest.mark.skip(reason="Tensorflow does nto support numpy 2.0 yet")
def test_depth_image_hand_fitting_tensorflow() -> None:
import tensorflow as tf

tf.config.set_visible_devices([], "GPU") # Running on CPU to get determinisic results

energies = run(
Expand Down
6 changes: 5 additions & 1 deletion tests/test_rgb_image_hand_fitting.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Test using rgb_image hand fitting."""

import numpy as np
import tensorflow as tf


from deodr.examples.rgb_image_hand_fitting import run
import pytest


def test_rgb_image_hand_fitting_pytorch() -> None:
Expand Down Expand Up @@ -49,7 +50,10 @@ def test_rgb_image_hand_fitting_numpy() -> None:
assert np.any(np.abs(np.array(possible_results) - energies[49]) < 1e-5)


@pytest.mark.skip(reason="Tensorflow does nto support numpy 2.0 yet")
def test_rgb_image_hand_fitting_tensorflow() -> None:
import tensorflow as tf

tf.config.set_visible_devices([], "GPU") # Running on CPU to get deterministic results

energies = run(
Expand Down

0 comments on commit ac17886

Please sign in to comment.