Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tensorflow_graphics/geometry/convolution/graph_convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def feature_steered_convolution(
ValueError: if the input dimensions are invalid.
"""
# pyformat: enable
with tf.name_scope(name): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
data = tf.convert_to_tensor(value=data)
neighbors = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=neighbors)
if sizes is not None:
Expand Down Expand Up @@ -239,7 +239,7 @@ def edge_convolution_template(
ValueError: if the input dimensions are invalid.
"""
# pyformat: enable
with tf.name_scope(name): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
data = tf.convert_to_tensor(value=data)
neighbors = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=neighbors)
if sizes is not None:
Expand Down
6 changes: 3 additions & 3 deletions tensorflow_graphics/geometry/convolution/graph_pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def pool(data: type_alias.TensorLike,
ValueError: if `algorithm` is invalid.
"""
# pyformat: enable
with tf.name_scope(name): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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:
Expand Down Expand Up @@ -161,7 +161,7 @@ def unpool(data: type_alias.TensorLike,
ValueError: if the input dimensions are invalid.
"""
# pyformat: enable
with tf.name_scope(name): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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:
Expand Down Expand Up @@ -253,7 +253,7 @@ def upsample_transposed_convolution(
ValueError: if the input dimensions are invalid.
"""
# pyformat: enable
with tf.name_scope(name): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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:
Expand Down
10 changes: 5 additions & 5 deletions tensorflow_graphics/geometry/convolution/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
data = tf.convert_to_tensor(value=data)
if sizes is not None:
sizes = tf.convert_to_tensor(value=sizes)
Expand All @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
flat = tf.convert_to_tensor(value=flat)
output_shape = tf.concat((data_shape[:-1], tf.shape(input=flat)[-1:]),
axis=0)
Expand All @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
flat = tf.convert_to_tensor(value=flat)
output_shape = tf.concat((data_shape[:-1], tf.shape(input=flat)[-1:]),
axis=0)
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
data = tf.convert_to_tensor(value=data)
sizes = tf.convert_to_tensor(value=sizes)
if max_rows is None:
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
data = tf.compat.v1.convert_to_tensor_or_sparse_tensor(value=data)
if sizes is not None:
sizes = tf.convert_to_tensor(value=sizes)
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_graphics/geometry/representation/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
starts = tf.convert_to_tensor(value=starts)
stops = tf.convert_to_tensor(value=stops)
nums = tf.convert_to_tensor(value=nums)
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_graphics/geometry/representation/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
point = tf.convert_to_tensor(value=point)
origin = tf.convert_to_tensor(value=origin)
direction = tf.convert_to_tensor(value=direction)
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
point = tf.convert_to_tensor(value=point)
origin = tf.convert_to_tensor(value=origin)
direction = tf.convert_to_tensor(value=direction)
Expand Down
10 changes: 5 additions & 5 deletions tensorflow_graphics/geometry/representation/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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,))
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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,))
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
shape.check_static(
tensor=ray_org,
tensor_name="ray_org",
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
startpoints = tf.convert_to_tensor(value=startpoints)
endpoints = tf.convert_to_tensor(value=endpoints)
weights = tf.convert_to_tensor(value=weights)
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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)
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_graphics/geometry/representation/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
v0 = tf.convert_to_tensor(value=v0)
v1 = tf.convert_to_tensor(value=v1)
v2 = tf.convert_to_tensor(value=v2)
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
v0 = tf.convert_to_tensor(value=v0)
v1 = tf.convert_to_tensor(value=v1)
v2 = tf.convert_to_tensor(value=v2)
Expand Down
10 changes: 5 additions & 5 deletions tensorflow_graphics/image/matting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
image = tf.convert_to_tensor(value=image)
eps = tf.constant(value=eps, dtype=image.dtype)

Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
matte = tf.convert_to_tensor(value=matte)
pseudo_inverse = tf.convert_to_tensor(value=pseudo_inverse)

Expand All @@ -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) # pyrefly: ignore[unsupported-operation]
coeffs = _image_average(coeffs, size) / _image_average(ones, size)
return tf.split(coeffs, (-1, 1), axis=-1)


Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
matte = tf.convert_to_tensor(value=matte)
laplacian = tf.convert_to_tensor(value=laplacian)

Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
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)
Expand Down
8 changes: 4 additions & 4 deletions tensorflow_graphics/image/pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
image = tf.convert_to_tensor(value=image)

shape.check_static(tensor=image, tensor_name="image", has_rank=4)
Expand All @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
levels = [tf.convert_to_tensor(value=level) for level in levels]

for index, level in enumerate(levels):
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
image = tf.convert_to_tensor(value=image)

shape.check_static(tensor=image, tensor_name="image", has_rank=4)
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
image = tf.convert_to_tensor(value=image)

shape.check_static(tensor=image, tensor_name="image", has_rank=4)
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_graphics/image/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
image = tf.convert_to_tensor(value=image, name="image")
warp = tf.convert_to_tensor(value=warp, name="warp")

Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
image = tf.convert_to_tensor(value=image, name="image")
transform_matrix = tf.convert_to_tensor(
value=transform_matrix, name="transform_matrix")
Expand Down
22 changes: 11 additions & 11 deletions tensorflow_graphics/math/interpolation/bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) # pyrefly: ignore[unsupported-operation]
return tf.expand_dims(tf.clip_by_value(1.0 + position, 1.0, 1.0), axis=-1)


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) # pyrefly: ignore[unsupported-operation]
return tf.stack((1.0 - position, position), axis=-1)


def _quadratic(position: tf.Tensor) -> tf.Tensor:
Expand All @@ -59,30 +59,30 @@ 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, # pyrefly: ignore[unsupported-operation]
return tf.stack((tf.pow(1.0 - position, 2.0) / 2.0, -pos_sq + position + 0.5,
pos_sq / 2.0),
axis=-1)


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 # pyrefly: ignore[unsupported-operation]
neg_pos = 1.0 - position
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, # pyrefly: ignore[unsupported-operation]
(-3.0 * pos_cb + 3.0 * pos_sq + 3.0 * position + 1.0) / 6.0,
pos_cb / 6.0),
axis=-1)


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 # pyrefly: ignore[unsupported-operation]
neg_pos = 1.0 - position
pos_sq = tf.pow(position, 2.0)
pos_cb = tf.pow(position, 3.0)
pos_qt = tf.pow(position, 4.0)
Expand All @@ -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, # 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]
(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) /
24.0, pos_qt / 24.0),
axis=-1)

Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
positions = tf.convert_to_tensor(value=positions)

if degree > 4 or degree < 0:
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
knots = tf.convert_to_tensor(value=knots)
weights = tf.convert_to_tensor(value=weights)

Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
knots = tf.convert_to_tensor(value=knots)
positions = tf.convert_to_tensor(value=positions)

Expand Down
6 changes: 3 additions & 3 deletions tensorflow_graphics/math/interpolation/slerp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
return weight1 * vector1 + weight2 * vector2


Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
quaternion1 = tf.convert_to_tensor(value=quaternion1)
quaternion2 = tf.convert_to_tensor(value=quaternion2)
percent = tf.convert_to_tensor(value=percent, dtype=quaternion1.dtype)
Expand Down Expand Up @@ -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): # pyrefly: ignore[bad-instantiation]
with tf.name_scope(name):
vector1 = tf.convert_to_tensor(value=vector1)
vector2 = tf.convert_to_tensor(value=vector2)
percent = tf.convert_to_tensor(value=percent, dtype=vector1.dtype)
Expand Down
Loading
Loading