Skip to content

Commit

Permalink
Use Any instead of KerasTensor type in inference module because mypy …
Browse files Browse the repository at this point in the history
…was not happy
  • Loading branch information
bhky committed Dec 28, 2023
1 parent bc1a1b2 commit db590bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions opennsfw2/_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._download import get_default_weights_path
from ._image import preprocess_image, Preprocessing
from ._model import make_open_nsfw_model
from ._typing import KerasTensor, NDFloat32Array
from ._typing import NDFloat32Array

global_model: Optional[Model] = None
global_model_path: Optional[str] = None
Expand Down Expand Up @@ -67,7 +67,7 @@ def _predict_from_image_paths_in_batches(
to use the API in loops. See here:
https://keras.io/api/models/model_training_apis/#predict-method
"""
prediction_batches: List[KerasTensor] = []
prediction_batches: List[Any] = []
for i in range(0, len(image_paths), batch_size):
path_batch = image_paths[i: i + batch_size]
image_batch = [
Expand Down Expand Up @@ -138,7 +138,7 @@ def _predict_preprocessed_images_in_batches(
images: List[NDFloat32Array],
batch_size: int
) -> NDFloat32Array:
prediction_batches: List[KerasTensor] = []
prediction_batches: List[Any] = []
for i in range(0, len(images), batch_size):
batch = np.array(images[i: i + batch_size])
prediction_batches.append(model_(batch))
Expand Down

0 comments on commit db590bf

Please sign in to comment.