Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bhky committed Jan 24, 2025
2 parents b4f9034 + d13d07f commit b4d8102
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install tools
run: |
python3 -m pip install pylint
python3 -m pip install mypy
python3 -m pip install mypy==1.12.1
- name: Test
run: |
./tests/install_from_local_and_test.sh
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ python3 -m pip install .

## Notations

- `NDFloatArray`: NumPy float array type, which is an alias to `np.typing.NDArray[np.float_]`.
The values are converted to `np.float32` internally.
- `NDFloatArray`: NumPy float array type. The values are converted to `np.float32` internally.
- `tf.Tensor`: General TensorFlow Tensor type. The values are converted to `tf.float32` internally.

## Data format
Expand Down
2 changes: 1 addition & 1 deletion examples/kaggle/run_tf_dataset_kaggle_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import targetran.tf as tt
import tensorflow as tf

NDAnyArray = np.typing.NDArray[np.float_]
NDAnyArray = np.typing.NDArray[np.float32]

# This will be the data path when you use "Add Data" on the right panel
# of a Kaggle Notebook.
Expand Down
2 changes: 1 addition & 1 deletion examples/local/run_pt_dataset_local_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
from targetran.utils import Compose, collate_fn

NDAnyArray = np.typing.NDArray[np.float_]
NDAnyArray = np.typing.NDArray[np.float32]


def load_images() -> Dict[str, NDAnyArray]:
Expand Down
2 changes: 1 addition & 1 deletion examples/local/run_tf_dataset_local_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
TFResize,
)

NDAnyArray = np.typing.NDArray[np.float_]
NDAnyArray = np.typing.NDArray[np.float32]


def load_images() -> Dict[str, NDAnyArray]:
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = targetran
version = attr: targetran.__version__
author = attr: targetran.__author__
author_email = xtorch501@gmail.com
author_email = bhky.dev@gmail.com
description = Target transformation for data augmentation in objection detection
long_description = file: README.md
long_description_content_type = text/markdown
Expand All @@ -20,4 +20,4 @@ install_requires =
numpy>=1.22.0

[options.package_data]
targetran = py.typed
targetran = py.typed
4 changes: 3 additions & 1 deletion targetran/_np_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ def _np_resize_image(
"""
dest_size: (image_height, image_width)
"""
resized_image: NDAnyArray = cv2.resize( # pylint: disable=no-member
# pylint: disable=no-member
resized_image: NDFloatArray = cv2.resize(
image,
dsize=(dest_size[1], dest_size[0]),
interpolation=_INTERPOLATION_DICT[interpolation]
)
# pylint: enable=no-member
return resized_image


Expand Down
2 changes: 1 addition & 1 deletion targetran/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ArrayLike = np.typing.ArrayLike
NDAnyArray = np.typing.NDArray[Any]
NDBoolArray = np.typing.NDArray[np.bool_]
NDFloatArray = np.typing.NDArray[np.float_]
NDFloatArray = NDAnyArray # Not nice, but since NumPy 2.0 there's no better way yet.
NDIntArray = np.typing.NDArray[np.int_]

# T is treated semantically as "NDAnyArray or tf.Tensor" in this library.
Expand Down
5 changes: 2 additions & 3 deletions targetran/np/_np.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,8 @@ def _get_mats(
else:
self._rng.shuffle(indices)

indices = indices.tolist()
image_dest_tran_mats = np.take(image_dest_tran_mats, indices, 0)
bboxes_tran_mats = np.take(bboxes_tran_mats, indices, 0)
image_dest_tran_mats = np.take(image_dest_tran_mats, indices.tolist(), 0)
bboxes_tran_mats = np.take(bboxes_tran_mats, indices.tolist(), 0)

image_dest_tran_mat = np.linalg.multi_dot(image_dest_tran_mats)
# Note the reversed order for the bboxes tran matrices.
Expand Down
2 changes: 1 addition & 1 deletion tests/run_pt_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import targetran.np
from targetran.utils import Compose, collate_fn

NDAnyArray = np.typing.NDArray[np.float_]
NDAnyArray = np.typing.NDArray[np.float32]


def make_np_data() -> Tuple[Sequence[NDAnyArray],
Expand Down
2 changes: 1 addition & 1 deletion tests/run_tf_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import targetran.tf

NDAnyArray = np.typing.NDArray[np.float_]
NDAnyArray = np.typing.NDArray[np.float32]


def make_np_data() -> Tuple[Sequence[NDAnyArray],
Expand Down

0 comments on commit b4d8102

Please sign in to comment.