From dcc2544dd6e199f38f80eb07011574cbcff89960 Mon Sep 17 00:00:00 2001 From: Hana Joo Date: Wed, 1 Jul 2026 16:16:50 -0700 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 941349352 --- .../datasets/modelnet40/modelnet40.py | 4 +-- tensorflow_graphics/datasets/pix3d/pix3d.py | 4 +-- .../datasets/shapenet/shapenet.py | 6 ++--- .../geometry/convolution/graph_convolution.py | 10 +++---- .../geometry/convolution/graph_pooling.py | 6 ++--- .../geometry/convolution/utils.py | 10 +++---- .../as_conformal_as_possible.py | 2 +- .../geometry/representation/mesh/normals.py | 8 +++--- .../geometry/representation/mesh/sampler.py | 12 ++++----- .../transformation/tests/test_helpers.py | 2 +- .../image/color_space/linear_rgb.py | 2 +- tensorflow_graphics/image/color_space/srgb.py | 2 +- tensorflow_graphics/image/matting.py | 10 +++---- tensorflow_graphics/image/pyramid.py | 10 +++---- tensorflow_graphics/image/transformer.py | 6 ++--- tensorflow_graphics/io/exr.py | 4 +-- .../math/optimizer/levenberg_marquardt.py | 4 +-- tensorflow_graphics/nn/layer/pointnet.py | 24 ++++++++--------- .../nn/loss/chamfer_distance.py | 2 +- .../nn/loss/hausdorff_distance.py | 2 +- .../projects/pointnet/train.py | 10 +++---- .../losses/cross_entropy_loss.py | 2 +- .../models/centernet_vid.py | 2 +- .../networks/custom_blocks.py | 10 +++---- .../points_to_3Dobjects/networks/hourglass.py | 14 +++++----- .../points_to_3Dobjects/utils/evaluator.py | 12 ++++----- .../projects/points_to_3Dobjects/utils/io.py | 4 +-- .../points_to_3Dobjects/utils/plot.py | 14 +++++----- .../projects/radiance_fields/data_loaders.py | 4 +-- .../projects/radiance_fields/nerf/layers.py | 2 +- .../projects/radiance_fields/nerf/model.py | 22 ++++++++-------- .../sharf/appearance_net/model.py | 26 +++++++++---------- .../sharf/geometry_net/layers.py | 8 +++--- .../sharf/geometry_net/model.py | 26 +++++++++---------- .../projects/radiance_fields/utils.py | 2 +- .../rendering/camera/orthographic.py | 6 ++--- .../rendering/camera/perspective.py | 18 ++++++------- .../camera/quadratic_radial_distortion.py | 6 ++--- .../kernels/rasterization_backend.py | 4 +-- .../rendering/light/point_light.py | 2 +- tensorflow_graphics/rendering/opengl/math.py | 16 ++++++------ .../rendering/opengl/rasterization_backend.py | 2 +- .../tests/rasterization_test_utils.py | 2 +- .../rendering/texture/mipmap.py | 18 ++++++------- .../rendering/texture/texture_map.py | 2 +- .../rendering/triangle_rasterizer.py | 2 +- 46 files changed, 183 insertions(+), 183 deletions(-) diff --git a/tensorflow_graphics/datasets/modelnet40/modelnet40.py b/tensorflow_graphics/datasets/modelnet40/modelnet40.py index bd958b6a1..fe9fba589 100644 --- a/tensorflow_graphics/datasets/modelnet40/modelnet40.py +++ b/tensorflow_graphics/datasets/modelnet40/modelnet40.py @@ -80,13 +80,13 @@ def _split_generators(self, download_manager): # Note: VALIDATION split was not provided by the authors return [ tfds.core.SplitGenerator( - name=tfds.Split.TRAIN, + name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute] gen_kwargs=dict( filename_list_path=os.path.join( extracted_path, 'modelnet40_ply_hdf5_2048/train_files.txt'),)), tfds.core.SplitGenerator( - name=tfds.Split.TEST, + name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute] gen_kwargs=dict( filename_list_path=os.path.join( extracted_path, diff --git a/tensorflow_graphics/datasets/pix3d/pix3d.py b/tensorflow_graphics/datasets/pix3d/pix3d.py index f5a83547a..89fee61a9 100644 --- a/tensorflow_graphics/datasets/pix3d/pix3d.py +++ b/tensorflow_graphics/datasets/pix3d/pix3d.py @@ -148,14 +148,14 @@ def _split_generators(self, dl_manager): return [ tfds.core.SplitGenerator( - name=tfds.Split.TRAIN, + name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute] gen_kwargs={ 'samples_directory': pix3d_dir, 'split_file': self.TRAIN_SPLIT_IDX }, ), tfds.core.SplitGenerator( - name=tfds.Split.TEST, + name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute] gen_kwargs={ 'samples_directory': pix3d_dir, 'split_file': self.TEST_SPLIT_IDX diff --git a/tensorflow_graphics/datasets/shapenet/shapenet.py b/tensorflow_graphics/datasets/shapenet/shapenet.py index 50bb1bc22..5f6d04c0e 100644 --- a/tensorflow_graphics/datasets/shapenet/shapenet.py +++ b/tensorflow_graphics/datasets/shapenet/shapenet.py @@ -122,21 +122,21 @@ def split_generators(self, dl_manager, dataset_builder): return [ tfds.core.SplitGenerator( - name=tfds.Split.TRAIN, + name=tfds.Split.TRAIN, # pyrefly: ignore[missing-attribute] gen_kwargs={ 'base_dir': dl_manager.manual_dir, 'models': model_items['train'] }, ), tfds.core.SplitGenerator( - name=tfds.Split.TEST, + name=tfds.Split.TEST, # pyrefly: ignore[missing-attribute] gen_kwargs={ 'base_dir': dl_manager.manual_dir, 'models': model_items['test'] }, ), tfds.core.SplitGenerator( - name=tfds.Split.VALIDATION, + name=tfds.Split.VALIDATION, # pyrefly: ignore[missing-attribute] gen_kwargs={ 'base_dir': dl_manager.manual_dir, 'models': model_items['val'] diff --git a/tensorflow_graphics/geometry/convolution/graph_convolution.py b/tensorflow_graphics/geometry/convolution/graph_convolution.py index c1a74985c..e54203884 100644 --- a/tensorflow_graphics/geometry/convolution/graph_convolution.py +++ b/tensorflow_graphics/geometry/convolution/graph_convolution.py @@ -18,7 +18,7 @@ from __future__ import print_function from typing import Any, Callable, Dict -from six.moves import zip +from six.moves import zip # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.geometry.convolution import utils @@ -96,7 +96,7 @@ def feature_steered_convolution( ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) neighbors = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=neighbors) if sizes is not None: @@ -157,7 +157,7 @@ def feature_steered_convolution( y_i_m.append(tf.matmul(p_sum, w_m)) y_out = tf.add_n(inputs=y_i_m) + tf.reshape(var_b, [1, -1]) if data_ndims > 2: - y_out = unflatten(y_out) + y_out = unflatten(y_out) # pyrefly: ignore[unbound-name] return y_out @@ -239,7 +239,7 @@ def edge_convolution_template( ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) neighbors = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=neighbors) if sizes is not None: @@ -286,7 +286,7 @@ def edge_convolution_template( tf.compat.dimension_value(edge_features.shape[-1])))) if data_ndims > 2: - features = unflatten(features) + features = unflatten(features) # pyrefly: ignore[unbound-name] return features diff --git a/tensorflow_graphics/geometry/convolution/graph_pooling.py b/tensorflow_graphics/geometry/convolution/graph_pooling.py index d93a6f1d3..ace3dab23 100644 --- a/tensorflow_graphics/geometry/convolution/graph_pooling.py +++ b/tensorflow_graphics/geometry/convolution/graph_pooling.py @@ -74,7 +74,7 @@ def pool(data: type_alias.TensorLike, ValueError: if `algorithm` is invalid. """ # pyformat: enable - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) pool_map = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=pool_map) if sizes is not None: @@ -161,7 +161,7 @@ def unpool(data: type_alias.TensorLike, ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) pool_map = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=pool_map) if sizes is not None: @@ -253,7 +253,7 @@ def upsample_transposed_convolution( ValueError: if the input dimensions are invalid. """ # pyformat: enable - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) pool_map = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=pool_map) if sizes is not None: diff --git a/tensorflow_graphics/geometry/convolution/utils.py b/tensorflow_graphics/geometry/convolution/utils.py index 25ec9f233..88616b194 100644 --- a/tensorflow_graphics/geometry/convolution/utils.py +++ b/tensorflow_graphics/geometry/convolution/utils.py @@ -249,7 +249,7 @@ def flatten_batch_to_2d(data: type_alias.TensorLike, Raises: ValueError: if the input tensor dimensions are invalid. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) if sizes is not None: sizes = tf.convert_to_tensor(value=sizes) @@ -272,7 +272,7 @@ def flatten_batch_to_2d(data: type_alias.TensorLike, def unflatten(flat, name="utils_unflatten"): """Invert flatten_batch_to_2d.""" - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] flat = tf.convert_to_tensor(value=flat) output_shape = tf.concat((data_shape[:-1], tf.shape(input=flat)[-1:]), axis=0) @@ -288,7 +288,7 @@ def unflatten(flat, name="utils_unflatten"): def unflatten(flat, name="utils_unflatten"): """Invert flatten_batch_to_2d.""" - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] flat = tf.convert_to_tensor(value=flat) output_shape = tf.concat((data_shape[:-1], tf.shape(input=flat)[-1:]), axis=0) @@ -362,7 +362,7 @@ def unflatten_2d_to_batch(data: type_alias.TensorLike, Returns: A tensor with shape `[A1, A2, ..., max_rows, D2]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.convert_to_tensor(value=data) sizes = tf.convert_to_tensor(value=sizes) if max_rows is None: @@ -418,7 +418,7 @@ def convert_to_block_diag_2d(data: tf.sparse.SparseTensor, TypeError: if the input types are invalid. ValueError: if the input dimensions are invalid. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] data = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=data) if sizes is not None: sizes = tf.convert_to_tensor(value=sizes) diff --git a/tensorflow_graphics/geometry/deformation_energy/as_conformal_as_possible.py b/tensorflow_graphics/geometry/deformation_energy/as_conformal_as_possible.py index 20aa3f416..c72e2d493 100644 --- a/tensorflow_graphics/geometry/deformation_energy/as_conformal_as_possible.py +++ b/tensorflow_graphics/geometry/deformation_energy/as_conformal_as_possible.py @@ -95,7 +95,7 @@ def energy(vertices_rest_pose: type_alias.TensorLike, ValueError: if the shape of `vertices_rest_pose`, `vertices_deformed_pose`, `quaternions`, `edges`, `vertex_weight`, or `edge_weight` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertices_rest_pose = tf.convert_to_tensor(value=vertices_rest_pose) vertices_deformed_pose = tf.convert_to_tensor(value=vertices_deformed_pose) quaternions = tf.convert_to_tensor(value=quaternions) diff --git a/tensorflow_graphics/geometry/representation/mesh/normals.py b/tensorflow_graphics/geometry/representation/mesh/normals.py index 693293dca..9d8a2919f 100644 --- a/tensorflow_graphics/geometry/representation/mesh/normals.py +++ b/tensorflow_graphics/geometry/representation/mesh/normals.py @@ -19,7 +19,7 @@ import numpy as np -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.geometry.representation import triangle @@ -54,7 +54,7 @@ def gather_faces(vertices: type_alias.TensorLike, Raises: ValueError: If the shape of `vertices` or `indices` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertices = tf.convert_to_tensor(value=vertices) indices = tf.convert_to_tensor(value=indices) @@ -109,7 +109,7 @@ def face_normals(faces: type_alias.TensorLike, Raises: ValueError: If the shape of `vertices`, `faces` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] faces = tf.convert_to_tensor(value=faces) shape.check_static( @@ -158,7 +158,7 @@ def vertex_normals( Raises: ValueError: If the shape of `vertices`, `indices` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertices = tf.convert_to_tensor(value=vertices) indices = tf.convert_to_tensor(value=indices) diff --git a/tensorflow_graphics/geometry/representation/mesh/sampler.py b/tensorflow_graphics/geometry/representation/mesh/sampler.py index 91fc85cbc..75c03c877 100644 --- a/tensorflow_graphics/geometry/representation/mesh/sampler.py +++ b/tensorflow_graphics/geometry/representation/mesh/sampler.py @@ -75,7 +75,7 @@ def triangle_area(vertex0: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 1]`, where the last dimension represents the triangle areas. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertex0 = tf.convert_to_tensor(value=vertex0) vertex1 = tf.convert_to_tensor(value=vertex1) vertex2 = tf.convert_to_tensor(value=vertex2) @@ -116,7 +116,7 @@ def _random_categorical_sample( Returns: A `sample_dtype` tensor of shape `[A1, ..., An, num_samples]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] asserts.assert_all_above(weights, 0) logits = tf.math.log(weights) num_faces = tf.shape(input=logits)[-1] @@ -168,7 +168,7 @@ def generate_random_face_indices( An `int32` tensor of shape `[A1, ..., An, num_samples]` denoting sampled face indices. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] num_samples = tf.convert_to_tensor(value=num_samples) face_weights = tf.convert_to_tensor(value=face_weights) shape.check_static( @@ -222,7 +222,7 @@ def generate_random_barycentric_coordinates( """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] sample_shape = tf.convert_to_tensor(value=sample_shape) shape.check_static( tensor=sample_shape, tensor_name="sample_shape", has_rank=1) @@ -279,7 +279,7 @@ def weighted_random_sample_triangle_mesh( where D is dimensionality of each sampled point. sample_face_indices: A `int` tensor of shape `[A1, ..., An, num_samples]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] faces = tf.convert_to_tensor(value=faces) vertex_attributes = tf.convert_to_tensor(value=vertex_attributes) face_weights = tf.convert_to_tensor(value=face_weights) @@ -369,7 +369,7 @@ def area_weighted_random_sample_triangle_mesh( where D is dimensionality of each sampled point. sample_face_indices: A `int` tensor of shape `[A1, ..., An, num_samples]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] faces = tf.convert_to_tensor(value=faces) vertex_attributes = tf.convert_to_tensor(value=vertex_attributes) num_samples = tf.convert_to_tensor(value=num_samples) diff --git a/tensorflow_graphics/geometry/transformation/tests/test_helpers.py b/tensorflow_graphics/geometry/transformation/tests/test_helpers.py index 86b200d1c..83e7197c2 100644 --- a/tensorflow_graphics/geometry/transformation/tests/test_helpers.py +++ b/tensorflow_graphics/geometry/transformation/tests/test_helpers.py @@ -22,7 +22,7 @@ import numpy as np from scipy import stats -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow.compat.v2 as tf from tensorflow_graphics.geometry.transformation import axis_angle diff --git a/tensorflow_graphics/image/color_space/linear_rgb.py b/tensorflow_graphics/image/color_space/linear_rgb.py index f9524e0e7..5eb1879dd 100644 --- a/tensorflow_graphics/image/color_space/linear_rgb.py +++ b/tensorflow_graphics/image/color_space/linear_rgb.py @@ -51,7 +51,7 @@ def from_srgb(srgb: type_alias.TensorLike, A tensor of shape `[A_1, ..., A_n, 3]`, where the last dimension represents RGB values in linear color space. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] srgb = tf.convert_to_tensor(value=srgb) shape.check_static( diff --git a/tensorflow_graphics/image/color_space/srgb.py b/tensorflow_graphics/image/color_space/srgb.py index 8c5552edf..14754435b 100644 --- a/tensorflow_graphics/image/color_space/srgb.py +++ b/tensorflow_graphics/image/color_space/srgb.py @@ -58,7 +58,7 @@ def from_linear_rgb(linear_rgb: type_alias.TensorLike, A tensor of shape `[A_1, ..., A_n, 3]`, where the last dimension represents sRGB values. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] linear_rgb = tf.convert_to_tensor(value=linear_rgb) shape.check_static( diff --git a/tensorflow_graphics/image/matting.py b/tensorflow_graphics/image/matting.py index 1554b7cd9..0d98cda0f 100644 --- a/tensorflow_graphics/image/matting.py +++ b/tensorflow_graphics/image/matting.py @@ -131,7 +131,7 @@ def build_matrices(image: type_alias.TensorLike, Raises: ValueError: If `image` is not of rank 4. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image) eps = tf.constant(value=eps, dtype=image.dtype) @@ -192,7 +192,7 @@ def linear_coefficients(matte: type_alias.TensorLike, of rank 4. If `pseudo_inverse` is not of rank 5. If `B` is different between `matte` and `pseudo_inverse`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matte = tf.convert_to_tensor(value=matte) pseudo_inverse = tf.convert_to_tensor(value=pseudo_inverse) @@ -216,7 +216,7 @@ def linear_coefficients(matte: type_alias.TensorLike, width = tf.shape(input=matte)[2] + size - 1 coeffs = tf.image.resize_with_crop_or_pad(coeffs, height, width) ones = tf.image.resize_with_crop_or_pad(ones, height, width) - coeffs = _image_average(coeffs, size) / _image_average(ones, size) + coeffs = _image_average(coeffs, size) / _image_average(ones, size) # pyrefly: ignore[unsupported-operation] return tf.split(coeffs, (-1, 1), axis=-1) @@ -246,7 +246,7 @@ def loss(matte: type_alias.TensorLike, same size. If `laplacian` is not of rank 5. If `B` is different between `matte` and `laplacian`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matte = tf.convert_to_tensor(value=matte) laplacian = tf.convert_to_tensor(value=laplacian) @@ -287,7 +287,7 @@ def reconstruct(image: type_alias.TensorLike, the last dimension of `coeff_add` is not 1. If the batch dimensions of `image`, `coeff_mul`, and `coeff_add` do not match. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image) coeff_mul = tf.convert_to_tensor(value=coeff_mul) coeff_add = tf.convert_to_tensor(value=coeff_add) diff --git a/tensorflow_graphics/image/pyramid.py b/tensorflow_graphics/image/pyramid.py index ce088fd0c..cffc4da22 100644 --- a/tensorflow_graphics/image/pyramid.py +++ b/tensorflow_graphics/image/pyramid.py @@ -24,7 +24,7 @@ from typing import Callable, List, Optional, Tuple import numpy as np -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.util import export_api @@ -170,7 +170,7 @@ def downsample(image: type_alias.TensorLike, Raises: ValueError: If the shape of `image` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image) shape.check_static(tensor=image, tensor_name="image", has_rank=4) @@ -196,7 +196,7 @@ def merge(levels: List[type_alias.TensorLike], Raises: ValueError: If the shape of the elements of `levels` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] levels = [tf.convert_to_tensor(value=level) for level in levels] for index, level in enumerate(levels): @@ -229,7 +229,7 @@ def split(image: type_alias.TensorLike, Raises: ValueError: If the shape of `image` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image) shape.check_static(tensor=image, tensor_name="image", has_rank=4) @@ -264,7 +264,7 @@ def upsample(image: type_alias.TensorLike, Raises: ValueError: If the shape of `image` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image) shape.check_static(tensor=image, tensor_name="image", has_rank=4) diff --git a/tensorflow_graphics/image/transformer.py b/tensorflow_graphics/image/transformer.py index 94fef63e1..d27f994a7 100644 --- a/tensorflow_graphics/image/transformer.py +++ b/tensorflow_graphics/image/transformer.py @@ -16,7 +16,7 @@ import enum from typing import Optional -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_addons import image as tfa_image @@ -77,7 +77,7 @@ def sample(image: type_alias.TensorLike, ValueError: If `image` has rank != 4. If `warp` has rank < 2 or its last dimension is not 2. If `image` and `warp` batch dimension does not match. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image, name="image") warp = tf.convert_to_tensor(value=warp, name="warp") @@ -154,7 +154,7 @@ def perspective_transform( its last two dimensions are not 3. If `image` and `transform_matrix` batch dimension does not match. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] image = tf.convert_to_tensor(value=image, name="image") transform_matrix = tf.convert_to_tensor( value=transform_matrix, name="transform_matrix") diff --git a/tensorflow_graphics/io/exr.py b/tensorflow_graphics/io/exr.py index 9885a3af8..dbaf28400 100644 --- a/tensorflow_graphics/io/exr.py +++ b/tensorflow_graphics/io/exr.py @@ -22,8 +22,8 @@ import Imath import numpy as np import OpenEXR -from six.moves import range -from six.moves import zip +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] +from six.moves import zip # pyrefly: ignore[missing-source-for-stubs] _np_to_exr = { diff --git a/tensorflow_graphics/math/optimizer/levenberg_marquardt.py b/tensorflow_graphics/math/optimizer/levenberg_marquardt.py index 71cd5ed8e..c0ea4ebe6 100644 --- a/tensorflow_graphics/math/optimizer/levenberg_marquardt.py +++ b/tensorflow_graphics/math/optimizer/levenberg_marquardt.py @@ -35,7 +35,7 @@ from __future__ import division from __future__ import print_function -from six.moves import zip +from six.moves import zip # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.util import export_api @@ -151,7 +151,7 @@ def print_output(iteration, objective_value, *variables): """ if not isinstance(variables, (tuple, list)): variables = [variables] - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] if not isinstance(residuals, (tuple, list)): residuals = [residuals] if isinstance(residuals, tuple): diff --git a/tensorflow_graphics/nn/layer/pointnet.py b/tensorflow_graphics/nn/layer/pointnet.py index ca9a2ea81..2a034e707 100644 --- a/tensorflow_graphics/nn/layer/pointnet.py +++ b/tensorflow_graphics/nn/layer/pointnet.py @@ -117,7 +117,7 @@ def call(self, Returns: Tensor with shape `[B, C]`. """ - return tf.nn.relu(self.bn(self.dense(inputs), training)) + return tf.nn.relu(self.bn(self.dense(inputs), training)) # pyrefly: ignore[not-callable] class VanillaEncoder(tf.keras.layers.Layer): @@ -157,11 +157,11 @@ def call(self, Tensor with shape `[B, N, C=1024]` """ x = tf.expand_dims(inputs, axis=2) # [B,N,1,D] - x = self.conv1(x, training) # [B,N,1,64] - x = self.conv2(x, training) # [B,N,1,64] - x = self.conv3(x, training) # [B,N,1,64] - x = self.conv4(x, training) # [B,N,1,128] - x = self.conv5(x, training) # [B,N,1,1024] + x = self.conv1(x, training) # [B,N,1,64] # pyrefly: ignore[not-callable] + x = self.conv2(x, training) # [B,N,1,64] # pyrefly: ignore[not-callable] + x = self.conv3(x, training) # [B,N,1,64] # pyrefly: ignore[not-callable] + x = self.conv4(x, training) # [B,N,1,128] # pyrefly: ignore[not-callable] + x = self.conv5(x, training) # [B,N,1,1024] # pyrefly: ignore[not-callable] x = tf.math.reduce_max(input_tensor=x, axis=1) # [B,1,1024] return tf.squeeze(x) # [B,1024] @@ -203,10 +203,10 @@ def call(self, Returns: Tensor with shape `[B,num_classes]` """ - x = self.dense1(inputs, training) # [B,512] - x = self.dense2(x, training) # [B,256] - x = self.dropout(x, training) # [B,256] - return self.dense3(x) # [B,num_classes) + x = self.dense1(inputs, training) # [B,512] # pyrefly: ignore[not-callable] + x = self.dense2(x, training) # [B,256] # pyrefly: ignore[not-callable] + x = self.dropout(x, training) # [B,256] # pyrefly: ignore[not-callable] + return self.dense3(x) # [B,num_classes) # pyrefly: ignore[not-callable] class PointNetVanillaClassifier(tf.keras.layers.Layer): @@ -240,8 +240,8 @@ def call(self, Returns: Tensor with shape `[B,num_classes]` """ - features = self.encoder(points, training) # (B,1024) - logits = self.classifier(features, training) # (B,num_classes) + features = self.encoder(points, training) # (B,1024) # pyrefly: ignore[not-callable] + logits = self.classifier(features, training) # (B,num_classes) # pyrefly: ignore[not-callable] return logits @staticmethod diff --git a/tensorflow_graphics/nn/loss/chamfer_distance.py b/tensorflow_graphics/nn/loss/chamfer_distance.py index e22e40425..a3c606e9f 100644 --- a/tensorflow_graphics/nn/loss/chamfer_distance.py +++ b/tensorflow_graphics/nn/loss/chamfer_distance.py @@ -58,7 +58,7 @@ def evaluate(point_set_a: type_alias.TensorLike, Raises: ValueError: if the shape of `point_set_a`, `point_set_b` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_set_a = tf.convert_to_tensor(value=point_set_a) point_set_b = tf.convert_to_tensor(value=point_set_b) diff --git a/tensorflow_graphics/nn/loss/hausdorff_distance.py b/tensorflow_graphics/nn/loss/hausdorff_distance.py index 279f1bbbd..de4f3a1db 100644 --- a/tensorflow_graphics/nn/loss/hausdorff_distance.py +++ b/tensorflow_graphics/nn/loss/hausdorff_distance.py @@ -55,7 +55,7 @@ def evaluate(point_set_a: type_alias.TensorLike, Raises: ValueError: if the shape of `point_set_a`, `point_set_b` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_set_a = tf.convert_to_tensor(value=point_set_a) point_set_b = tf.convert_to_tensor(value=point_set_b) diff --git a/tensorflow_graphics/projects/pointnet/train.py b/tensorflow_graphics/projects/pointnet/train.py index def08dcb2..6fdca6fae 100644 --- a/tensorflow_graphics/projects/pointnet/train.py +++ b/tensorflow_graphics/projects/pointnet/train.py @@ -99,7 +99,7 @@ def train(example): # --- report rate in summaries if FLAGS.lr_decay and step % FLAGS.tb_every == 0: - tf.summary.scalar(name="learning_rate", data=lr_scheduler(step), step=step) + tf.summary.scalar(name="learning_rate", data=lr_scheduler(step), step=step) # pyrefly: ignore[not-callable] # ------------------------------------------------------------------------------ @@ -111,18 +111,18 @@ def evaluate(): """Identify the best accuracy reached during training.""" step = optimizer.iterations.numpy() if "best_accuracy" not in evaluate.__dict__: - evaluate.best_accuracy = 0 + evaluate.best_accuracy = 0 # pyrefly: ignore[missing-attribute] if step % FLAGS.ev_every != 0: - return evaluate.best_accuracy + return evaluate.best_accuracy # pyrefly: ignore[missing-attribute] aggregator = tf.keras.metrics.SparseCategoricalAccuracy() for example in ds_test: points, labels = example["points"], example["label"] logits = model(points, training=False) aggregator.update_state(labels, logits) accuracy = aggregator.result() - evaluate.best_accuracy = max(accuracy, evaluate.best_accuracy) + evaluate.best_accuracy = max(accuracy, evaluate.best_accuracy) # pyrefly: ignore[missing-attribute] tf.summary.scalar(name="accuracy_test", data=accuracy, step=step) - return evaluate.best_accuracy + return evaluate.best_accuracy # pyrefly: ignore[missing-attribute] # ------------------------------------------------------------------------------ diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/losses/cross_entropy_loss.py b/tensorflow_graphics/projects/points_to_3Dobjects/losses/cross_entropy_loss.py index 66bcb5788..fe1b245d0 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/losses/cross_entropy_loss.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/losses/cross_entropy_loss.py @@ -35,7 +35,7 @@ def __call__(self, prediction, gt, sample): cross_entropy_loss = tf.keras.losses.CategoricalCrossentropy( from_logits=True, label_smoothing=self.label_smoothing, reduction=tf.keras.losses.Reduction.NONE) - loss = cross_entropy_loss(gt, predicted_centers) + loss = cross_entropy_loss(gt, predicted_centers) # pyrefly: ignore[not-callable] else: gt = tf.cast(sample['shapes_soft'], dtype=tf.float32) gt = tf.reshape(gt, [b, -1, num_classes]) diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/models/centernet_vid.py b/tensorflow_graphics/projects/points_to_3Dobjects/models/centernet_vid.py index 171a62895..62820452d 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/models/centernet_vid.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/models/centernet_vid.py @@ -427,7 +427,7 @@ def train_sample(self, sample): network_gradients, gradients_norm = tf.clip_by_global_norm( network_gradients, clip_norm=self.clip_norm) - self.optimizer.apply_gradients( + self.optimizer.apply_gradients( # pyrefly: ignore[missing-attribute] zip(network_gradients, self.network.trainable_variables)) additional_logs = {'total_loss': total_loss, diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/networks/custom_blocks.py b/tensorflow_graphics/projects/points_to_3Dobjects/networks/custom_blocks.py index daee0215b..ff07f764c 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/networks/custom_blocks.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/networks/custom_blocks.py @@ -107,10 +107,10 @@ def __init__(self, self.relu = IdentityLayer(name='identity') def call(self, inputs, **kwargs): - x = self.pad(inputs) + x = self.pad(inputs) # pyrefly: ignore[not-callable] x = self.conv(x) x = self.norm(x) - x = self.relu(x) + x = self.relu(x) # pyrefly: ignore[not-callable] return x @@ -159,9 +159,9 @@ def __init__(self, self.relu = tf.keras.layers.ReLU(name='relu') def call(self, inputs, **kwargs): - x = self.conv_block(inputs) + x = self.conv_block(inputs) # pyrefly: ignore[not-callable] x = self.conv(x) x = self.norm(x) - x_skip = self.skip(inputs) - x = self.relu(x + x_skip) + x_skip = self.skip(inputs) # pyrefly: ignore[not-callable] + x = self.relu(x + x_skip) # pyrefly: ignore[not-callable] return x diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/networks/hourglass.py b/tensorflow_graphics/projects/points_to_3Dobjects/networks/hourglass.py index bb629e70d..e2d7c0395 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/networks/hourglass.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/networks/hourglass.py @@ -132,10 +132,10 @@ def call(self, inputs, **kwargs): for block in self.encoder_block2: x_s = block(x_s) for block in self.inner_block: - x_s = block(x_s) + x_s = block(x_s) # pyrefly: ignore[not-callable] for block in self.decoder_block: x_s = block(x_s) - x_s = self.upsample(x_s) + x_s = self.upsample(x_s) # pyrefly: ignore[not-callable] merge_features = self.merge_features([x, x_s]) return merge_features @@ -169,9 +169,9 @@ def __init__(self, self.out_conv.bias_initializer = tf.keras.initializers.constant(-2.19) def call(self, inputs, **kwargs): - x = self.pad(inputs) + x = self.pad(inputs) # pyrefly: ignore[not-callable] x = self.conv(x) - x_ = self.relu(x) + x_ = self.relu(x) # pyrefly: ignore[not-callable] x = self.out_conv(x_) if self.return_features: out_x = {self.name: x, f'{self.name}_features': x_} @@ -210,7 +210,7 @@ def call(self, inputs, **kwargs): for block in self._encoder: x = block(x) x = tf.reduce_mean(x, axis=[1, 2]) - return {self.name: self._logits(x)} + return {self.name: self._logits(x)} # pyrefly: ignore[not-callable] class Hourglass(tf.keras.Model): @@ -289,7 +289,7 @@ def __init__(self, def call(self, inputs, training=None, mask=None): - x = self.downsample_input(inputs) + x = self.downsample_input(inputs) # pyrefly: ignore[not-callable] output = [] for ii in range(self.number_hourglasses): x_hourglass = self.hourglass_network[ii](x) @@ -311,7 +311,7 @@ def call(self, inputs, training=None, mask=None): if ii < self.number_hourglasses - 1: x = self.intermediate_conv1[ii](x) + self.intermediate_conv2[ii](x_out) - x = self.intermediate_relu(x) + x = self.intermediate_relu(x) # pyrefly: ignore[not-callable] intermediate_residual = self.intermediate_residual[ii] x = intermediate_residual(x) diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/utils/evaluator.py b/tensorflow_graphics/projects/points_to_3Dobjects/utils/evaluator.py index 911909e45..1bcff9aa3 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/utils/evaluator.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/utils/evaluator.py @@ -213,7 +213,7 @@ def update(self, labeled_sdfs, labeled_classes, labeled_poses, self.resolution, self.resolution]) inter = tf.transpose(tf.reduce_max(inter, axis=a)) - im = axs[fig_obj_count, mtype * 2 + 0].matshow(inter.numpy()) + im = axs[fig_obj_count, mtype * 2 + 0].matshow(inter.numpy()) # pyrefly: ignore[unbound-name] plt.colorbar(im, ax=axs[fig_obj_count, mtype * 2 + 0]) print(mtype, fig_obj_count, 0) @@ -265,7 +265,7 @@ def evaluate(self): """Evaluate.""" if self.slave: data = self.iou_per_class - with gfile.Open(self.path, 'wb') as file: + with gfile.Open(self.path, 'wb') as file: # pyrefly: ignore[no-matching-overload] pickle.dump(data, file) logging.info(file) return @@ -343,7 +343,7 @@ def update(self, labeled_sdfs, labeled_classes, labeled_poses, self.resolution, self.resolution]) inter = tf.transpose(tf.reduce_max(inter, axis=a)) - im = axs[fig_obj_count, 0].matshow(inter.numpy()) + im = axs[fig_obj_count, 0].matshow(inter.numpy()) # pyrefly: ignore[unbound-name] plt.colorbar(im, ax=axs[fig_obj_count, 0]) values = tf.math.sign(tf.nn.relu(interpolated + self.tol)) @@ -378,7 +378,7 @@ def evaluate(self): data = {'collisions': self.collisions, 'intersections': self.intersections, 'ious': self.ious} - with gfile.Open(self.path, 'wb') as file: + with gfile.Open(self.path, 'wb') as file: # pyrefly: ignore[no-matching-overload] pickle.dump(data, file) logging.info(file) return @@ -542,7 +542,7 @@ def _eval_detections_per_class(self, pred, gt, ovthresh=0.25): jmax = j if ovmax > ovthresh: - if not r['det'][jmax]: + if not r['det'][jmax]: # pyrefly: ignore[unbound-name] tp[d] = 1. r['det'][jmax] = 1 else: @@ -696,7 +696,7 @@ def add_detections(self, sample, detections): iou_mean, iou_min = metric.update( labeled_sdfs, labeled_classes, labeled_poses, predicted_sdfs, - predicted_classes, predicted_poses, sample['dot']) + predicted_classes, predicted_poses, sample['dot']) # pyrefly: ignore[bad-argument-count] result_dict['iou_mean'] = iou_mean result_dict['iou_min'] = iou_min elif isinstance(metric, CollisionMetric): diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/utils/io.py b/tensorflow_graphics/projects/points_to_3Dobjects/utils/io.py index dcf3e2db9..7db8dd4f1 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/utils/io.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/utils/io.py @@ -29,7 +29,7 @@ def tfrecords_to_dataset_tf2(tfrecords_pattern, buffer_size=5000, shuffle=True): """Generates a TF Dataset from a rio pattern.""" - with tf.name_scope('Input/'): + with tf.name_scope('Input/'): # pyrefly: ignore[bad-instantiation] tfrecords_pattern = expand_rio_pattern(tfrecords_pattern) dataset = tf.data.Dataset.list_files(tfrecords_pattern, shuffle=shuffle) dataset = dataset.interleave(tf.data.TFRecordDataset, cycle_length=16) @@ -46,7 +46,7 @@ def get_dataset(tfrecords_pattern, shuffle=True, cycle_length=16): """Generates a TF Dataset from a rio pattern.""" - with tf.name_scope('Input/'): + with tf.name_scope('Input/'): # pyrefly: ignore[bad-instantiation] tfrecords_pattern = expand_rio_pattern(tfrecords_pattern) dataset = tf.data.Dataset.list_files(tfrecords_pattern, shuffle=shuffle) dataset = dataset.interleave(tf.data.TFRecordDataset, diff --git a/tensorflow_graphics/projects/points_to_3Dobjects/utils/plot.py b/tensorflow_graphics/projects/points_to_3Dobjects/utils/plot.py index dce137090..d33359d03 100644 --- a/tensorflow_graphics/projects/points_to_3Dobjects/utils/plot.py +++ b/tensorflow_graphics/projects/points_to_3Dobjects/utils/plot.py @@ -332,22 +332,22 @@ def plot_detections( for j, [boxes, style] in enumerate([[labels, 'dashed'], [detections, 'solid']]): - number_of_boxes = boxes['detection_boxes'].shape[0] + number_of_boxes = boxes['detection_boxes'].shape[0] # pyrefly: ignore[bad-index] for i in range(number_of_boxes): predicted_pose_obj2world = np.eye(4) - predicted_pose_obj2world[0:3, 0:3] = boxes['rotations_3d'][i].numpy() - predicted_pose_obj2world[0:3, 3] = boxes['center3d'][i].numpy() - draw_bounding_box_3d(boxes['size3d'].numpy()[i], + predicted_pose_obj2world[0:3, 0:3] = boxes['rotations_3d'][i].numpy() # pyrefly: ignore[bad-index] + predicted_pose_obj2world[0:3, 3] = boxes['center3d'][i].numpy() # pyrefly: ignore[bad-index] + draw_bounding_box_3d(boxes['size3d'].numpy()[i], # pyrefly: ignore[bad-index] predicted_pose_obj2world, intrinsics, pose_world2camera, linestyle=style) if j == 0: - if isinstance(boxes['detection_boxes'], tf.Tensor): - boxes['detection_boxes'] = boxes['detection_boxes'].numpy() + if isinstance(boxes['detection_boxes'], tf.Tensor): # pyrefly: ignore[bad-index] + boxes['detection_boxes'] = boxes['detection_boxes'].numpy() # pyrefly: ignore[unsupported-operation] # if isinstance(boxes['detection_classes'], tf.Tensor): # boxes['detection_classes'] = boxes['detection_classes'].numpy() - x_min, y_min, x_max, y_max = boxes['detection_boxes'][i] + x_min, y_min, x_max, y_max = boxes['detection_boxes'][i] # pyrefly: ignore[bad-index] # plt.text(x_min, y_min, # class_id_to_name[int(boxes['detection_classes'][i])]) plt.plot([x_min, x_max, x_max, x_min, x_min], diff --git a/tensorflow_graphics/projects/radiance_fields/data_loaders.py b/tensorflow_graphics/projects/radiance_fields/data_loaders.py index cdd5c0ccc..9a2583f06 100644 --- a/tensorflow_graphics/projects/radiance_fields/data_loaders.py +++ b/tensorflow_graphics/projects/radiance_fields/data_loaders.py @@ -74,7 +74,7 @@ def load_synthetic_nerf_dataset(dataset_dir: str = DATASETDIR, transform_matrix = np.array(frame['transform_matrix']) transform_matrices[i, :, :] = transform_matrix - dataset = tf.data.Dataset.from_tensor_slices((images, + dataset = tf.data.Dataset.from_tensor_slices((images, # pyrefly: ignore[bad-argument-type] focals, principal_points, transform_matrices)) @@ -269,7 +269,7 @@ def load_srn_dataset(tfrecords_dir: str, A tf.data.Dataset containing the images and camera parameters. """ tfrecords_pattern = tfrecords_dir + '/*.tfrecord' - dataset = tf.data.Dataset.list_files(tfrecords_pattern, + dataset = tf.data.Dataset.list_files(tfrecords_pattern, # pyrefly: ignore[bad-argument-type] shuffle=True, seed=seed) dataset = dataset.interleave(tf.data.TFRecordDataset, cycle_length=16) diff --git a/tensorflow_graphics/projects/radiance_fields/nerf/layers.py b/tensorflow_graphics/projects/radiance_fields/nerf/layers.py index 5cce76cb2..091865374 100644 --- a/tensorflow_graphics/projects/radiance_fields/nerf/layers.py +++ b/tensorflow_graphics/projects/radiance_fields/nerf/layers.py @@ -21,7 +21,7 @@ def dense_block(tensor, n_filters, n_layers=2, activation=layers.ReLU(), seed=None): initializer = tf.keras.initializers.GlorotUniform(seed=seed) for _ in range(n_layers): - tensor = layers.Dense(n_filters, + tensor = layers.Dense(n_filters, # pyrefly: ignore[not-callable] activation=activation, kernel_initializer=initializer)(tensor) return tensor diff --git a/tensorflow_graphics/projects/radiance_fields/nerf/model.py b/tensorflow_graphics/projects/radiance_fields/nerf/model.py index 6953d8851..f2ad27d30 100644 --- a/tensorflow_graphics/projects/radiance_fields/nerf/model.py +++ b/tensorflow_graphics/projects/radiance_fields/nerf/model.py @@ -109,17 +109,17 @@ def init_checkpoint(self, checkpoint_dir, checkpoint=None): def load_checkpoint(self, checkpoint=None): """Load checkpoints.""" - latest_checkpoint = self.manager.latest_checkpoint if checkpoint is None else checkpoint + latest_checkpoint = self.manager.latest_checkpoint if checkpoint is None else checkpoint # pyrefly: ignore[missing-attribute] if latest_checkpoint is not None: logging.info("Checkpoint %s restored", latest_checkpoint) - _ = self.checkpoint.restore(latest_checkpoint).expect_partial() + _ = self.checkpoint.restore(latest_checkpoint).expect_partial() # pyrefly: ignore[missing-attribute] else: logging.warning("No checkpoint was restored.") def get_model(self): """Constructs the original NeRF network as a keras model.""" - with tf.name_scope("Network/"): + with tf.name_scope("Network/"): # pyrefly: ignore[bad-instantiation] xyz_features = tf.keras.layers.Input(shape=[None, None, self.xyz_dim]) dir_features = tf.keras.layers.Input(shape=[None, None, self.dir_dim]) @@ -129,11 +129,11 @@ def get_model(self): feat1 = nerf_layers.dense_block(feat0, n_filters=self.n_filters, n_layers=4) - feat2 = tf.keras.layers.Dense(self.n_filters)(feat1) - density = tf.keras.layers.Dense(1)(feat2) + feat2 = tf.keras.layers.Dense(self.n_filters)(feat1) # pyrefly: ignore[not-callable] + density = tf.keras.layers.Dense(1)(feat2) # pyrefly: ignore[not-callable] feat2_dir = tf.keras.layers.concatenate([feat2, dir_features], -1) - feat3 = tf.keras.layers.Dense(self.n_filters//2)(feat2_dir) - rgb = tf.keras.layers.Dense(3)(feat3) + feat3 = tf.keras.layers.Dense(self.n_filters//2)(feat2_dir) # pyrefly: ignore[not-callable] + rgb = tf.keras.layers.Dense(3)(feat3) # pyrefly: ignore[not-callable] rgb_density = tf.keras.layers.concatenate([rgb, density], -1) return tf.keras.Model(inputs=[xyz_features, dir_features], outputs=[rgb_density]) @@ -208,7 +208,7 @@ def inference(self, r_org, r_dir): n_samples=self.ray_samples_coarse, strategy=self.coarse_sampling_strategy) posenc_features = self.prepare_positional_encoding(ray_points_coarse, r_dir) - rgb_density = self.coarse_model(posenc_features) + rgb_density = self.coarse_model(posenc_features) # pyrefly: ignore[not-callable] rgb_coarse, weights_coarse = self.render_network_output(rgb_density, ray_points_coarse) depth_map_coarse = tf.reduce_sum(weights_coarse * z_vals_coarse, axis=-1) @@ -221,7 +221,7 @@ def inference(self, r_org, r_dir): n_samples=self.ray_samples_fine, combine_z_values=True) posenc_features = self.prepare_positional_encoding(ray_points_fine, r_dir) - rgb_density = self.fine_model(posenc_features) + rgb_density = self.fine_model(posenc_features) # pyrefly: ignore[not-callable] rgb_fine, weights_fine = self.render_network_output(rgb_density, ray_points_fine) depth_map_fine = tf.reduce_sum(weights_fine * z_vals_fine, axis=-1) @@ -248,9 +248,9 @@ def train_step(self, r_org, r_dir, gt_rgb): rgb_fine_loss = utils.l2_loss(rgb_fine, gt_rgb) total_loss = rgb_coarse_loss + rgb_fine_loss gradients = tape.gradient(total_loss, self.network_vars) - self.optimizer_network.apply_gradients(zip(gradients, self.network_vars)) + self.optimizer_network.apply_gradients(zip(gradients, self.network_vars)) # pyrefly: ignore[bad-argument-type, missing-attribute] - with self.summary_writer.as_default(): + with self.summary_writer.as_default(): # pyrefly: ignore[missing-attribute] step = self.global_step tf.summary.scalar("total_loss", total_loss, step=step) tf.summary.scalar("rgb_loss_f", rgb_fine_loss, step=step) diff --git a/tensorflow_graphics/projects/radiance_fields/sharf/appearance_net/model.py b/tensorflow_graphics/projects/radiance_fields/sharf/appearance_net/model.py index 6fbb15405..fc1ae717d 100644 --- a/tensorflow_graphics/projects/radiance_fields/sharf/appearance_net/model.py +++ b/tensorflow_graphics/projects/radiance_fields/sharf/appearance_net/model.py @@ -131,26 +131,26 @@ def init_checkpoint(self, checkpoint_dir, checkpoint=None): def load_checkpoint(self, checkpoint=None): """Load checkpoints.""" if checkpoint is None: - latest_checkpoint = self.manager.latest_checkpoint + latest_checkpoint = self.manager.latest_checkpoint # pyrefly: ignore[missing-attribute] else: latest_checkpoint = checkpoint if latest_checkpoint is not None: logging.info("Checkpoint %s restored", latest_checkpoint) - _ = self.checkpoint.restore(latest_checkpoint).expect_partial() - for a, b in zip(self.model_backup.variables, - self.model.variables): + _ = self.checkpoint.restore(latest_checkpoint).expect_partial() # pyrefly: ignore[missing-attribute] + for a, b in zip(self.model_backup.variables, # pyrefly: ignore[missing-attribute] + self.model.variables): # pyrefly: ignore[missing-attribute] a.assign(b) else: logging.warning("No checkpoint was restored.") def reset_models(self): - for a, b in zip(self.model.variables, - self.model_backup.variables): + for a, b in zip(self.model.variables, # pyrefly: ignore[missing-attribute] + self.model_backup.variables): # pyrefly: ignore[missing-attribute] a.assign(b) def get_model(self): """NeRF-based network.""" - with tf.name_scope("Network/"): + with tf.name_scope("Network/"): # pyrefly: ignore[bad-instantiation] input_features = tf.keras.layers.Input(shape=[self.input_dim]) feat0 = nerf_layers.concat_block(input_features, n_filters=self.n_filters, @@ -158,7 +158,7 @@ def get_model(self): feat1 = nerf_layers.dense_block(feat0, n_filters=self.n_filters, n_layers=3) - rgb_density = tf.keras.layers.Dense(4)(feat1) + rgb_density = tf.keras.layers.Dense(4)(feat1) # pyrefly: ignore[not-callable] return tf.keras.Model(inputs=[input_features], outputs=[rgb_density]) @tf.function @@ -251,7 +251,7 @@ def inference(self, r_org, r_dir, latent_code, alpha], axis=-1) net_inputs = tf.reshape(net_inputs, [-1, tf.shape(net_inputs)[-1]]) # Run the network and render ----------------------------------------------- - rgb_density = self.model([net_inputs]) + rgb_density = self.model([net_inputs]) # pyrefly: ignore[not-callable] rgb_fine, _ = self.render_network_output(rgb_density, ray_points_fine) return rgb_fine @@ -288,9 +288,9 @@ def train_step(self, r_org, r_dir, shape_index, rgb_fine_loss = utils.l2_loss(rgb_fine, gt_rgb) total_loss = rgb_fine_loss gradients = tape.gradient(total_loss, - self.network_vars + [self.latent_code_vars]) - self.optimizer_network.apply_gradients( - zip(gradients[:len(self.network_vars)], self.network_vars)) - self.optimizer_latent.apply_gradients( + self.network_vars + [self.latent_code_vars]) # pyrefly: ignore[unsupported-operation] + self.optimizer_network.apply_gradients( # pyrefly: ignore[missing-attribute] + zip(gradients[:len(self.network_vars)], self.network_vars)) # pyrefly: ignore[bad-argument-type] + self.optimizer_latent.apply_gradients( # pyrefly: ignore[missing-attribute] zip(gradients[len(self.network_vars):], [self.latent_code_vars])) return total_loss diff --git a/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/layers.py b/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/layers.py index bea8e191d..e513b9cbc 100644 --- a/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/layers.py +++ b/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/layers.py @@ -36,9 +36,9 @@ def conv_block_3d(tensor, num_filters, size, strides, tensor = norm_layer(tensor, normalization) if relu: - tensor = tf.keras.layers.LeakyReLU(alpha=alpha_lrelu)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=alpha_lrelu)(tensor) # pyrefly: ignore[not-callable] if dropout: - tensor = tf.keras.layers.Dropout(rate)(tensor) + tensor = tf.keras.layers.Dropout(rate)(tensor) # pyrefly: ignore[not-callable] return tensor @@ -56,8 +56,8 @@ def conv_t_block_3d(tensor, num_filters, size, strides, tensor = norm_layer(tensor, normalization) if relu: - tensor = tf.keras.layers.LeakyReLU(alpha=alpha_lrelu)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=alpha_lrelu)(tensor) # pyrefly: ignore[not-callable] if dropout: - tensor = tf.keras.layers.Dropout(rate)(tensor) + tensor = tf.keras.layers.Dropout(rate)(tensor) # pyrefly: ignore[not-callable] return tensor diff --git a/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/model.py b/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/model.py index 00ce6b103..2e16a247f 100644 --- a/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/model.py +++ b/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/model.py @@ -64,17 +64,17 @@ def get_model(self): norm3d = self.norm3d activation = self.fc_activation - with tf.name_scope('Network/'): + with tf.name_scope('Network/'): # pyrefly: ignore[bad-instantiation] latent_code = tf.keras.layers.Input(shape=(self.latent_code_dim,)) - with tf.name_scope('FC_layers'): - fc0 = tf.keras.layers.Dense(fc_channels, + with tf.name_scope('FC_layers'): # pyrefly: ignore[bad-instantiation] + fc0 = tf.keras.layers.Dense(fc_channels, # pyrefly: ignore[not-callable] activation=activation)(latent_code) - fc1 = tf.keras.layers.Dense(fc_channels, activation=activation)(fc0) - fc2 = tf.keras.layers.Dense(fc_channels, activation=activation)(fc1) - fc2_as_volume = tf.keras.layers.Reshape((1, 1, 1, fc_channels))(fc2) + fc1 = tf.keras.layers.Dense(fc_channels, activation=activation)(fc0) # pyrefly: ignore[not-callable] + fc2 = tf.keras.layers.Dense(fc_channels, activation=activation)(fc1) # pyrefly: ignore[not-callable] + fc2_as_volume = tf.keras.layers.Reshape((1, 1, 1, fc_channels))(fc2) # pyrefly: ignore[not-callable] - with tf.name_scope('GLO_VoxelDecoder'): + with tf.name_scope('GLO_VoxelDecoder'): # pyrefly: ignore[bad-instantiation] decoder_1 = geometry_layers.conv_t_block_3d(fc2_as_volume, num_filters=32, size=self.conv_size, @@ -151,20 +151,20 @@ def init_checkpoint(self, checkpoint_dir, checkpoint=None): def load_checkpoint(self, checkpoint=None): """Load checkpoints.""" if checkpoint is None: - latest_checkpoint = self.manager.latest_checkpoint + latest_checkpoint = self.manager.latest_checkpoint # pyrefly: ignore[missing-attribute] else: latest_checkpoint = checkpoint if latest_checkpoint is not None: logging.info('Checkpoint %s restored', latest_checkpoint) - _ = self.checkpoint.restore(latest_checkpoint).expect_partial() - for a, b in zip(self.model_backup.variables, - self.model.variables): + _ = self.checkpoint.restore(latest_checkpoint).expect_partial() # pyrefly: ignore[missing-attribute] + for a, b in zip(self.model_backup.variables, # pyrefly: ignore[missing-attribute] + self.model.variables): # pyrefly: ignore[missing-attribute] a.assign(b) else: logging.warning('No checkpoint was restored.') def reset_models(self): - for a, b in zip(self.model.variables, - self.model_backup.variables): + for a, b in zip(self.model.variables, # pyrefly: ignore[missing-attribute] + self.model_backup.variables): # pyrefly: ignore[missing-attribute] a.assign(b) diff --git a/tensorflow_graphics/projects/radiance_fields/utils.py b/tensorflow_graphics/projects/radiance_fields/utils.py index 1246b28f0..c85e9b909 100644 --- a/tensorflow_graphics/projects/radiance_fields/utils.py +++ b/tensorflow_graphics/projects/radiance_fields/utils.py @@ -65,7 +65,7 @@ def change_coordinate_system(points3d, Returns: [type]: [description] """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] points3d = tf.convert_to_tensor(points3d) rotation = tf.convert_to_tensor(rotations) scale = tf.convert_to_tensor(scale) diff --git a/tensorflow_graphics/rendering/camera/orthographic.py b/tensorflow_graphics/rendering/camera/orthographic.py index 44f6ab0a0..05d17159f 100644 --- a/tensorflow_graphics/rendering/camera/orthographic.py +++ b/tensorflow_graphics/rendering/camera/orthographic.py @@ -59,7 +59,7 @@ def project(point_3d: type_alias.TensorLike, Raises: ValueError: If the shape of `point_3d` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_3d = tf.convert_to_tensor(value=point_3d) shape.check_static( @@ -97,7 +97,7 @@ def ray(point_2d: type_alias.TensorLike, Raises: ValueError: If the shape of `point_2d` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_2d = tf.convert_to_tensor(value=point_2d) shape.check_static( @@ -139,7 +139,7 @@ def unproject(point_2d: type_alias.TensorLike, Raises: ValueError: If the shape of `point_2d`, `depth` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_2d = tf.convert_to_tensor(value=point_2d) depth = tf.convert_to_tensor(value=depth) diff --git a/tensorflow_graphics/rendering/camera/perspective.py b/tensorflow_graphics/rendering/camera/perspective.py index 0efc0648f..e7368beb7 100644 --- a/tensorflow_graphics/rendering/camera/perspective.py +++ b/tensorflow_graphics/rendering/camera/perspective.py @@ -82,7 +82,7 @@ def parameters_from_right_handed( represent the near and far clipping planes used to construct `projection_matrix`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] projection_matrix = tf.convert_to_tensor(value=projection_matrix) shape.check_static( @@ -141,7 +141,7 @@ def right_handed(vertical_field_of_view: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 4, 4]`, containing matrices of right handed perspective-view frustum. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertical_field_of_view = tf.convert_to_tensor(value=vertical_field_of_view) aspect_ratio = tf.convert_to_tensor(value=aspect_ratio) near = tf.convert_to_tensor(value=near) @@ -220,7 +220,7 @@ def intrinsics_from_matrix( Raises: ValueError: If the shape of `matrix` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -281,7 +281,7 @@ def matrix_from_intrinsics( ValueError: If the shape of `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) skew = tf.convert_to_tensor(value=skew) @@ -363,7 +363,7 @@ def project(point_3d: type_alias.TensorLike, ValueError: If the shape of `point_3d`, `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_3d = tf.convert_to_tensor(value=point_3d) focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -427,7 +427,7 @@ def ray(point_2d: type_alias.TensorLike, ValueError: If the shape of `point_2d`, `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_2d = tf.convert_to_tensor(value=point_2d) focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -478,7 +478,7 @@ def random_rays(focal: tf.Tensor, A tensor of shape `[A1, ..., An, M, 3]` with the ray directions and a tensor of shape `[A1, ..., An, M, 2]` with the pixel x, y locations. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -531,7 +531,7 @@ def random_patches(focal: tf.Tensor, ray directions in 3D passing from the M*N pixels of the patch and a tensor of shape `[A1, ..., An, M*N, 2]` with the pixel x, y locations. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] focal = tf.convert_to_tensor(value=focal) principal_point = tf.convert_to_tensor(value=principal_point) @@ -619,7 +619,7 @@ def unproject(point_2d: type_alias.TensorLike, ValueError: If the shape of `point_2d`, `depth`, `focal`, or `principal_point` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_2d = tf.convert_to_tensor(value=point_2d) depth = tf.convert_to_tensor(value=depth) focal = tf.convert_to_tensor(value=focal) diff --git a/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py b/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py index 8b54a6e4f..9d3e9900e 100644 --- a/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py +++ b/tensorflow_graphics/rendering/camera/quadratic_radial_distortion.py @@ -33,7 +33,7 @@ from __future__ import print_function from typing import Tuple -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.util import asserts @@ -79,7 +79,7 @@ def distortion_factor( monotonically increasing. Wherever `overflow_mask` is True, `distortion_factor`'s value is meaningless. """ - with tf.name_scope(name,): + with tf.name_scope(name,): # pyrefly: ignore[bad-instantiation] squared_radius = tf.convert_to_tensor(value=squared_radius) distortion_coefficient = tf.convert_to_tensor(value=distortion_coefficient) @@ -154,7 +154,7 @@ def undistortion_factor( `undistortion_factor`'s value is meaningless. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] distorted_squared_radius = tf.convert_to_tensor( value=distorted_squared_radius) distortion_coefficient = tf.convert_to_tensor(value=distortion_coefficient) diff --git a/tensorflow_graphics/rendering/kernels/rasterization_backend.py b/tensorflow_graphics/rendering/kernels/rasterization_backend.py index ee58a7ecc..f1de5af91 100644 --- a/tensorflow_graphics/rendering/kernels/rasterization_backend.py +++ b/tensorflow_graphics/rendering/kernels/rasterization_backend.py @@ -20,7 +20,7 @@ import enum from typing import Tuple -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.rendering import framebuffer as fb @@ -85,7 +85,7 @@ def rasterize( The barycentric coordinates can be used to determine pixel validity instead. See framebuffer.py for a description of the Framebuffer fields. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertices = tf.convert_to_tensor(value=vertices) triangles = tf.convert_to_tensor(value=triangles) view_projection_matrices = tf.convert_to_tensor( diff --git a/tensorflow_graphics/rendering/light/point_light.py b/tensorflow_graphics/rendering/light/point_light.py index 307a2e215..85202ef66 100644 --- a/tensorflow_graphics/rendering/light/point_light.py +++ b/tensorflow_graphics/rendering/light/point_light.py @@ -90,7 +90,7 @@ def estimate_radiance( not supported. InvalidArgumentError: if 'surface_point_normal' is not normalized. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_light_radiance = tf.convert_to_tensor(value=point_light_radiance) point_light_position = tf.convert_to_tensor(value=point_light_position) surface_point_position = tf.convert_to_tensor(value=surface_point_position) diff --git a/tensorflow_graphics/rendering/opengl/math.py b/tensorflow_graphics/rendering/opengl/math.py index 975feb38f..c0c082302 100644 --- a/tensorflow_graphics/rendering/opengl/math.py +++ b/tensorflow_graphics/rendering/opengl/math.py @@ -55,7 +55,7 @@ def model_to_eye(point_model_space: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 3]`, containing `point_model_space` in eye coordinates. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_model_space = tf.convert_to_tensor(value=point_model_space) camera_position = tf.convert_to_tensor(value=camera_position) look_at_point = tf.convert_to_tensor(value=look_at_point) @@ -119,7 +119,7 @@ def eye_to_clip(point_eye_space: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 4]`, containing `point_eye_space` in homogeneous clip coordinates. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_eye_space = tf.convert_to_tensor(value=point_eye_space) vertical_field_of_view = tf.convert_to_tensor(value=vertical_field_of_view) aspect_ratio = tf.convert_to_tensor(value=aspect_ratio) @@ -177,7 +177,7 @@ def clip_to_ndc(point_clip_space: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 3]`, containing `point_clip_space` in normalized device coordinates. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_clip_space = tf.convert_to_tensor(value=point_clip_space) shape.check_static( @@ -227,7 +227,7 @@ def ndc_to_screen(point_ndc_space: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 3]`, containing `point_ndc_space` in screen coordinates. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_ndc_space = tf.convert_to_tensor(value=point_ndc_space) lower_left_corner = tf.convert_to_tensor(value=lower_left_corner) screen_dimensions = tf.convert_to_tensor(value=screen_dimensions) @@ -318,7 +318,7 @@ def model_to_screen( `point_model_space` in screen coordinates, and the second represents the 'w' component of `point_model_space` in clip space. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_model_space = tf.convert_to_tensor(value=point_model_space) model_to_eye_matrix = tf.convert_to_tensor(value=model_to_eye_matrix) perspective_matrix = tf.convert_to_tensor(value=perspective_matrix) @@ -406,7 +406,7 @@ def perspective_correct_barycentrics( A tensor of shape `[A1, ..., An, 3]`, containing perspective correct barycentric coordinates. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] pixel_position = tf.convert_to_tensor(value=pixel_position) triangle_vertices_model_space = tf.convert_to_tensor( value=triangle_vertices_model_space) @@ -464,7 +464,7 @@ def interpolate_attributes(attribute: type_alias.TensorLike, Returns: A tensor of shape `[A1, ..., An, B]`, containing interpolated attributes. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] attribute = tf.convert_to_tensor(value=attribute) barycentric = tf.convert_to_tensor(value=barycentric) @@ -527,7 +527,7 @@ def perspective_correct_interpolation( Returns: A tensor of shape `[A1, ..., An, B]`, containing interpolated attributes. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] barycentric = perspective_correct_barycentrics( triangle_vertices_model_space, pixel_position, model_to_eye_matrix, perspective_matrix, screen_dimensions, lower_left_corner) diff --git a/tensorflow_graphics/rendering/opengl/rasterization_backend.py b/tensorflow_graphics/rendering/opengl/rasterization_backend.py index 4ecc1f2ac..368fee739 100644 --- a/tensorflow_graphics/rendering/opengl/rasterization_backend.py +++ b/tensorflow_graphics/rendering/opengl/rasterization_backend.py @@ -144,7 +144,7 @@ def rasterize(vertices: type_alias.TensorLike, The barycentric coordinates can be used to determine pixel validity instead. See framebuffer.py for a description of the Framebuffer fields. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] if num_layers != 1: raise ValueError("OpenGL rasterizer only supports single layer.") diff --git a/tensorflow_graphics/rendering/tests/rasterization_test_utils.py b/tensorflow_graphics/rendering/tests/rasterization_test_utils.py index bb2de2ce2..6c3f4d252 100644 --- a/tensorflow_graphics/rendering/tests/rasterization_test_utils.py +++ b/tensorflow_graphics/rendering/tests/rasterization_test_utils.py @@ -43,7 +43,7 @@ def make_perspective_matrix(image_width=None, image_height=None): near_plane = (0.01,) far_plane = (10.0,) return perspective.right_handed(field_of_view, - (float(image_width) / float(image_height),), + (float(image_width) / float(image_height),), # pyrefly: ignore[bad-argument-type] near_plane, far_plane) diff --git a/tensorflow_graphics/rendering/texture/mipmap.py b/tensorflow_graphics/rendering/texture/mipmap.py index 9ec752ea8..e0d8c8ed7 100644 --- a/tensorflow_graphics/rendering/texture/mipmap.py +++ b/tensorflow_graphics/rendering/texture/mipmap.py @@ -34,7 +34,7 @@ from typing import Optional, Sequence, Text -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.rendering.texture import texture_map from tensorflow_graphics.util import export_api @@ -94,7 +94,7 @@ def map_texture(uv_map: tfg_type.TensorLike, ValueError: If texture_image is too small for the mipmap images to be constructed. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] if mipmap_images is None and texture_image is None: raise ValueError('Either texture_image or mipmap_images should be ' @@ -131,15 +131,15 @@ def map_texture(uv_map: tfg_type.TensorLike, texture_shape = texture_image.get_shape().as_list() texture_height, texture_width = texture_shape[-3:-1] - if (texture_height / 2**num_mipmap_levels < 1 or - texture_width / 2**num_mipmap_levels < 1): + if (texture_height / 2**num_mipmap_levels < 1 or # pyrefly: ignore[unsupported-operation] + texture_width / 2**num_mipmap_levels < 1): # pyrefly: ignore[unsupported-operation] raise ValueError('The size of texture_image ' f'({texture_height}, {texture_width}) ' 'is too small for the provided number of mipmap ' f'levels ({num_mipmap_levels}).') mipmap_images = [texture_image] - for idx in range(num_mipmap_levels - 1): + for idx in range(num_mipmap_levels - 1): # pyrefly: ignore[unsupported-operation] previous_size = mipmap_images[idx].shape.as_list() current_height = tf.floor(previous_size[0] / 2) current_width = tf.floor(previous_size[1] / 2) @@ -157,19 +157,19 @@ def map_texture(uv_map: tfg_type.TensorLike, max_derivative = tf.math.maximum( tf.reduce_max(input_tensor=tf.math.abs(ddx), axis=-1), tf.reduce_max(input_tensor=tf.math.abs(ddy), axis=-1)) - max_derivative = max_derivative * [texture_height, texture_width] + max_derivative = max_derivative * [texture_height, texture_width] # pyrefly: ignore[unbound-name] max_derivative = tf.math.maximum(max_derivative, 1.0) mipmap_level = tf.experimental.numpy.log2(max_derivative) mipmap_indices = tf.stack( (tf.math.floor(mipmap_level), tf.math.ceil(mipmap_level)), axis=-1) mipmap_level = mipmap_level - mipmap_indices[..., 0] - mipmap_indices = tf.clip_by_value(mipmap_indices, 0, num_mipmap_levels - 1) + mipmap_indices = tf.clip_by_value(mipmap_indices, 0, num_mipmap_levels - 1) # pyrefly: ignore[unsupported-operation] mipmap_indices = tf.cast(mipmap_indices, dtype=tf.int32) # Map texture for each level and stack the results mapped_texture_stack = [] - for mipmap_image in mipmap_images: + for mipmap_image in mipmap_images: # pyrefly: ignore[not-iterable] mapped_texture_stack.append( texture_map.map_texture( uv_map=uv_map, texture_image=mipmap_image, tiling=tiling)) @@ -194,7 +194,7 @@ def map_texture(uv_map: tfg_type.TensorLike, return tf.reshape( mapped_texture, - uv_batch_dimensions + [uv_height, uv_width, texture_shape[-1]]) + uv_batch_dimensions + [uv_height, uv_width, texture_shape[-1]]) # pyrefly: ignore[unbound-name] # API contains all public functions and classes. diff --git a/tensorflow_graphics/rendering/texture/texture_map.py b/tensorflow_graphics/rendering/texture/texture_map.py index 57b6fbc25..71ddae049 100644 --- a/tensorflow_graphics/rendering/texture/texture_map.py +++ b/tensorflow_graphics/rendering/texture/texture_map.py @@ -72,7 +72,7 @@ def map_texture(uv_map: tfg_type.TensorLike, A tensor of shape `[A1, ..., An, H, W, C]` containing the interpolated values. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] uv_map = tf.convert_to_tensor(value=uv_map, dtype=tf.float32) texture_image = tf.convert_to_tensor(value=texture_image, dtype=tf.float32) diff --git a/tensorflow_graphics/rendering/triangle_rasterizer.py b/tensorflow_graphics/rendering/triangle_rasterizer.py index cf15f3b2b..4aac8cff6 100644 --- a/tensorflow_graphics/rendering/triangle_rasterizer.py +++ b/tensorflow_graphics/rendering/triangle_rasterizer.py @@ -79,7 +79,7 @@ def rasterize( the dictionary contains perspective correct interpolated attributes of shape `[A1, ..., An, height, width, K]` per entry in the `attributes` dictionary. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vertices = tf.convert_to_tensor(value=vertices) triangles = tf.convert_to_tensor(value=triangles) view_projection_matrix = tf.convert_to_tensor(value=view_projection_matrix)