Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update numpy version 2.0.2 #254

Merged
merged 8 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
python-version: [ "3.9", "3.10"]
python-version: [ "3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Lint with Ruff
run: |
pip install ruff
ruff .
ruff check .

- name: Mypy
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: python -m cibuildwheel --output-dir wheelhouse
# to supply options, put them in 'env', like:
env:
CIBW_SKIP: pp31* # problem with missing GCC 8.4
CIBW_SKIP: pp3* # problem with missing GCC 8.4

- uses: actions/upload-artifact@v3
with:
Expand All @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v2
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

Expand Down
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 .
2 changes: 1 addition & 1 deletion deodr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Martin de La Gorce. 2019.
"""

__version__ = "0.2.2"
__version__ = "0.2.3"

__all__ = [
"Scene2D",
Expand Down
2 changes: 1 addition & 1 deletion deodr/differentiable_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def world_to_camera(self, points_3d: np.ndarray) -> np.ndarray:
return points_3d.dot(self.extrinsic[:3, :3].T) + self.extrinsic[:3, 3]

def camera_to_world_mtx_4x4(self) -> np.ndarray:
return np.row_stack(
return np.vstack(
(
np.column_stack((self.extrinsic[:, :3].T, self.get_center())),
np.array((0, 0, 0, 1)),
Expand Down
5 changes: 3 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,8 @@
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 +48,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
4 changes: 2 additions & 2 deletions deodr/examples/eigen_faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def fun(points_deformed: np.ndarray, pca_coefs: np.ndarray) -> Tuple[float, Dict
for niter in range(nb_iter):
energy, grads = fun(**variables)
print(f"iter{niter} E={energy}")
for name in variables:
variables[name] = variables[name] - lambdas[name] * grads[name]
for name, variable in variables.items():
variables[name] = variable - lambdas[name] * grads[name]

variables["points_deformed"][on_border] = points[on_border]

Expand Down
11 changes: 6 additions & 5 deletions deodr/examples/rgb_image_hand_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
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 +37,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 Expand Up @@ -70,7 +71,7 @@ def run(
hand_fitter.reset()

background_color = np.median(
np.row_stack(
np.vstack(
(
hand_image[:10, :10, :].reshape(-1, 3),
hand_image[-10:, :10, :].reshape(-1, 3),
Expand Down
6 changes: 3 additions & 3 deletions deodr/examples/rgb_multiview_hand.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def run(
default_light_ambient = 0.6
# default_light = {'directional':np.array([0.0,0.0,0.0]),'ambient':np.array([0.6])}

euler_init = np.row_stack([np.array([0, yrot, 0]) for yrot in np.linspace(-0.5, 0.5, 3)])
euler_init = np.vstack([np.array([0, yrot, 0]) for yrot in np.linspace(-0.5, 0.5, 3)])

vertices = vertices - np.mean(vertices, axis=0)
t_init = np.array([0, -0.2, 0.2])
Expand Down Expand Up @@ -69,7 +69,7 @@ def run(

hand_image = hand_images[0]
background_color = np.median(
np.row_stack(
np.vstack(
(
hand_image[:10, :10, :].reshape(-1, 3),
hand_image[-10:, :10, :].reshape(-1, 3),
Expand Down Expand Up @@ -97,7 +97,7 @@ def run(
if display or save_images:
combined_image = np.column_stack(
(
np.row_stack(hand_images),
np.vstack(hand_images),
image,
np.tile(np.minimum(diff_image, 1)[:, :, None], (1, 1, 3)),
)
Expand Down
4 changes: 2 additions & 2 deletions deodr/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def read_obj(filename: str) -> Tuple[np.ndarray, np.ndarray]:
cleaned_fields.append(v)
faces.append(np.array(cleaned_fields))

faces_np = np.row_stack(faces)
vertices_np = np.row_stack(vertices)
faces_np = np.vstack(faces)
vertices_np = np.vstack(vertices)
return faces_np, vertices_np


Expand Down
2 changes: 2 additions & 0 deletions deodr/opengl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module to render deodr scenes using OpenGL using moderngl or pyrender."""

__all__ = ["moderngl", "pyrender"]

from deodr.opengl import moderngl, pyrender
2 changes: 1 addition & 1 deletion deodr/opengl/moderngl.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def set_texture(self, texture: np.ndarray) -> None:
# texture.build_mipmaps()

def set_camera(self, camera: Camera) -> None:
extrinsic = np.row_stack((camera.extrinsic, [0, 0, 0, 1]))
extrinsic = np.vstack((camera.extrinsic, [0, 0, 0, 1]))

intrinsic = Matrix44(
np.diag([1, -1, -1, 1]).dot(
Expand Down
4 changes: 4 additions & 0 deletions deodr/tensorflow/differentiable_renderer_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
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
2 changes: 1 addition & 1 deletion deodr/tensorflow/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

def scipy_sparse_matrix_to_tensorflow(x: scipy.sparse.spmatrix) -> tf.SparseTensor:
coo = x.tocoo()
indices = np.mat([coo.row, coo.col]).transpose()
indices = np.array([coo.row, coo.col]).transpose()
return tf.SparseTensor(indices, coo.data, coo.shape)
2 changes: 1 addition & 1 deletion deodr/triangulated_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def loop_subdivision(mesh: ColoredTriMesh, n_iter: int = 1) -> ColoredTriMesh:
mesh.adjacencies.faces_edges[:, 2] + mesh.nb_vertices,
)
)
new_faces = np.row_stack((faces1, faces2, faces3, faces4))
new_faces = np.vstack((faces1, faces2, faces3, faces4))
if mesh.uv is not None:
raise BaseException("Textured mesh not supported yet in subdivision.")
if mesh.vertices_colors is not None:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.22.0", "Cython>=0.29"]
requires = ["setuptools", "wheel", "numpy>=2.0.0", "Cython>=0.29"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -12,7 +12,7 @@ license = { text = "BSD" }
readme = "readme.md"

dependencies = [
"numpy>=1.22.0", "scipy"
"numpy>=2.0.0", "scipy"
]

[tool.black]
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


Loading
Loading