diff --git a/tensorflow_graphics/geometry/representation/grid.py b/tensorflow_graphics/geometry/representation/grid.py index c0d05cdf3..9d6676724 100644 --- a/tensorflow_graphics/geometry/representation/grid.py +++ b/tensorflow_graphics/geometry/representation/grid.py @@ -17,7 +17,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 @@ -98,7 +98,7 @@ def generate(starts, stops, nums, name="grid_generate"): axis and from -2.0 to 2.0 with 5 subdivisions for the y axis. This lead to a tensor of shape (3, 5, 2). """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] starts = tf.convert_to_tensor(value=starts) stops = tf.convert_to_tensor(value=stops) nums = tf.convert_to_tensor(value=nums) diff --git a/tensorflow_graphics/geometry/representation/point.py b/tensorflow_graphics/geometry/representation/point.py index 9fca99824..ad561b799 100644 --- a/tensorflow_graphics/geometry/representation/point.py +++ b/tensorflow_graphics/geometry/representation/point.py @@ -55,7 +55,7 @@ def distance_to_ray(point: type_alias.TensorLike, ValueError: If the shape of `point`, `origin`, or 'direction' is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) origin = tf.convert_to_tensor(value=origin) direction = tf.convert_to_tensor(value=direction) @@ -99,7 +99,7 @@ def project_to_ray(point: type_alias.TensorLike, ValueError: If the shape of `point`, `origin`, or 'direction' is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) origin = tf.convert_to_tensor(value=origin) direction = tf.convert_to_tensor(value=direction) diff --git a/tensorflow_graphics/geometry/representation/ray.py b/tensorflow_graphics/geometry/representation/ray.py index 6ba13e9c5..bf9dd04e9 100644 --- a/tensorflow_graphics/geometry/representation/ray.py +++ b/tensorflow_graphics/geometry/representation/ray.py @@ -18,7 +18,7 @@ from __future__ import print_function from typing import Tuple, Union -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.math import sampling @@ -92,7 +92,7 @@ def sample_1d( A tensor of shape `[A1, ..., An, M, 3]` indicating the M points on the ray and a tensor of shape `[A1, ..., An, M]` for the Z values on the points. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] ray_org = tf.convert_to_tensor(ray_org) ray_dir = tf.convert_to_tensor(ray_dir) near = tf.convert_to_tensor(near) * tf.ones((1,)) @@ -145,7 +145,7 @@ def sample_1d( else: strategy_method = None - random_z_values = strategy_method(near, far, n_samples) + random_z_values = strategy_method(near, far, n_samples) # pyrefly: ignore[not-callable] points3d = _points_from_z_values(ray_org, ray_dir, random_z_values) return points3d, random_z_values @@ -175,7 +175,7 @@ def sample_stratified_1d( A tensor of shape `[A1, ..., An, M, 3]` indicating the M points on the ray and a tensor of shape `[A1, ..., An, M]` for the Z values on the points. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] ray_org = tf.convert_to_tensor(ray_org) ray_dir = tf.convert_to_tensor(ray_dir) near = tf.convert_to_tensor(near) * tf.ones((1,)) @@ -245,7 +245,7 @@ def sample_inverse_transform_stratified_1d( A tensor of shape `[A1, ..., An, M, 3]` indicating the M points on the ray and a tensor of shape `[A1, ..., An, M]` for the Z values on the points. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] shape.check_static( tensor=ray_org, tensor_name="ray_org", @@ -312,7 +312,7 @@ def triangulate(startpoints, endpoints, weights, name="ray_triangulate"): Raises: ValueError: If the shape of the arguments is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] startpoints = tf.convert_to_tensor(value=startpoints) endpoints = tf.convert_to_tensor(value=endpoints) weights = tf.convert_to_tensor(value=weights) @@ -403,7 +403,7 @@ def intersection_ray_sphere(sphere_center, `point_on_ray` is not supported. tf.errors.InvalidArgumentError: If `ray` is not normalized. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] sphere_center = tf.convert_to_tensor(value=sphere_center) sphere_radius = tf.convert_to_tensor(value=sphere_radius) ray = tf.convert_to_tensor(value=ray) diff --git a/tensorflow_graphics/geometry/representation/triangle.py b/tensorflow_graphics/geometry/representation/triangle.py index 0c6dda5b3..27a732166 100644 --- a/tensorflow_graphics/geometry/representation/triangle.py +++ b/tensorflow_graphics/geometry/representation/triangle.py @@ -57,7 +57,7 @@ def normal(v0: type_alias.TensorLike, Raises: ValueError: If the shape of `v0`, `v1`, or `v2` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] v0 = tf.convert_to_tensor(value=v0) v1 = tf.convert_to_tensor(value=v1) v2 = tf.convert_to_tensor(value=v2) @@ -104,7 +104,7 @@ def area(v0: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 1]`, where the last dimension represents a normalized vector. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] v0 = tf.convert_to_tensor(value=v0) v1 = tf.convert_to_tensor(value=v1) v2 = tf.convert_to_tensor(value=v2) diff --git a/tensorflow_graphics/geometry/transformation/axis_angle.py b/tensorflow_graphics/geometry/transformation/axis_angle.py index 6418bee08..1352312af 100644 --- a/tensorflow_graphics/geometry/transformation/axis_angle.py +++ b/tensorflow_graphics/geometry/transformation/axis_angle.py @@ -73,7 +73,7 @@ def from_euler(angles: type_alias.TensorLike, `[A1, ..., An, 1]`, where the first tensor represents the axis, and the second represents the angle. The resulting axis is a normalized vector. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = quaternion_lib.from_euler(angles) return from_quaternion(quaternion) @@ -109,7 +109,7 @@ def from_euler_with_small_angles_approximation( `[A1, ..., An, 1]`, where the first tensor represents the axis, and the second represents the angle. The resulting axis is a normalized vector. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = quaternion_lib.from_euler_with_small_angles_approximation( angles) return from_quaternion(quaternion) @@ -136,7 +136,7 @@ def from_quaternion(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -180,7 +180,7 @@ def from_rotation_matrix(rotation_matrix: type_alias.TensorLike, Raises: ValueError: If the shape of `rotation_matrix` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] rotation_matrix = tf.convert_to_tensor(value=rotation_matrix) shape.check_static( @@ -218,7 +218,7 @@ def inverse(axis: type_alias.TensorLike, Raises: ValueError: If the shape of `axis` or `angle` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -256,7 +256,7 @@ def is_normalized(axis: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 1]`, where False indicates that the axis is not normalized. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -305,7 +305,7 @@ def rotate(point: type_alias.TensorLike, ValueError: If `point`, `axis`, or `angle` are of different shape or if their respective shape is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) diff --git a/tensorflow_graphics/geometry/transformation/dual_quaternion.py b/tensorflow_graphics/geometry/transformation/dual_quaternion.py index 39dc851cc..3def34a78 100644 --- a/tensorflow_graphics/geometry/transformation/dual_quaternion.py +++ b/tensorflow_graphics/geometry/transformation/dual_quaternion.py @@ -63,7 +63,7 @@ def conjugate(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual_quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -97,7 +97,7 @@ def multiply(dual_quaternion1: type_alias.TensorLike, Returns: A tensor of shape `[A1, ..., An, 8]` representing dual quaternions. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion1 = tf.convert_to_tensor(value=dual_quaternion1) dual_quaternion2 = tf.convert_to_tensor(value=dual_quaternion2) @@ -144,7 +144,7 @@ def inverse(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -193,7 +193,7 @@ def norm(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -234,7 +234,7 @@ def is_normalized(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual_quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -278,7 +278,7 @@ def from_rotation_translation( Raises: ValueError: If the shape of `rotation_matrix` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] rotation_quaternion = tf.convert_to_tensor(value=rotation_quaternion) translation_vector = tf.convert_to_tensor(value=translation_vector) @@ -319,7 +319,7 @@ def to_rotation_translation( A tuple with a `[A1, ..., An, 4]`-tensor for rotation in quaternion form, and a `[A1, ..., An, 3]`-tensor for translation, in that order. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -362,7 +362,7 @@ def from_axis_angle_translation(axis: type_alias.TensorLike, ValueError: If the shape of `axis`, `angle`, or `translation_vector` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) translation_vector = tf.convert_to_tensor(value=translation_vector) @@ -415,7 +415,7 @@ def conjugate_dual( Raises: ValueError: If the shape of `dual_quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -442,7 +442,7 @@ def point_to_dual_quaternion( Returns: The dual quaternion representation of `point`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) shape.check_static( diff --git a/tensorflow_graphics/geometry/transformation/euler.py b/tensorflow_graphics/geometry/transformation/euler.py index 4b406b4fd..c63bf40aa 100644 --- a/tensorflow_graphics/geometry/transformation/euler.py +++ b/tensorflow_graphics/geometry/transformation/euler.py @@ -60,7 +60,7 @@ def from_axis_angle(axis: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 3]`, where the last dimension represents the three Euler angles. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] return from_quaternion(quaternion.from_axis_angle(axis, angle)) @@ -98,7 +98,7 @@ def gimbal_lock(r01, r02, r20, eps_addition): angles = tf.stack((theta_x, theta_y, theta_z), axis=-1) return angles - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternions = tf.convert_to_tensor(value=quaternions) shape.check_static( @@ -193,7 +193,7 @@ def gimbal_lock(rotation_matrix, r20, eps_addition): angles = tf.stack((theta_x, theta_y, theta_z), axis=-1) return angles - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] rotation_matrix = tf.convert_to_tensor(value=rotation_matrix) shape.check_static( @@ -232,7 +232,7 @@ def inverse(euler_angle: type_alias.TensorLike, Raises: ValueError: If the shape of `euler_angle` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] euler_angle = tf.convert_to_tensor(value=euler_angle) shape.check_static( diff --git a/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py b/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py index 58870a6d7..8ceb3e91b 100644 --- a/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py +++ b/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py @@ -56,7 +56,7 @@ def blend(points: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] points = tf.convert_to_tensor(value=points) skinning_weights = tf.convert_to_tensor(value=skinning_weights) bone_rotations = tf.convert_to_tensor(value=bone_rotations) diff --git a/tensorflow_graphics/geometry/transformation/look_at.py b/tensorflow_graphics/geometry/transformation/look_at.py index 91f7267ed..42d8fa526 100644 --- a/tensorflow_graphics/geometry/transformation/look_at.py +++ b/tensorflow_graphics/geometry/transformation/look_at.py @@ -50,7 +50,7 @@ def right_handed(camera_position: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 4, 4]`, containing right handed look at matrices. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] camera_position = tf.convert_to_tensor(value=camera_position) look_at = tf.convert_to_tensor(value=look_at) up_vector = tf.convert_to_tensor(value=up_vector) diff --git a/tensorflow_graphics/geometry/transformation/quaternion.py b/tensorflow_graphics/geometry/transformation/quaternion.py index fb53504c7..e7fa4f3ea 100644 --- a/tensorflow_graphics/geometry/transformation/quaternion.py +++ b/tensorflow_graphics/geometry/transformation/quaternion.py @@ -32,7 +32,7 @@ from typing import List -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.geometry.transformation import rotation_matrix_3d @@ -98,7 +98,7 @@ def between_two_vectors_3d(vector1: type_alias.TensorLike, Raises: ValueError: If the shape of `vector1` or `vector2` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) @@ -154,7 +154,7 @@ def conjugate(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -187,7 +187,7 @@ def from_axis_angle(axis: type_alias.TensorLike, Raises: ValueError: If the shape of `axis` or `angle` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -229,7 +229,7 @@ def from_euler(angles: type_alias.TensorLike, Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -272,7 +272,7 @@ def from_euler_with_small_angles_approximation( Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -310,7 +310,7 @@ def from_rotation_matrix(rotation_matrix: type_alias.TensorLike, Raises: ValueError: If the shape of `rotation_matrix` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] rotation_matrix = tf.convert_to_tensor(value=rotation_matrix) shape.check_static( @@ -395,7 +395,7 @@ def inverse(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -429,7 +429,7 @@ def is_normalized(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -463,7 +463,7 @@ def normalize(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -494,7 +494,7 @@ def multiply(quaternion1: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion1` or `quaternion2` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion1 = tf.convert_to_tensor(value=quaternion1) quaternion2 = tf.convert_to_tensor(value=quaternion2) @@ -526,7 +526,7 @@ def normalized_random_uniform(quaternion_shape: List[int], A tensor of shape `[quaternion_shape[0],...,quaternion_shape[-1], 4]` representing random normalized quaternions. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion_shape = tf.convert_to_tensor( value=quaternion_shape, dtype=tf.int32) quaternion_shape = tf.concat((quaternion_shape, tf.constant([4])), axis=0) @@ -594,7 +594,7 @@ def rotate(point: type_alias.TensorLike, Raises: ValueError: If the shape of `point` or `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) quaternion = tf.convert_to_tensor(value=quaternion) @@ -642,7 +642,7 @@ def relative_angle(quaternion1: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion1` or `quaternion2` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion1 = tf.convert_to_tensor(value=quaternion1) quaternion2 = tf.convert_to_tensor(value=quaternion2) diff --git a/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py b/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py index a3d2ecbf8..6a0aa37a3 100644 --- a/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py +++ b/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py @@ -35,7 +35,7 @@ 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_graphics.geometry.transformation import rotation_matrix_common @@ -77,7 +77,7 @@ def from_euler(angle: type_alias.TensorLike, Raises: ValueError: If the shape of `angle` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] angle = tf.convert_to_tensor(value=angle) shape.check_static( @@ -132,7 +132,7 @@ def from_euler_with_small_angles_approximation( Raises: ValueError: If the shape of `angle` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -166,7 +166,7 @@ def inverse(matrix: type_alias.TensorLike, 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( @@ -201,7 +201,7 @@ def is_valid(matrix: type_alias.TensorLike, A tensor of type `bool` and shape `[A1, ..., An, 1]` where False indicates that the input is not a valid rotation matrix. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -236,7 +236,7 @@ def rotate(point: type_alias.TensorLike, Raises: ValueError: If the shape of `point` or `matrix` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) matrix = tf.convert_to_tensor(value=matrix) diff --git a/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py b/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py index 4ff9bd4c3..50908ca67 100644 --- a/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py +++ b/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py @@ -22,7 +22,7 @@ from __future__ import print_function from absl import flags -from six.moves import range +from six.moves import range # pyrefly: ignore[missing-source-for-stubs] import tensorflow as tf from tensorflow_graphics.geometry.transformation import rotation_matrix_common @@ -99,7 +99,7 @@ def assert_rotation_matrix_normalized( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return matrix - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -142,7 +142,7 @@ def from_axis_angle( Raises: ValueError: If the shape of `axis` or `angle` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -204,7 +204,7 @@ def from_euler(angles: type_alias.TensorLike, Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -244,7 +244,7 @@ def from_euler_with_small_angles_approximation( Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -276,7 +276,7 @@ def from_quaternion( Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -323,7 +323,7 @@ def inverse(matrix: type_alias.TensorLike, 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( @@ -356,7 +356,7 @@ def is_valid(matrix: type_alias.TensorLike, A tensor of type `bool` and shape `[A1, ..., An, 1]` where False indicates that the input is not a valid rotation matrix. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -392,7 +392,7 @@ def rotate(point: type_alias.TensorLike, ValueError: If the shape of `point` or `rotation_matrix_3d` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point = tf.convert_to_tensor(value=point) matrix = tf.convert_to_tensor(value=matrix) diff --git a/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py b/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py index 45cf7e1eb..185d58677 100644 --- a/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py +++ b/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py @@ -17,7 +17,7 @@ from __future__ import division from __future__ import print_function -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 @@ -45,7 +45,7 @@ def is_valid(matrix: type_alias.TensorLike, A tensor of type `bool` and shape `[A1, ..., An, 1]` where False indicates that the input is not a valid rotation matrix. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] matrix = tf.convert_to_tensor(value=matrix) shape.check_static( diff --git a/tensorflow_graphics/math/feature_representation.py b/tensorflow_graphics/math/feature_representation.py index 84a0a0a57..35b9cf858 100644 --- a/tensorflow_graphics/math/feature_representation.py +++ b/tensorflow_graphics/math/feature_representation.py @@ -16,7 +16,7 @@ from __future__ import division from __future__ import print_function -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 @@ -37,7 +37,7 @@ def positional_encoding(features: TensorLike, Returns: A tensor of shape `[A1, ..., An, 2*N*M + M]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] features = tf.convert_to_tensor(value=features) output = [features] diff --git a/tensorflow_graphics/math/interpolation/bspline.py b/tensorflow_graphics/math/interpolation/bspline.py index be7cab32a..3fe6c4088 100644 --- a/tensorflow_graphics/math/interpolation/bspline.py +++ b/tensorflow_graphics/math/interpolation/bspline.py @@ -44,13 +44,13 @@ class Degree(enum.IntEnum): def _constant(position: tf.Tensor) -> tf.Tensor: """B-Spline basis function of degree 0 for positions in the range [0, 1].""" # A piecewise constant spline is discontinuous at the knots. - return tf.expand_dims(tf.clip_by_value(1.0 + position, 1.0, 1.0), axis=-1) + return tf.expand_dims(tf.clip_by_value(1.0 + position, 1.0, 1.0), axis=-1) # pyrefly: ignore[unsupported-operation] def _linear(position: tf.Tensor) -> tf.Tensor: """B-Spline basis functions of degree 1 for positions in the range [0, 1].""" # Piecewise linear splines are C0 smooth. - return tf.stack((1.0 - position, position), axis=-1) + return tf.stack((1.0 - position, position), axis=-1) # pyrefly: ignore[unsupported-operation] def _quadratic(position: tf.Tensor) -> tf.Tensor: @@ -59,7 +59,7 @@ def _quadratic(position: tf.Tensor) -> tf.Tensor: pos_sq = tf.pow(position, 2.0) # Piecewise quadratic splines are C1 smooth. - return tf.stack((tf.pow(1.0 - position, 2.0) / 2.0, -pos_sq + position + 0.5, + return tf.stack((tf.pow(1.0 - position, 2.0) / 2.0, -pos_sq + position + 0.5, # pyrefly: ignore[unsupported-operation] pos_sq / 2.0), axis=-1) @@ -67,14 +67,14 @@ def _quadratic(position: tf.Tensor) -> tf.Tensor: def _cubic(position: tf.Tensor) -> tf.Tensor: """B-Spline basis functions of degree 3 for positions in the range [0, 1].""" # We pre-calculate the terms that are used multiple times. - neg_pos = 1.0 - position + neg_pos = 1.0 - position # pyrefly: ignore[unsupported-operation] pos_sq = tf.pow(position, 2.0) pos_cb = tf.pow(position, 3.0) # Piecewise cubic splines are C2 smooth. return tf.stack( (tf.pow(neg_pos, 3.0) / 6.0, (3.0 * pos_cb - 6.0 * pos_sq + 4.0) / 6.0, - (-3.0 * pos_cb + 3.0 * pos_sq + 3.0 * position + 1.0) / 6.0, + (-3.0 * pos_cb + 3.0 * pos_sq + 3.0 * position + 1.0) / 6.0, # pyrefly: ignore[unsupported-operation] pos_cb / 6.0), axis=-1) @@ -82,7 +82,7 @@ def _cubic(position: tf.Tensor) -> tf.Tensor: def _quartic(position: tf.Tensor) -> tf.Tensor: """B-Spline basis functions of degree 4 for positions in the range [0, 1].""" # We pre-calculate the terms that are used multiple times. - neg_pos = 1.0 - position + neg_pos = 1.0 - position # pyrefly: ignore[unsupported-operation] pos_sq = tf.pow(position, 2.0) pos_cb = tf.pow(position, 3.0) pos_qt = tf.pow(position, 4.0) @@ -92,8 +92,8 @@ def _quartic(position: tf.Tensor) -> tf.Tensor: (tf.pow(neg_pos, 4.0) / 24.0, (-4.0 * tf.pow(neg_pos, 4.0) + 4.0 * tf.pow(neg_pos, 3.0) + 6.0 * tf.pow(neg_pos, 2.0) + 4.0 * neg_pos + 1.0) / 24.0, - (pos_qt - 2.0 * pos_cb - pos_sq + 2.0 * position) / 4.0 + 11.0 / 24.0, - (-4.0 * pos_qt + 4.0 * pos_cb + 6.0 * pos_sq + 4.0 * position + 1.0) / + (pos_qt - 2.0 * pos_cb - pos_sq + 2.0 * position) / 4.0 + 11.0 / 24.0, # pyrefly: ignore[unsupported-operation] + (-4.0 * pos_qt + 4.0 * pos_cb + 6.0 * pos_sq + 4.0 * position + 1.0) / # pyrefly: ignore[unsupported-operation] 24.0, pos_qt / 24.0), axis=-1) @@ -137,7 +137,7 @@ def knot_weights( ValueError: If degree is greater than 4 or num_knots - 1, or less than 0. InvalidArgumentError: If positions are not in the right range. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] positions = tf.convert_to_tensor(value=positions) if degree > 4 or degree < 0: @@ -158,7 +158,7 @@ def knot_weights( Degree.CUBIC: _cubic, Degree.QUARTIC: _quartic } - basis_functions = all_basis_functions[degree] + basis_functions = all_basis_functions[degree] # pyrefly: ignore[bad-index] if not cyclical and num_knots - degree == 1: # In this case all weights are non-zero and we can just return them. @@ -236,7 +236,7 @@ def interpolate_with_weights( Raises: ValueError: If the last dimension of knots and weights is not equal. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] knots = tf.convert_to_tensor(value=knots) weights = tf.convert_to_tensor(value=weights) @@ -271,7 +271,7 @@ def interpolate(knots: type_alias.TensorLike, A tensor of shape `[A1, ... An, B1, ..., Bk]`, which is the result of spline interpolation. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] knots = tf.convert_to_tensor(value=knots) positions = tf.convert_to_tensor(value=positions) diff --git a/tensorflow_graphics/math/interpolation/slerp.py b/tensorflow_graphics/math/interpolation/slerp.py index 9fd20091c..b333532cd 100644 --- a/tensorflow_graphics/math/interpolation/slerp.py +++ b/tensorflow_graphics/math/interpolation/slerp.py @@ -142,7 +142,7 @@ def interpolate_with_weights( A tensor of shape `[A1, ... , An, M]` containing the result of the interpolation. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] return weight1 * vector1 + weight2 * vector2 @@ -185,7 +185,7 @@ def quaternion_weights( Two tensors of shape `[A1, ... , An, 1]` each, which are the two slerp weights for each quaternion. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] quaternion1 = tf.convert_to_tensor(value=quaternion1) quaternion2 = tf.convert_to_tensor(value=quaternion2) percent = tf.convert_to_tensor(value=percent, dtype=quaternion1.dtype) @@ -253,7 +253,7 @@ def vector_weights(vector1: type_alias.TensorLike, Two tensors of shape `[A1, ... , An, 1]`, representing interpolation weights for each input vector. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) percent = tf.convert_to_tensor(value=percent, dtype=vector1.dtype) diff --git a/tensorflow_graphics/math/interpolation/trilinear.py b/tensorflow_graphics/math/interpolation/trilinear.py index 35230aa9a..d577aab10 100644 --- a/tensorflow_graphics/math/interpolation/trilinear.py +++ b/tensorflow_graphics/math/interpolation/trilinear.py @@ -41,7 +41,7 @@ def interpolate(grid_3d: type_alias.TensorLike, A tensor of shape `[A1, ..., An, M, C]` """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] grid_3d = tf.convert_to_tensor(value=grid_3d) sampling_points = tf.convert_to_tensor(value=sampling_points) diff --git a/tensorflow_graphics/math/interpolation/weighted.py b/tensorflow_graphics/math/interpolation/weighted.py index 3f1151341..86d0c53eb 100644 --- a/tensorflow_graphics/math/interpolation/weighted.py +++ b/tensorflow_graphics/math/interpolation/weighted.py @@ -61,7 +61,7 @@ def interpolate(points: type_alias.TensorLike, A tensor of shape `[A1, ..., An, M]` storing the interpolated M-D points. The first n dimensions will be the same as weights and indices. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] points = tf.convert_to_tensor(value=points) weights = tf.convert_to_tensor(value=weights) indices = tf.convert_to_tensor(value=indices) @@ -128,7 +128,7 @@ def get_barycentric_coordinates( valid: A boolean tensor of shape `[A1, ..., An, N], which is `True` where pixels are inside the triangle, and `False` otherwise. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] triangle_vertices = tf.convert_to_tensor(value=triangle_vertices) pixels = tf.convert_to_tensor(value=pixels) diff --git a/tensorflow_graphics/math/math_helpers.py b/tensorflow_graphics/math/math_helpers.py index 9976511f4..a58e2d913 100644 --- a/tensorflow_graphics/math/math_helpers.py +++ b/tensorflow_graphics/math/math_helpers.py @@ -52,7 +52,7 @@ def cartesian_to_spherical_coordinates( (`r`,`theta`,`phi`), where `r` is the sphere radius, `theta` is the polar angle and `phi` is the azimuthal angle. Returns `NaN` gradient if x = y = 0. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_cartesian = tf.convert_to_tensor(value=point_cartesian) shape.check_static( @@ -140,7 +140,7 @@ def spherical_to_cartesian_coordinates( A tensor of shape `[A1, ..., An, 3]`, where the last dimension contains the cartesian coordinates in x,y,z order. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] point_spherical = tf.convert_to_tensor(value=point_spherical) shape.check_static( @@ -180,7 +180,7 @@ def square_to_spherical_coordinates( [0,1]. """ - 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( diff --git a/tensorflow_graphics/math/sampling.py b/tensorflow_graphics/math/sampling.py index e89553f00..0a0a067c0 100644 --- a/tensorflow_graphics/math/sampling.py +++ b/tensorflow_graphics/math/sampling.py @@ -40,7 +40,7 @@ def regular_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -70,7 +70,7 @@ def regular_inverse_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -100,7 +100,7 @@ def uniform_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -135,7 +135,7 @@ def stratified_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -175,7 +175,7 @@ def logspace_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) shape.compare_batch_dimensions( @@ -209,7 +209,7 @@ def geomspace_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) shape.compare_batch_dimensions( @@ -238,7 +238,7 @@ def stratified_geomspace_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -268,7 +268,7 @@ def _normalize_pdf(pdf: TensorLike, name="normalize_pdf") -> tf.Tensor: Returns: A tensor of shape `[A1, ..., An, M]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] pdf = tf.convert_to_tensor(value=pdf) pdf += 1e-5 return safe_ops.safe_signed_div(pdf, tf.reduce_sum(pdf, -1, keepdims=True)) @@ -285,7 +285,7 @@ def _get_cdf(pdf: TensorLike, name="get_cdf"): Returns: A tensor of shape `[A1, ..., An, M+1]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] pdf = tf.convert_to_tensor(value=pdf) batch_shape = tf.shape(pdf)[:-1] cdf = tf.cumsum(pdf, -1) @@ -317,7 +317,7 @@ def inverse_transform_sampling_1d( A tensor of shape `[A1, ..., An, N]` indicating the new N random points. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] bins = tf.convert_to_tensor(value=bins) pdf = tf.convert_to_tensor(value=pdf) @@ -378,7 +378,7 @@ def inverse_transform_stratified_1d(bin_start: TensorLike, A tensor of shape `[A1, ..., An, N]` indicating the N points on the ray """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] bin_start = tf.convert_to_tensor(value=bin_start) bin_width = tf.convert_to_tensor(value=bin_width) pdf = tf.convert_to_tensor(value=pdf) diff --git a/tensorflow_graphics/math/spherical_harmonics.py b/tensorflow_graphics/math/spherical_harmonics.py index af51b873d..19fd1a74b 100644 --- a/tensorflow_graphics/math/spherical_harmonics.py +++ b/tensorflow_graphics/math/spherical_harmonics.py @@ -20,7 +20,7 @@ from typing import 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.math import math_helpers @@ -58,7 +58,7 @@ def integration_product( ValueError: if the last dimension of `harmonics1` is different from the last dimension of `harmonics2`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] harmonics1 = tf.convert_to_tensor(value=harmonics1) harmonics2 = tf.convert_to_tensor(value=harmonics2) @@ -88,7 +88,7 @@ def generate_l_m_permutations( Returns: Two tensors of shape `[max_band*max_band]`. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] degree_l = [] order_m = [] for degree in range(0, max_band + 1): @@ -112,7 +112,7 @@ def generate_l_m_zonal( Returns: Two tensors of shape `[max_band+1]`, one for degree l and one for order m. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] degree_l = np.linspace(0, max_band, num=max_band + 1, dtype=np.int32) order_m = np.zeros(max_band + 1, dtype=np.int32) return (tf.convert_to_tensor(value=degree_l), @@ -273,7 +273,7 @@ def evaluate_spherical_harmonics( InvalidArgumentError: if at least an element of `l`, `m`, `theta` or `phi` is outside the expected range. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] degree_l = tf.convert_to_tensor(value=degree_l) order_m = tf.convert_to_tensor(value=order_m) theta = tf.convert_to_tensor(value=theta) @@ -339,7 +339,7 @@ def rotate_zonal_harmonics( ValueError: If the shape of `zonal_coeffs`, `theta` or `phi` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] zonal_coeffs = tf.convert_to_tensor(value=zonal_coeffs) theta = tf.convert_to_tensor(value=theta) phi = tf.convert_to_tensor(value=phi) @@ -386,7 +386,7 @@ def tile_zonal_coefficients( Raises: ValueError: if the shape of `coefficients` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] coefficients = tf.convert_to_tensor(value=coefficients) shape.check_static( diff --git a/tensorflow_graphics/math/vector.py b/tensorflow_graphics/math/vector.py index c275b9b2e..d59656045 100644 --- a/tensorflow_graphics/math/vector.py +++ b/tensorflow_graphics/math/vector.py @@ -47,7 +47,7 @@ def cross(vector1: TensorLike, A tensor of shape `[A1, ..., Ai = 3, ..., An]`, where the dimension i = axis represents the result of the cross product. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) @@ -90,7 +90,7 @@ def dot(vector1: TensorLike, A tensor of shape `[A1, ..., Ai = 1, ..., An]`, where the dimension i = axis represents the result of the dot product. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) @@ -132,7 +132,7 @@ def reflect(vector: TensorLike, A tensor of shape `[A1, ..., Ai, ..., An]`, where the dimension i = axis represents a reflected vector. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) normal = tf.convert_to_tensor(value=normal) diff --git a/tensorflow_graphics/nn/metric/fscore.py b/tensorflow_graphics/nn/metric/fscore.py index 8bb696c39..31396da24 100644 --- a/tensorflow_graphics/nn/metric/fscore.py +++ b/tensorflow_graphics/nn/metric/fscore.py @@ -66,7 +66,7 @@ def evaluate(ground_truth: type_alias.TensorLike, ValueError: if the shape of `ground_truth`, `prediction` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] ground_truth = tf.convert_to_tensor(value=ground_truth) prediction = tf.convert_to_tensor(value=prediction) diff --git a/tensorflow_graphics/nn/metric/intersection_over_union.py b/tensorflow_graphics/nn/metric/intersection_over_union.py index 1fe718057..8daa9b550 100644 --- a/tensorflow_graphics/nn/metric/intersection_over_union.py +++ b/tensorflow_graphics/nn/metric/intersection_over_union.py @@ -17,7 +17,7 @@ from __future__ import division from __future__ import print_function -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 @@ -54,7 +54,7 @@ def evaluate(ground_truth_labels: type_alias.TensorLike, ValueError: if the shape of `ground_truth_labels`, `predicted_labels` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] ground_truth_labels = tf.convert_to_tensor(value=ground_truth_labels) predicted_labels = tf.convert_to_tensor(value=predicted_labels) diff --git a/tensorflow_graphics/nn/metric/precision.py b/tensorflow_graphics/nn/metric/precision.py index 814a82fb1..58a2c6ff5 100644 --- a/tensorflow_graphics/nn/metric/precision.py +++ b/tensorflow_graphics/nn/metric/precision.py @@ -66,7 +66,7 @@ class and return a single precision value. Defaults to true. Raises: ValueError: if the shape of `ground_truth`, `prediction` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] ground_truth = tf.cast( x=tf.convert_to_tensor(value=ground_truth), dtype=tf.int32) prediction = tf.convert_to_tensor(value=prediction) diff --git a/tensorflow_graphics/nn/metric/recall.py b/tensorflow_graphics/nn/metric/recall.py index 7e82be870..e068d0f5a 100644 --- a/tensorflow_graphics/nn/metric/recall.py +++ b/tensorflow_graphics/nn/metric/recall.py @@ -66,7 +66,7 @@ class and return a single recall value. Defaults to true. Raises: ValueError: if the shape of `ground_truth`, `prediction` is not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] ground_truth = tf.cast( x=tf.convert_to_tensor(value=ground_truth), dtype=tf.int32) prediction = tf.convert_to_tensor(value=prediction) diff --git a/tensorflow_graphics/projects/gan/architectures_progressive_gan.py b/tensorflow_graphics/projects/gan/architectures_progressive_gan.py index 38e6c65d2..217025f34 100644 --- a/tensorflow_graphics/projects/gan/architectures_progressive_gan.py +++ b/tensorflow_graphics/projects/gan/architectures_progressive_gan.py @@ -103,7 +103,7 @@ def create_generator(latent_code_dimension: int = 128, The created generator keras model object. """ if kernel_initializer is None: - kernel_initializer = tf.keras.initializers.TruncatedNormal( + kernel_initializer = tf.keras.initializers.TruncatedNormal( # pyrefly: ignore[bad-assignment] mean=0.0, stddev=1.0) input_tensor = tf.keras.Input(shape=(latent_code_dimension,)) @@ -118,9 +118,9 @@ def create_generator(latent_code_dimension: int = 128, units=4 * 4 * latent_code_dimension, kernel_initializer=kernel_initializer)( maybe_normzlized_input_tensor) - tensor = tf.keras.layers.Reshape(target_shape=(4, 4, latent_code_dimension))( + tensor = tf.keras.layers.Reshape(target_shape=(4, 4, latent_code_dimension))( # pyrefly: ignore[not-callable] tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_batch_normalization: tensor = tf.keras.layers.BatchNormalization()(tensor) if use_pixel_normalization: @@ -132,7 +132,7 @@ def create_generator(latent_code_dimension: int = 128, padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_batch_normalization: tensor = tf.keras.layers.BatchNormalization()(tensor) if use_pixel_normalization: @@ -144,7 +144,7 @@ def create_generator(latent_code_dimension: int = 128, outputs.append( to_rgb( input_tensor=tensor, - kernel_initializer=kernel_initializer, + kernel_initializer=kernel_initializer, # pyrefly: ignore[bad-argument-type] name='side_output_%d_conv' % index)) tensor = keras_layers.TwoByTwoNearestNeighborUpSampling()(tensor) @@ -156,7 +156,7 @@ def create_generator(latent_code_dimension: int = 128, padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_batch_normalization: tensor = tf.keras.layers.BatchNormalization()(tensor) if use_pixel_normalization: @@ -164,7 +164,7 @@ def create_generator(latent_code_dimension: int = 128, tensor = to_rgb( input_tensor=tensor, - kernel_initializer=kernel_initializer, + kernel_initializer=kernel_initializer, # pyrefly: ignore[bad-argument-type] name='final_output') if generate_intermediate_outputs: outputs.append(tensor) @@ -213,7 +213,7 @@ def from_rgb(input_tensor: tf.Tensor, Returns: The feature map. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] output = create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernel, filters=num_channels, @@ -222,7 +222,7 @@ def from_rgb(input_tensor: tf.Tensor, kernel_initializer=kernel_initializer, padding='same')( input_tensor) - return tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(output) + return tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(output) # pyrefly: ignore[not-callable] def create_discriminator( @@ -270,7 +270,7 @@ def create_discriminator( The generated discriminator keras model. """ if kernel_initializer is None: - kernel_initializer = tf.keras.initializers.TruncatedNormal( + kernel_initializer = tf.keras.initializers.TruncatedNormal( # pyrefly: ignore[bad-assignment] mean=0.0, stddev=1.0) if use_intermediate_inputs: @@ -286,7 +286,7 @@ def create_discriminator( tensor, use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, num_channels=downsampling_blocks_num_channels[0][0], - kernel_initializer=kernel_initializer, + kernel_initializer=kernel_initializer, # pyrefly: ignore[bad-argument-type] relu_leakiness=relu_leakiness) if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) @@ -301,7 +301,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) tensor = create_conv_layer( @@ -312,7 +312,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) if use_antialiased_bilinear_downsampling: @@ -320,7 +320,7 @@ def create_discriminator( tensor = tf.keras.layers.AveragePooling2D()(tensor) if use_intermediate_inputs: - tensor = tf.keras.layers.Concatenate()([inputs[-index - 2], tensor]) + tensor = tf.keras.layers.Concatenate()([inputs[-index - 2], tensor]) # pyrefly: ignore[unbound-name] tensor = create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, @@ -330,7 +330,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) @@ -342,7 +342,7 @@ def create_discriminator( padding='valid', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) @@ -353,9 +353,9 @@ def create_discriminator( kernel_size=1, kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.Reshape((-1,))(tensor) + tensor = tf.keras.layers.Reshape((-1,))(tensor) # pyrefly: ignore[not-callable] if use_intermediate_inputs: - return tf.keras.Model(inputs=inputs, outputs=tensor, name=name) + return tf.keras.Model(inputs=inputs, outputs=tensor, name=name) # pyrefly: ignore[unbound-name] else: - return tf.keras.Model(inputs=input_tensor, outputs=tensor, name=name) + return tf.keras.Model(inputs=input_tensor, outputs=tensor, name=name) # pyrefly: ignore[unbound-name] diff --git a/tensorflow_graphics/projects/gan/architectures_style_gan.py b/tensorflow_graphics/projects/gan/architectures_style_gan.py index 81c8d9627..a6a53ac79 100644 --- a/tensorflow_graphics/projects/gan/architectures_style_gan.py +++ b/tensorflow_graphics/projects/gan/architectures_style_gan.py @@ -113,7 +113,7 @@ def create_mapping_network(latent_code_dimension: int = 128, tensor = maybe_normalized_input_tensor for i in range(num_layers): - with tf.name_scope(name='mapping_layer_%d' % i): + with tf.name_scope(name='mapping_layer_%d' % i): # pyrefly: ignore[bad-instantiation] # The kernel_multiplier implements the reduced learning rate of the # mapping network. tensor = keras_layers.FanInScaledDense( @@ -123,7 +123,7 @@ def create_mapping_network(latent_code_dimension: int = 128, kernel_initializer=tf.keras.initializers.TruncatedNormal( mean=0.0, stddev=1.0 / learning_rate_multiplier))( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] return tf.keras.Model(inputs=input_tensor, outputs=tensor, name=name) @@ -162,7 +162,7 @@ def create_synthesis_network(latent_code_dimension: int = 128, tensor = keras_layers.LearnedConstant()(mapped_latent_code_input) tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] tensor = apply_style_with_adain( mapped_latent_code=mapped_latent_code_input, input_tensor=tensor) tensor = keras_layers.FanInScaledConv2D( @@ -173,7 +173,7 @@ def create_synthesis_network(latent_code_dimension: int = 128, kernel_initializer=kernel_initializer)( tensor) tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] tensor = apply_style_with_adain( mapped_latent_code=mapped_latent_code_input, input_tensor=tensor) @@ -197,7 +197,7 @@ def create_synthesis_network(latent_code_dimension: int = 128, kernel_initializer=kernel_initializer)( tensor) tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] tensor = apply_style_with_adain( mapped_latent_code=mapped_latent_code_input, input_tensor=tensor) @@ -262,8 +262,8 @@ def create_style_based_generator( use_bilinear_upsampling=use_bilinear_upsampling) input_tensor = tf.keras.Input(shape=(latent_code_dimension,)) - mapped_latent_code = mapping_network(input_tensor) - generated_images = synthesis_network(mapped_latent_code) + mapped_latent_code = mapping_network(input_tensor) # pyrefly: ignore[not-callable] + generated_images = synthesis_network(mapped_latent_code) # pyrefly: ignore[not-callable] generator = tf.keras.Model( inputs=input_tensor, outputs=generated_images, name=name) diff --git a/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py b/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py index 2c917d978..64a2735df 100644 --- a/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py +++ b/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py @@ -132,10 +132,10 @@ def create_synthesis_network( filters=upsampling_blocks_num_channels[0], kernel_size=3)((tensor, mapped_latent_code_input)) if use_noise_inputs: - tensor = keras_layers.Noise()((tensor, noise_inputs[0])) + tensor = keras_layers.Noise()((tensor, noise_inputs[0])) # pyrefly: ignore[unbound-name] else: tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] output = None for index, channels in enumerate(upsampling_blocks_num_channels): @@ -157,7 +157,7 @@ def create_synthesis_network( tensor = keras_layers.Noise()((tensor, noise_inputs[noise_index])) else: tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] output = _maybe_upsample_and_add_outputs( architectures_progressive_gan.to_rgb( @@ -270,7 +270,7 @@ def create_discriminator( The generated discriminator keras model. """ if kernel_initializer is None: - kernel_initializer = tf.keras.initializers.TruncatedNormal( + kernel_initializer = tf.keras.initializers.TruncatedNormal( # pyrefly: ignore[bad-assignment] mean=0.0, stddev=1.0) input_tensor = tf.keras.Input(shape=(None, None, num_channels)) @@ -283,7 +283,7 @@ def create_discriminator( for index, (channels_1, channels_2) in enumerate(downsampling_blocks_num_channels): - with tf.name_scope(f'downsampling_block_{index}'): + with tf.name_scope(f'downsampling_block_{index}'): # pyrefly: ignore[bad-instantiation] shortcut = tensor shortcut = architectures_progressive_gan.create_conv_layer( @@ -306,7 +306,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] tensor = architectures_progressive_gan.create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, filters=channels_2, @@ -315,7 +315,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] if use_antialiased_bilinear_downsampling: tensor = keras_layers.Blur2D()(tensor) tensor = tf.keras.layers.AveragePooling2D()(tensor) @@ -331,7 +331,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] tensor = architectures_progressive_gan.create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, @@ -341,7 +341,7 @@ def create_discriminator( padding='valid', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] tensor = architectures_progressive_gan.create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, @@ -350,6 +350,6 @@ def create_discriminator( kernel_size=1, kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.Reshape((-1,))(tensor) + tensor = tf.keras.layers.Reshape((-1,))(tensor) # pyrefly: ignore[not-callable] return tf.keras.Model(inputs=input_tensor, outputs=tensor, name=name) diff --git a/tensorflow_graphics/projects/gan/exponential_moving_average.py b/tensorflow_graphics/projects/gan/exponential_moving_average.py index 03a563e4a..fc8327807 100644 --- a/tensorflow_graphics/projects/gan/exponential_moving_average.py +++ b/tensorflow_graphics/projects/gan/exponential_moving_average.py @@ -46,12 +46,12 @@ def __init__(self, decay: float = 0.999): Args: decay: The decay rate of the exponential moving average. """ - self.averaged_variables: Sequence[tf.Variable] = None + self.averaged_variables: Sequence[tf.Variable] = None # pyrefly: ignore[bad-assignment] self._decay = decay def _ema_assign_fn(self, variable: tf.Variable, value: tf.Tensor): """Updates the exponential moving average for a single variable.""" - return variable.assign(self._decay * variable + (1.0 - self._decay) * value) + return variable.assign(self._decay * variable + (1.0 - self._decay) * value) # pyrefly: ignore[unsupported-operation] def _apply_values(self, variables: Sequence[tf.Variable]): """Applies the new values to the exponential moving averages.""" @@ -88,7 +88,7 @@ def apply(self, variables: Sequence[tf.Variable]): if self.averaged_variables is None: with tf.init_scope(): strategy = tf.distribute.get_strategy() - self.averaged_variables = [] + self.averaged_variables = [] # pyrefly: ignore[bad-assignment] for variable in variables: with strategy.extended.colocate_vars_with(variable): diff --git a/tensorflow_graphics/projects/gan/keras_layers.py b/tensorflow_graphics/projects/gan/keras_layers.py index e143cda95..ee7630a64 100644 --- a/tensorflow_graphics/projects/gan/keras_layers.py +++ b/tensorflow_graphics/projects/gan/keras_layers.py @@ -88,7 +88,7 @@ def kernel(self) -> tf.Tensor: # Fan in computation assumes that the last dimension of the kernel is the # output dimension. fan_in = np.prod(self._kernel.shape.as_list()[:-1]) - return (self._kernel * self._multiplier / math.sqrt(fan_in) * + return (self._kernel * self._multiplier / math.sqrt(fan_in) * # pyrefly: ignore[bad-return, unsupported-operation] self._kernel_multiplier) @kernel.setter @@ -98,7 +98,7 @@ def kernel(self, kernel: tf.Variable) -> None: @property def bias(self) -> tf.Tensor: if self._bias_multiplier is not None: - return self._bias * self._bias_multiplier + return self._bias * self._bias_multiplier # pyrefly: ignore[bad-return, unsupported-operation] else: return self._bias.read_value() @@ -384,7 +384,7 @@ def call( raise ValueError('inputs needs to have two elements.') feature_map, mapped_latent_code = inputs - style = self._dense_layer(mapped_latent_code)[:, tf.newaxis, tf.newaxis, :] + style = self._dense_layer(mapped_latent_code)[:, tf.newaxis, tf.newaxis, :] # pyrefly: ignore[not-callable] modulated_features = self._conv_layer(feature_map * style) weight = self._conv_layer.kernel[tf.newaxis, :, :, :, :] diff --git a/tensorflow_graphics/projects/gan/losses.py b/tensorflow_graphics/projects/gan/losses.py index ff518414c..28808c162 100644 --- a/tensorflow_graphics/projects/gan/losses.py +++ b/tensorflow_graphics/projects/gan/losses.py @@ -54,7 +54,7 @@ def gradient_penalty_loss(real_data: Union[tf.Tensor, Sequence[tf.Tensor]], ValueError if the numnber of elements in real_data and generated_data are not equal. """ - with tf.name_scope(name=name_scope): + with tf.name_scope(name=name_scope): # pyrefly: ignore[bad-instantiation] with tf.GradientTape() as tape: if (isinstance(real_data, tf.Tensor) and isinstance(generated_data, tf.Tensor)): @@ -88,9 +88,9 @@ def gradient_penalty_loss(real_data: Union[tf.Tensor, Sequence[tf.Tensor]], (type(real_data), type(generated_data))) # By default the gradient tape only watches trainable variables. tape.watch(interpolated_data) - interpolated_labels = discriminator(interpolated_data) + interpolated_labels = discriminator(interpolated_data) # pyrefly: ignore[not-callable] - with tf.name_scope(name='gradients'): + with tf.name_scope(name='gradients'): # pyrefly: ignore[bad-instantiation] gradients = tape.gradient( target=interpolated_labels, sources=interpolated_data) @@ -146,12 +146,12 @@ def r1_regularization(real_data: Union[tf.Tensor, Sequence[tf.Tensor]], Returns: The r1 regulatization loss per example as tensor of shape [batch_size]. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] with tf.GradientTape() as tape: tape.watch(real_data) - discriminator_output = discriminator(real_data) + discriminator_output = discriminator(real_data) # pyrefly: ignore[not-callable] - with tf.name_scope(name='gradients'): + with tf.name_scope(name='gradients'): # pyrefly: ignore[bad-instantiation] gradients = tape.gradient( target=discriminator_output, sources=real_data) @@ -186,7 +186,7 @@ def wasserstein_generator_loss( Returns: The loss for the generator. """ - with tf.name_scope(name=name): + with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] return -discriminator_output_generated_data @@ -211,8 +211,8 @@ def wasserstein_discriminator_loss( Returns: The loss for the discriminator. """ - with tf.name_scope(name=name): - return discriminator_output_generated_data - discriminator_output_real_data + with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] + return discriminator_output_generated_data - discriminator_output_real_data # pyrefly: ignore[unsupported-operation] def wasserstein_hinge_generator_loss( @@ -235,7 +235,7 @@ def wasserstein_hinge_generator_loss( Returns: The loss for the generator. """ - with tf.name_scope(name=name): + with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] return -discriminator_output_generated_data @@ -260,9 +260,9 @@ def wasserstein_hinge_discriminator_loss( Returns: The loss for the discriminator. """ - with tf.name_scope(name=name): - return tf.nn.relu(1.0 - discriminator_output_real_data) + tf.nn.relu( - discriminator_output_generated_data + 1.0) + with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] + return tf.nn.relu(1.0 - discriminator_output_real_data) + tf.nn.relu( # pyrefly: ignore[unsupported-operation] + discriminator_output_generated_data + 1.0) # pyrefly: ignore[unsupported-operation] def minimax_generator_loss(discriminator_output_generated_data: tf.Tensor, @@ -280,7 +280,7 @@ def minimax_generator_loss(discriminator_output_generated_data: tf.Tensor, Returns: The loss for the generator. """ - with tf.name_scope(name=name): + with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] # -log(sigmoid(discriminator_output_generated_data)) return tf.nn.sigmoid_cross_entropy_with_logits( labels=tf.ones_like(discriminator_output_generated_data), @@ -306,7 +306,7 @@ def minimax_discriminator_loss( Returns: The loss for the discriminator. """ - with tf.name_scope(name=name): + with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] # -log(sigmoid(discriminator_output_real_data)) loss_real = tf.nn.sigmoid_cross_entropy_with_logits( labels=tf.ones_like(discriminator_output_real_data), diff --git a/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py b/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py index da3336487..5317b2e0d 100644 --- a/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py +++ b/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py @@ -141,7 +141,7 @@ class SyncMiniBatchStandardDeviation(MiniBatchStandardDeviationBase): def _calculate_mean_feature_standard_deviation(self, inputs, batch_axis): - with tf.name_scope('mean_feature_standard_deviation'): + with tf.name_scope('mean_feature_standard_deviation'): # pyrefly: ignore[bad-instantiation] # The dynamic range of fp16 is too limited to support the collection of # sufficient statistics. As a workaround we simply perform the operations # on 32-bit floats before converting the mean and variance back to fp16 diff --git a/tensorflow_graphics/rendering/reflectance/blinn_phong.py b/tensorflow_graphics/rendering/reflectance/blinn_phong.py index ec5f75012..e013418fc 100644 --- a/tensorflow_graphics/rendering/reflectance/blinn_phong.py +++ b/tensorflow_graphics/rendering/reflectance/blinn_phong.py @@ -89,7 +89,7 @@ def brdf(direction_incoming_light: type_alias.TensorLike, InvalidArgumentError: if not all of shininess values are non-negative, or if at least one element of `albedo` is outside of [0,1]. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] direction_incoming_light = tf.convert_to_tensor( value=direction_incoming_light) direction_outgoing_light = tf.convert_to_tensor( diff --git a/tensorflow_graphics/rendering/reflectance/lambertian.py b/tensorflow_graphics/rendering/reflectance/lambertian.py index 4b38c86b7..c2046f4ed 100644 --- a/tensorflow_graphics/rendering/reflectance/lambertian.py +++ b/tensorflow_graphics/rendering/reflectance/lambertian.py @@ -65,7 +65,7 @@ def brdf(direction_incoming_light: type_alias.TensorLike, InvalidArgumentError: if at least one element of `albedo` is outside of [0,1]. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] direction_incoming_light = tf.convert_to_tensor( value=direction_incoming_light) direction_outgoing_light = tf.convert_to_tensor( diff --git a/tensorflow_graphics/rendering/reflectance/phong.py b/tensorflow_graphics/rendering/reflectance/phong.py index a0a584c86..cd66269db 100644 --- a/tensorflow_graphics/rendering/reflectance/phong.py +++ b/tensorflow_graphics/rendering/reflectance/phong.py @@ -85,7 +85,7 @@ def brdf(direction_incoming_light: type_alias.TensorLike, InvalidArgumentError: if not all of shininess values are non-negative, or if at least one element of `albedo` is outside of [0,1]. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] direction_incoming_light = tf.convert_to_tensor( value=direction_incoming_light) direction_outgoing_light = tf.convert_to_tensor( diff --git a/tensorflow_graphics/rendering/volumetric/absorption.py b/tensorflow_graphics/rendering/volumetric/absorption.py index 32a53b56e..cc9bf4a62 100644 --- a/tensorflow_graphics/rendering/volumetric/absorption.py +++ b/tensorflow_graphics/rendering/volumetric/absorption.py @@ -50,7 +50,7 @@ def render(voxels: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] voxels = tf.convert_to_tensor(value=voxels) shape.check_static( diff --git a/tensorflow_graphics/rendering/volumetric/emission_absorption.py b/tensorflow_graphics/rendering/volumetric/emission_absorption.py index 23f4b8c8c..e646c1c0b 100644 --- a/tensorflow_graphics/rendering/volumetric/emission_absorption.py +++ b/tensorflow_graphics/rendering/volumetric/emission_absorption.py @@ -50,7 +50,7 @@ def render(voxels: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] voxels = tf.convert_to_tensor(value=voxels) shape.check_static( diff --git a/tensorflow_graphics/rendering/volumetric/ray_radiance.py b/tensorflow_graphics/rendering/volumetric/ray_radiance.py index b04d9e2dd..cafc0ae8b 100644 --- a/tensorflow_graphics/rendering/volumetric/ray_radiance.py +++ b/tensorflow_graphics/rendering/volumetric/ray_radiance.py @@ -47,7 +47,7 @@ def compute_radiance( and a tensor of shape `[A1, ..., An, N]` for the sample weights. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] rgba_values = tf.convert_to_tensor(value=rgba_values) distances = tf.convert_to_tensor(value=distances) distances = tf.expand_dims(distances, -1) diff --git a/tensorflow_graphics/rendering/volumetric/visual_hull.py b/tensorflow_graphics/rendering/volumetric/visual_hull.py index ec0328232..ed870621f 100644 --- a/tensorflow_graphics/rendering/volumetric/visual_hull.py +++ b/tensorflow_graphics/rendering/volumetric/visual_hull.py @@ -46,7 +46,7 @@ def render(voxels: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] voxels = tf.convert_to_tensor(value=voxels) shape.check_static( diff --git a/tensorflow_graphics/util/asserts.py b/tensorflow_graphics/util/asserts.py index 874cd5dc9..862dc6696 100644 --- a/tensorflow_graphics/util/asserts.py +++ b/tensorflow_graphics/util/asserts.py @@ -51,7 +51,7 @@ def assert_no_infs_or_nans( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return tensor - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] tensor = tf.convert_to_tensor(value=tensor) assert_ops = (tf.debugging.check_numerics( @@ -87,7 +87,7 @@ def assert_all_above( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) minval = tf.convert_to_tensor(value=minval, dtype=vector.dtype) @@ -126,7 +126,7 @@ def assert_all_below( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) maxval = tf.convert_to_tensor(value=maxval, dtype=vector.dtype) @@ -172,7 +172,7 @@ def assert_all_in_range( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) minval = tf.convert_to_tensor(value=minval, dtype=vector.dtype) maxval = tf.convert_to_tensor(value=maxval, dtype=vector.dtype) @@ -218,7 +218,7 @@ def assert_nonzero_norm( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) if eps is None: eps = select_eps_for_division(vector.dtype) @@ -258,7 +258,7 @@ def assert_normalized( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return vector - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) if eps is None: eps = select_eps_for_division(vector.dtype) @@ -298,7 +298,7 @@ def assert_at_least_k_non_zero_entries( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return tensor - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] tensor = tf.convert_to_tensor(value=tensor) indicator = tf.cast(tf.math.greater(tensor, 0.0), dtype=tensor.dtype) @@ -329,7 +329,7 @@ def assert_binary( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return tensor - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] tensor = tf.convert_to_tensor(value=tensor) condition = tf.reduce_all( input_tensor=tf.logical_or(tf.equal(tensor, 0), tf.equal(tensor, 1))) diff --git a/tensorflow_graphics/util/export_api.py b/tensorflow_graphics/util/export_api.py index 724121cc5..ebd24971b 100644 --- a/tensorflow_graphics/util/export_api.py +++ b/tensorflow_graphics/util/export_api.py @@ -48,7 +48,7 @@ def get_modules(): return [ obj_name for obj_name, obj in inspect.getmembers(module) if inspect.ismodule(obj) and six.ensure_str(obj.__name__).rsplit(".", 1) - [0] == module.__name__ and not obj_name.startswith("_") + [0] == module.__name__ and not obj_name.startswith("_") # pyrefly: ignore[missing-attribute] ] diff --git a/tensorflow_graphics/util/safe_ops.py b/tensorflow_graphics/util/safe_ops.py index 7a174d265..7c2ce7b9c 100644 --- a/tensorflow_graphics/util/safe_ops.py +++ b/tensorflow_graphics/util/safe_ops.py @@ -38,7 +38,7 @@ def nonzero_sign( x: type_alias.TensorLike, name: str = 'nonzero_sign') -> tf.Tensor: """Returns the sign of x with sign(0) defined as 1 instead of 0.""" - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] x = tf.convert_to_tensor(value=x) one = tf.ones_like(x) @@ -76,7 +76,7 @@ def safe_cospx_div_cosx( Returns: A tensor of shape `[A1, ..., An]` containing the resulting values. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] theta = tf.convert_to_tensor(value=theta) factor = tf.convert_to_tensor(value=factor, dtype=theta.dtype) if eps is None: @@ -88,7 +88,7 @@ def safe_cospx_div_cosx( # factors as small as 1e-10 correctly, while preventing a division by zero. eps *= tf.clip_by_value(1.0 / factor, 1.0, 1e10) sign = nonzero_sign(0.5 * np.pi - (theta - 0.5 * np.pi) % np.pi) - theta += sign * eps + theta += sign * eps # pyrefly: ignore[unsupported-operation] div = tf.cos(factor * theta) / tf.cos(theta) return asserts.assert_no_infs_or_nans(div) @@ -138,7 +138,7 @@ def safe_shrink( Returns: A tensor of shape `[A1, ..., An]` containing the shrinked values. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] vector = tf.convert_to_tensor(value=vector) if eps is None: eps = asserts.select_eps_for_addition(vector.dtype) @@ -181,7 +181,7 @@ def safe_signed_div( Returns: A tensor of shape `[A1, ..., An]` containing the results of division. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] a = tf.convert_to_tensor(value=a) b = tf.convert_to_tensor(value=b) if eps is None: @@ -222,7 +222,7 @@ def safe_sinpx_div_sinx( Returns: A tensor of shape `[A1, ..., An]` containing the resulting values. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] theta = tf.convert_to_tensor(value=theta) factor = tf.convert_to_tensor(value=factor, dtype=theta.dtype) if eps is None: @@ -234,7 +234,7 @@ def safe_sinpx_div_sinx( # factors as small as 1e-10 correctly, while preventing a division by zero. eps *= tf.clip_by_value(1.0 / factor, 1.0, 1e10) sign = nonzero_sign(0.5 * np.pi - theta % np.pi) - theta += sign * eps + theta += sign * eps # pyrefly: ignore[unsupported-operation] div = tf.sin(factor * theta) / tf.sin(theta) return asserts.assert_no_infs_or_nans(div) @@ -264,7 +264,7 @@ def safe_unsigned_div( Returns: A tensor of shape `[A1, ..., An]` containing the results of division. """ - with tf.name_scope(name): + with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] a = tf.convert_to_tensor(value=a) b = tf.convert_to_tensor(value=b) if eps is None: diff --git a/tensorflow_graphics/util/shape.py b/tensorflow_graphics/util/shape.py index 685d616e1..c4c8556bf 100644 --- a/tensorflow_graphics/util/shape.py +++ b/tensorflow_graphics/util/shape.py @@ -22,8 +22,8 @@ import numpy as np import six -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] import tensorflow as tf diff --git a/tensorflow_graphics/util/test_case.py b/tensorflow_graphics/util/test_case.py index f1ac35545..ce6e783ac 100644 --- a/tensorflow_graphics/util/test_case.py +++ b/tensorflow_graphics/util/test_case.py @@ -27,7 +27,7 @@ from absl import flags from absl.testing import parameterized import numpy as np -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 tfg_flags @@ -104,7 +104,7 @@ def _compute_gradient_error(self, x, y, x_init, delta=1e-6): max_error = np.maximum(error, diff.max()) row_max_error, column_max_error = np.unravel_index( diff.argmax(), diff.shape) - return max_error, row_max_error, column_max_error + return max_error, row_max_error, column_max_error # pyrefly: ignore[unbound-name] def _create_placeholders_from_shapes(self, shapes,