
"""simple docstring"""


import collections
import inspect
import unittest

from transformers import SwinvaConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch
      from torch import nn

      from transformers import SwinvaForImageClassification, SwinvaForMaskedImageModeling, SwinvaModel
      from transformers.models.swinva.modeling_swinva import SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
      from PIL import Image

      from transformers import AutoImageProcessor



class   __a  :






       def __init__(  self :							int       ,      UpperCAmelCase_ :							Optional[int]       ,      UpperCAmelCase_ :							Union[str, Any]=13       ,      UpperCAmelCase_ :							Optional[int]=32       ,      UpperCAmelCase_ :							Optional[Any]=2       ,      UpperCAmelCase_ :							Optional[int]=3       ,      UpperCAmelCase_ :							str=16       ,      UpperCAmelCase_ :							Union[str, Any]=[1, 2, 1]       ,      UpperCAmelCase_ :							int=[2, 2, 4]       ,      UpperCAmelCase_ :							Any=2       ,      UpperCAmelCase_ :							int=2.0       ,      UpperCAmelCase_ :							Union[str, Any]=True       ,      UpperCAmelCase_ :							str=0.0       ,      UpperCAmelCase_ :							Tuple=0.0       ,      UpperCAmelCase_ :							int=0.1       ,      UpperCAmelCase_ :							List[str]="gelu"       ,      UpperCAmelCase_ :							Tuple=False       ,      UpperCAmelCase_ :							Dict=True       ,      UpperCAmelCase_ :							List[str]=0.02       ,      UpperCAmelCase_ :							Tuple=1e-5       ,      UpperCAmelCase_ :							Dict=True       ,      UpperCAmelCase_ :							Optional[int]=None       ,      UpperCAmelCase_ :							Union[str, Any]=True       ,      UpperCAmelCase_ :							int=10       ,      UpperCAmelCase_ :							Optional[int]=8       ,      )->  str:







              """simple docstring"""
              UpperCamelCase					 =		parent
              UpperCamelCase					 =		batch_size
              UpperCamelCase					 =		image_size
              UpperCamelCase					 =		patch_size
              UpperCamelCase					 =		num_channels
              UpperCamelCase					 =		embed_dim
              UpperCamelCase					 =		depths
              UpperCamelCase					 =		num_heads
              UpperCamelCase					 =		window_size
              UpperCamelCase					 =		mlp_ratio
              UpperCamelCase					 =		qkv_bias
              UpperCamelCase					 =		hidden_dropout_prob
              UpperCamelCase					 =		attention_probs_dropout_prob
              UpperCamelCase					 =		drop_path_rate
              UpperCamelCase					 =		hidden_act
              UpperCamelCase					 =		use_absolute_embeddings
              UpperCamelCase					 =		patch_norm
              UpperCamelCase					 =		layer_norm_eps
              UpperCamelCase					 =		initializer_range
              UpperCamelCase					 =		is_training
              UpperCamelCase					 =		scope
              UpperCamelCase					 =		use_labels
              UpperCamelCase					 =		type_sequence_label_size
              UpperCamelCase					 =		encoder_stride






       def 	_SCREAMING_SNAKE_CASE       (  self :							str			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase					 =		floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

              UpperCamelCase					 =		None
              if self.use_labels:
                     UpperCamelCase					 =		ids_tensor([self.batch_size]       ,      self.type_sequence_label_size			)

              UpperCamelCase					 =		self.get_config()

              return config, pixel_values, labels






       def 	_SCREAMING_SNAKE_CASE       (  self :							Union[str, Any]			)->  Any:







              """simple docstring"""
              return SwinvaConfig(
                  image_size=self.image_size       ,      patch_size=self.patch_size       ,      num_channels=self.num_channels       ,      embed_dim=self.embed_dim       ,      depths=self.depths       ,      num_heads=self.num_heads       ,      window_size=self.window_size       ,      mlp_ratio=self.mlp_ratio       ,      qkv_bias=self.qkv_bias       ,      hidden_dropout_prob=self.hidden_dropout_prob       ,      attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,      drop_path_rate=self.drop_path_rate       ,      hidden_act=self.hidden_act       ,      use_absolute_embeddings=self.use_absolute_embeddings       ,      path_norm=self.patch_norm       ,      layer_norm_eps=self.layer_norm_eps       ,      initializer_range=self.initializer_range       ,      encoder_stride=self.encoder_stride       ,      )






       def 	_SCREAMING_SNAKE_CASE       (  self :							str       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							str       ,      UpperCAmelCase_ :							List[str]			)->  str:







              """simple docstring"""
              UpperCamelCase					 =		SwinvaModel(config=UpperCAmelCase_			)
              model.to(UpperCAmelCase_			)
              model.eval()
              UpperCamelCase					 =		model(UpperCAmelCase_			)

              UpperCamelCase					 =		((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths			) - 1))
              UpperCamelCase					 =		int(config.embed_dim * 2 ** (len(config.depths			) - 1)			)

              self.parent.assertEqual(result.last_hidden_state.shape       ,      (self.batch_size, expected_seq_len, expected_dim)			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							str       ,      UpperCAmelCase_ :							Union[str, Any]       ,      UpperCAmelCase_ :							Any       ,      UpperCAmelCase_ :							Union[str, Any]			)->  Any:







              """simple docstring"""
              UpperCamelCase					 =		SwinvaForMaskedImageModeling(config=UpperCAmelCase_			)
              model.to(UpperCAmelCase_			)
              model.eval()
              UpperCamelCase					 =		model(UpperCAmelCase_			)
              self.parent.assertEqual(
                  result.logits.shape       ,      (self.batch_size, self.num_channels, self.image_size, self.image_size)			)

              # test greyscale images
              UpperCamelCase					 =		1
              UpperCamelCase					 =		SwinvaForMaskedImageModeling(UpperCAmelCase_			)
              model.to(UpperCAmelCase_			)
              model.eval()

              UpperCamelCase					 =		floats_tensor([self.batch_size, 1, self.image_size, self.image_size]			)
              UpperCamelCase					 =		model(UpperCAmelCase_			)
              self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, 1, self.image_size, self.image_size)			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							str       ,      UpperCAmelCase_ :							List[str]       ,      UpperCAmelCase_ :							Union[str, Any]       ,      UpperCAmelCase_ :							str			)->  List[Any]:







              """simple docstring"""
              UpperCamelCase					 =		self.type_sequence_label_size
              UpperCamelCase					 =		SwinvaForImageClassification(UpperCAmelCase_			)
              model.to(UpperCAmelCase_			)
              model.eval()
              UpperCamelCase					 =		model(UpperCAmelCase_       ,      labels=UpperCAmelCase_			)
              self.parent.assertEqual(result.logits.shape       ,      (self.batch_size, self.type_sequence_label_size)			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							str			)->  Tuple:







              """simple docstring"""
              UpperCamelCase					 =		self.prepare_config_and_inputs()
              UpperCamelCase ,       UpperCamelCase ,       UpperCamelCase					 =		config_and_inputs
              UpperCamelCase					 =		{"pixel_values": pixel_values}
              return config, inputs_dict





@require_torch
class   __a  (      _lowerCAmelCase    ,     _lowerCAmelCase    ,     unittest.TestCase	):
       UpperCamelCase_		:					Optional[Any]   =			(
           (SwinvaModel, SwinvaForImageClassification, SwinvaForMaskedImageModeling) if is_torch_available() else ()
       )
       UpperCamelCase_		:					int   =			(
           {'''feature-extraction''': SwinvaModel, '''image-classification''': SwinvaForImageClassification}
           if is_torch_available()
           else {}
       )

       UpperCamelCase_		:					List[str]   =			False
       UpperCamelCase_		:					Optional[int]   =			False
       UpperCamelCase_		:					Any   =			False
       UpperCamelCase_		:					str   =			False






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[Any]			)->  Optional[Any]:







              """simple docstring"""
              UpperCamelCase					 =		SwinvaModelTester(self			)
              UpperCamelCase					 =		ConfigTester(self       ,      config_class=UpperCAmelCase_       ,      embed_dim=37			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Any			)->  int:







              """simple docstring"""
              self.config_tester.create_and_test_config_to_json_string()
              self.config_tester.create_and_test_config_to_json_file()
              self.config_tester.create_and_test_config_from_and_save_pretrained()
              self.config_tester.create_and_test_config_with_num_labels()
              self.config_tester.check_config_can_be_init_without_params()
              self.config_tester.check_config_arguments_init()






       def 	_SCREAMING_SNAKE_CASE       (  self :							int			)->  Dict:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_model(*UpperCAmelCase_			)






       @unittest.skip(reason="Got `CUDA error: misaligned address` with PyTorch 2.0.0."			)
       def 	_SCREAMING_SNAKE_CASE       (  self :							List[str]			)->  str:







              """simple docstring"""
              pass






       @unittest.skip(reason="Swinv2 does not use inputs_embeds"			)
       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]			)->  int:







              """simple docstring"""
              pass






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[Any]			)->  Tuple:







              """simple docstring"""
              UpperCamelCase ,       UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs_for_common()

              for model_class in self.all_model_classes:
                     UpperCamelCase					 =		model_class(UpperCAmelCase_			)
                     self.assertIsInstance(model.get_input_embeddings()       ,      (nn.Module)			)
                     UpperCamelCase					 =		model.get_output_embeddings()
                     self.assertTrue(x is None or isinstance(UpperCAmelCase_       ,      nn.Linear			)			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  List[str]:







              """simple docstring"""
              UpperCamelCase ,       UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs_for_common()

              for model_class in self.all_model_classes:
                     UpperCamelCase					 =		model_class(UpperCAmelCase_			)
                     UpperCamelCase					 =		inspect.signature(model.forward			)
                     # signature.parameters is an OrderedDict => so arg_names order is deterministic
                     UpperCamelCase					 =		[*signature.parameters.keys()]

                     UpperCamelCase					 =		["pixel_values"]
                     self.assertListEqual(arg_names[:1]       ,      UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Dict			)->  str:







              """simple docstring"""
              UpperCamelCase ,       UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs_for_common()
              UpperCamelCase					 =		True

              for model_class in self.all_model_classes:
                     UpperCamelCase					 =		True
                     UpperCamelCase					 =		False
                     UpperCamelCase					 =		True
                     UpperCamelCase					 =		model_class(UpperCAmelCase_			)
                     model.to(UpperCAmelCase_			)
                     model.eval()
                     with torch.no_grad():
                            UpperCamelCase					 =		model(**self._prepare_for_class(UpperCAmelCase_       ,      UpperCAmelCase_			)			)
                     UpperCamelCase					 =		outputs.attentions
                     UpperCamelCase					 =		len(self.model_tester.depths			)
                     self.assertEqual(len(UpperCAmelCase_			)       ,      UpperCAmelCase_			)

                     # check that output_attentions also work using config
                     del inputs_dict["output_attentions"]
                     UpperCamelCase					 =		True
                     UpperCamelCase					 =		config.window_size**2
                     UpperCamelCase					 =		model_class(UpperCAmelCase_			)
                     model.to(UpperCAmelCase_			)
                     model.eval()
                     with torch.no_grad():
                            UpperCamelCase					 =		model(**self._prepare_for_class(UpperCAmelCase_       ,      UpperCAmelCase_			)			)
                     UpperCamelCase					 =		outputs.attentions
                     self.assertEqual(len(UpperCAmelCase_			)       ,      UpperCAmelCase_			)

                     self.assertListEqual(
                         list(attentions[0].shape[-3:]			)       ,      [self.model_tester.num_heads[0], window_size_squared, window_size_squared]       ,      )
                     UpperCamelCase					 =		len(UpperCAmelCase_			)

                     # Check attention is always last and order is fine
                     UpperCamelCase					 =		True
                     UpperCamelCase					 =		True
                     UpperCamelCase					 =		model_class(UpperCAmelCase_			)
                     model.to(UpperCAmelCase_			)
                     model.eval()
                     with torch.no_grad():
                            UpperCamelCase					 =		model(**self._prepare_for_class(UpperCAmelCase_       ,      UpperCAmelCase_			)			)

                     if hasattr(self.model_tester       ,      "num_hidden_states_types"			):
                            UpperCamelCase					 =		self.model_tester.num_hidden_states_types
                     else:
                            # also another +1 for reshaped_hidden_states
                            UpperCamelCase					 =		2
                     self.assertEqual(out_len + added_hidden_states       ,      len(UpperCAmelCase_			)			)

                     UpperCamelCase					 =		outputs.attentions

                     self.assertEqual(len(UpperCAmelCase_			)       ,      UpperCAmelCase_			)

                     self.assertListEqual(
                         list(self_attentions[0].shape[-3:]			)       ,      [self.model_tester.num_heads[0], window_size_squared, window_size_squared]       ,      )






       def 	_SCREAMING_SNAKE_CASE       (  self :							Optional[int]       ,      UpperCAmelCase_ :							Dict       ,      UpperCAmelCase_ :							Optional[int]       ,      UpperCAmelCase_ :							Optional[int]       ,      UpperCAmelCase_ :							List[str]			)->  str:







              """simple docstring"""
              UpperCamelCase					 =		model_class(UpperCAmelCase_			)
              model.to(UpperCAmelCase_			)
              model.eval()

              with torch.no_grad():
                     UpperCamelCase					 =		model(**self._prepare_for_class(UpperCAmelCase_       ,      UpperCAmelCase_			)			)

              UpperCamelCase					 =		outputs.hidden_states

              UpperCamelCase					 =		getattr(
                  self.model_tester       ,      "expected_num_hidden_layers"       ,      len(self.model_tester.depths			) + 1			)
              self.assertEqual(len(UpperCAmelCase_			)       ,      UpperCAmelCase_			)

              # Swinv2 has a different seq_length
              UpperCamelCase					 =		(
                  config.patch_size
                  if isinstance(config.patch_size       ,      collections.abc.Iterable			)
                  else (config.patch_size, config.patch_size)
              )

              UpperCamelCase					 =		(image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

              self.assertListEqual(
                  list(hidden_states[0].shape[-2:]			)       ,      [num_patches, self.model_tester.embed_dim]       ,      )

              UpperCamelCase					 =		outputs.reshaped_hidden_states
              self.assertEqual(len(UpperCAmelCase_			)       ,      UpperCAmelCase_			)

              UpperCamelCase ,       UpperCamelCase ,       UpperCamelCase ,       UpperCamelCase					 =		reshaped_hidden_states[0].shape
              UpperCamelCase					 =		(
                  reshaped_hidden_states[0].view(UpperCAmelCase_       ,      UpperCAmelCase_       ,      height * width			).permute(0       ,      2       ,      1			)
              )
              self.assertListEqual(
                  list(reshaped_hidden_states.shape[-2:]			)       ,      [num_patches, self.model_tester.embed_dim]       ,      )






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[str]			)->  Union[str, Any]:







              """simple docstring"""
              UpperCamelCase ,       UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase					 =		(
                  self.model_tester.image_size
                  if isinstance(self.model_tester.image_size       ,      collections.abc.Iterable			)
                  else (self.model_tester.image_size, self.model_tester.image_size)
              )

              for model_class in self.all_model_classes:
                     UpperCamelCase					 =		True
                     self.check_hidden_states_output(UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_			)

                     # check that output_hidden_states also work using config
                     del inputs_dict["output_hidden_states"]
                     UpperCamelCase					 =		True

                     self.check_hidden_states_output(UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[str]			)->  Dict:







              """simple docstring"""
              UpperCamelCase ,       UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs_for_common()
              UpperCamelCase					 =		3

              UpperCamelCase					 =		(
                  self.model_tester.image_size
                  if isinstance(self.model_tester.image_size       ,      collections.abc.Iterable			)
                  else (self.model_tester.image_size, self.model_tester.image_size)
              )
              UpperCamelCase					 =		(
                  config.patch_size
                  if isinstance(config.patch_size       ,      collections.abc.Iterable			)
                  else (config.patch_size, config.patch_size)
              )

              UpperCamelCase					 =		image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
              UpperCamelCase					 =		image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

              for model_class in self.all_model_classes:
                     UpperCamelCase					 =		True
                     self.check_hidden_states_output(UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_       ,      (padded_height, padded_width)			)

                     # check that output_hidden_states also work using config
                     del inputs_dict["output_hidden_states"]
                     UpperCamelCase					 =		True
                     self.check_hidden_states_output(UpperCAmelCase_       ,      UpperCAmelCase_       ,      UpperCAmelCase_       ,      (padded_height, padded_width)			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							Union[str, Any]			)->  int:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_masked_image_modeling(*UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  Any:







              """simple docstring"""
              UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs()
              self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase_			)






       @slow
       def 	_SCREAMING_SNAKE_CASE       (  self :							Dict			)->  Dict:







              """simple docstring"""
              for model_name in SWINV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                     UpperCamelCase					 =		SwinvaModel.from_pretrained(UpperCAmelCase_			)
                     self.assertIsNotNone(UpperCAmelCase_			)






       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  int:







              """simple docstring"""
              UpperCamelCase ,       UpperCamelCase					 =		self.model_tester.prepare_config_and_inputs_for_common()

              UpperCamelCase					 =		_config_zero_init(UpperCAmelCase_			)
              for model_class in self.all_model_classes:
                     UpperCamelCase					 =		model_class(config=UpperCAmelCase_			)
                     for name, param in model.named_parameters():
                            if "embeddings" not in name and "logit_scale" not in name and param.requires_grad:
                                   self.assertIn(
                                       ((param.data.mean() * 1e9).round() / 1e9).item()       ,      [0.0, 1.0]       ,      msg=f"Parameter {name} of model {model_class} seems not properly initialized"       ,      )





@require_vision
@require_torch
class   __a  (      unittest.TestCase	):






       @cached_property
       def 	_SCREAMING_SNAKE_CASE       (  self :							int			)->  Union[str, Any]:







              """simple docstring"""
              return (
                  AutoImageProcessor.from_pretrained("microsoft/swinv2-tiny-patch4-window8-256"			)
                  if is_vision_available()
                  else None
              )






       @slow
       def 	_SCREAMING_SNAKE_CASE       (  self :							List[Any]			)->  List[str]:







              """simple docstring"""
              UpperCamelCase					 =		SwinvaForImageClassification.from_pretrained("microsoft/swinv2-tiny-patch4-window8-256"			).to(
                  UpperCAmelCase_			)
              UpperCamelCase					 =		self.default_image_processor

              UpperCamelCase					 =		Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"			)
              UpperCamelCase					 =		image_processor(images=UpperCAmelCase_       ,      return_tensors="pt"			).to(UpperCAmelCase_			)

              # forward pass
              with torch.no_grad():
                     UpperCamelCase					 =		model(**UpperCAmelCase_			)

              # verify the logits
              UpperCamelCase					 =		torch.Size((1, 1_000)			)
              self.assertEqual(outputs.logits.shape       ,      UpperCAmelCase_			)
              UpperCamelCase					 =		torch.tensor([-0.3947, -0.4306, 0.0026]			).to(UpperCAmelCase_			)
              self.assertTrue(torch.allclose(outputs.logits[0, :3]       ,      UpperCAmelCase_       ,      atol=1e-4			)			)







"""simple docstring"""


import numpy as np

# Importing the Keras libraries and packages
import tensorflow as tf
from tensorflow.keras import layers, models

if __name__ == "__main__":
      # Initialising the CNN
      # (Sequential- Building the model layer by layer)
      SCREAMING_SNAKE_CASE      =     models.Sequential()

      # Step 1 - Convolution
      # Here 64,64 is the length & breadth of dataset images and 3 is for the RGB channel
      # (3,3) is the kernel size (filter matrix)
      classifier.add(
          layers.ConvaD(32, (3, 3), input_shape=(64, 64, 3), activation="""relu""")
      )

      # Step 2 - Pooling
      classifier.add(layers.MaxPoolingaD(pool_size=(2, 2)))

      # Adding a second convolutional layer
      classifier.add(layers.ConvaD(32, (3, 3), activation="""relu"""))
      classifier.add(layers.MaxPoolingaD(pool_size=(2, 2)))

      # Step 3 - Flattening
      classifier.add(layers.Flatten())

      # Step 4 - Full connection
      classifier.add(layers.Dense(units=128, activation="""relu"""))
      classifier.add(layers.Dense(units=1, activation="""sigmoid"""))

      # Compiling the CNN
      classifier.compile(
          optimizer="""adam""", loss="""binary_crossentropy""", metrics=["""accuracy"""]
      )

      # Part 2 - Fitting the CNN to the images

      # Load Trained model weights

      # from keras.models import load_model
      # regressor=load_model('cnn.h5')

      SCREAMING_SNAKE_CASE      =     tf.keras.preprocessing.image.ImageDataGenerator(
          rescale=1.0 / 255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True
      )

      SCREAMING_SNAKE_CASE      =     tf.keras.preprocessing.image.ImageDataGenerator(rescale=1.0 / 255)

      SCREAMING_SNAKE_CASE      =     train_datagen.flow_from_directory(
          """dataset/training_set""", target_size=(64, 64), batch_size=32, class_mode="""binary"""
      )

      SCREAMING_SNAKE_CASE      =     test_datagen.flow_from_directory(
          """dataset/test_set""", target_size=(64, 64), batch_size=32, class_mode="""binary"""
      )

      classifier.fit_generator(
          training_set, steps_per_epoch=5, epochs=30, validation_data=test_set
      )

      classifier.save("""cnn.h5""")

      # Part 3 - Making new predictions

      SCREAMING_SNAKE_CASE      =     tf.keras.preprocessing.image.load_img(
          """dataset/single_prediction/image.png""", target_size=(64, 64)
      )
      SCREAMING_SNAKE_CASE      =     tf.keras.preprocessing.image.img_to_array(test_image)
      SCREAMING_SNAKE_CASE      =     np.expand_dims(test_image, axis=0)
      SCREAMING_SNAKE_CASE      =     classifier.predict(test_image)
      # training_set.class_indices
      if result[0][0] == 0:
            SCREAMING_SNAKE_CASE      =     """Normal"""
      if result[0][0] == 1:
            SCREAMING_SNAKE_CASE      =     """Abnormality detected"""





