
import inspect
import unittest

from datasets import load_dataset
from packaging import version

from transformers import BeitConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, 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 (
						    MODEL_MAPPING,
						    BeitForImageClassification,
						    BeitForMaskedImageModeling,
						    BeitForSemanticSegmentation,
						    BeitModel,
						)
						from transformers.models.beit.modeling_beit import BEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
						import PIL
						from PIL import Image

						from transformers import BeitImageProcessor





class   UpperCamelCase_      :







						'''simple docstring'''



						def __init__(			self							:List[str]		,    lowerCAmelCase__							:Dict		,    lowerCAmelCase__							:Optional[Any]=100		,    lowerCAmelCase__							:str=13		,    lowerCAmelCase__							:str=30		,    lowerCAmelCase__							:str=2		,    lowerCAmelCase__							:Tuple=3		,    lowerCAmelCase__							:Tuple=True		,    lowerCAmelCase__							:Tuple=True		,    lowerCAmelCase__							:List[str]=32		,    lowerCAmelCase__							:Dict=4		,    lowerCAmelCase__							:int=4		,    lowerCAmelCase__							:List[Any]=37		,    lowerCAmelCase__							:str="gelu"		,    lowerCAmelCase__							:str=0.1		,    lowerCAmelCase__							:Tuple=0.1		,    lowerCAmelCase__							:Optional[Any]=10		,    lowerCAmelCase__							:Any=0.02		,    lowerCAmelCase__							:Tuple=3		,    lowerCAmelCase__							:Dict=None		,    lowerCAmelCase__							:Any=[0, 1, 2, 3]		,    )  ->str:
										lowercase         =      parent
										lowercase         =      100
										lowercase         =      batch_size
										lowercase         =      image_size
										lowercase         =      patch_size
										lowercase         =      num_channels
										lowercase         =      is_training
										lowercase         =      use_labels
										lowercase         =      hidden_size
										lowercase         =      num_hidden_layers
										lowercase         =      num_attention_heads
										lowercase         =      intermediate_size
										lowercase         =      hidden_act
										lowercase         =      hidden_dropout_prob
										lowercase         =      attention_probs_dropout_prob
										lowercase         =      type_sequence_label_size
										lowercase         =      initializer_range
										lowercase         =      scope
										lowercase         =      out_indices
										lowercase         =      num_labels

										# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
										lowercase         =      (image_size // patch_size) ** 2
										lowercase         =      num_patches + 1





						def        SCREAMING_SNAKE_CASE(			self							:Optional[int]     )  ->str:
										lowercase         =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]     )

										lowercase         =      None
										lowercase         =      None
										if self.use_labels:
														lowercase         =      ids_tensor([self.batch_size]		,    self.type_sequence_label_size     )
														lowercase         =      ids_tensor([self.batch_size, self.image_size, self.image_size]		,    self.num_labels     )

										lowercase         =      self.get_config()

										return config, pixel_values, labels, pixel_labels





						def        SCREAMING_SNAKE_CASE(			self							:Any     )  ->Tuple:
										return BeitConfig(
										    vocab_size=self.vocab_size		,    image_size=self.image_size		,    patch_size=self.patch_size		,    num_channels=self.num_channels		,    hidden_size=self.hidden_size		,    num_hidden_layers=self.num_hidden_layers		,    num_attention_heads=self.num_attention_heads		,    intermediate_size=self.intermediate_size		,    hidden_act=self.hidden_act		,    hidden_dropout_prob=self.hidden_dropout_prob		,    attention_probs_dropout_prob=self.attention_probs_dropout_prob		,    is_decoder=lowerCAmelCase__		,    initializer_range=self.initializer_range		,    out_indices=self.out_indices		,    )





						def        SCREAMING_SNAKE_CASE(			self							:Dict		,    lowerCAmelCase__							:int		,    lowerCAmelCase__							:Any		,    lowerCAmelCase__							:Tuple		,    lowerCAmelCase__							:Tuple     )  ->List[Any]:
										lowercase         =      BeitModel(config=lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__     )
										self.parent.assertEqual(result.last_hidden_state.shape		,    (self.batch_size, self.seq_length, self.hidden_size)     )





						def        SCREAMING_SNAKE_CASE(			self							:Optional[int]		,    lowerCAmelCase__							:Tuple		,    lowerCAmelCase__							:str		,    lowerCAmelCase__							:int		,    lowerCAmelCase__							:Optional[int]     )  ->Any:
										lowercase         =      BeitForMaskedImageModeling(config=lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__     )
										self.parent.assertEqual(result.logits.shape		,    (self.batch_size, self.seq_length - 1, self.vocab_size)     )





						def        SCREAMING_SNAKE_CASE(			self							:Any		,    lowerCAmelCase__							:Optional[Any]		,    lowerCAmelCase__							:str		,    lowerCAmelCase__							:Any		,    lowerCAmelCase__							:Tuple     )  ->List[Any]:
										lowercase         =      self.type_sequence_label_size
										lowercase         =      BeitForImageClassification(lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__		,    labels=lowerCAmelCase__     )
										self.parent.assertEqual(result.logits.shape		,    (self.batch_size, self.type_sequence_label_size)     )

										# test greyscale images
										lowercase         =      1
										lowercase         =      BeitForImageClassification(lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()

										lowercase         =      floats_tensor([self.batch_size, 1, self.image_size, self.image_size]     )
										lowercase         =      model(lowerCAmelCase__		,    labels=lowerCAmelCase__     )
										self.parent.assertEqual(result.logits.shape		,    (self.batch_size, self.type_sequence_label_size)     )





						def        SCREAMING_SNAKE_CASE(			self							:Dict		,    lowerCAmelCase__							:Dict		,    lowerCAmelCase__							:Union[str, Any]		,    lowerCAmelCase__							:Optional[Any]		,    lowerCAmelCase__							:Any     )  ->List[str]:
										lowercase         =      self.num_labels
										lowercase         =      BeitForSemanticSegmentation(lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__     )
										self.parent.assertEqual(
										    result.logits.shape		,    (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)     )
										lowercase         =      model(lowerCAmelCase__		,    labels=lowerCAmelCase__     )
										self.parent.assertEqual(
										    result.logits.shape		,    (self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)     )





						def        SCREAMING_SNAKE_CASE(			self							:List[str]     )  ->Union[str, Any]:
										lowercase         =      self.prepare_config_and_inputs()
										lowercase     ,	lowercase     ,	lowercase     ,	lowercase         =      config_and_inputs
										lowercase         =      {"pixel_values": pixel_values}
										return config, inputs_dict





@require_torch
class   UpperCamelCase_      (      __a		,    __a		,    unittest.TestCase		):







						'''simple docstring'''



						UpperCamelCase      :  List[Any]				   =					(
						    (BeitModel, BeitForImageClassification, BeitForMaskedImageModeling, BeitForSemanticSegmentation)
						    if is_torch_available()
						    else ()
						)
						UpperCamelCase      :  Optional[Any]				   =					(
						    {
						        '''feature-extraction''': BeitModel,
						        '''image-classification''': BeitForImageClassification,
						        '''image-segmentation''': BeitForSemanticSegmentation,
						    }
						    if is_torch_available()
						    else {}
						)

						UpperCamelCase      :  Optional[int]				   =					False
						UpperCamelCase      :  List[Any]				   =					False
						UpperCamelCase      :  Optional[Any]				   =					False





						def        SCREAMING_SNAKE_CASE(			self							:List[str]     )  ->Optional[int]:
										lowercase         =      BeitModelTester(self     )
										lowercase         =      ConfigTester(self		,    config_class=lowerCAmelCase__		,    has_text_modality=lowerCAmelCase__		,    hidden_size=37     )





						def        SCREAMING_SNAKE_CASE(			self							:Dict     )  ->int:
										self.config_tester.run_common_tests()





						@unittest.skip(reason="BEiT does not use inputs_embeds"     )
						def        SCREAMING_SNAKE_CASE(			self							:Any     )  ->List[str]:
										pass





						@require_torch_multi_gpu
						@unittest.skip(reason="BEiT has some layers using `add_module` which doesn't work well with `nn.DataParallel`"     )
						def        SCREAMING_SNAKE_CASE(			self							:str     )  ->str:
										pass





						def        SCREAMING_SNAKE_CASE(			self							:str     )  ->List[str]:
										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()

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





						def        SCREAMING_SNAKE_CASE(			self							:Tuple     )  ->List[Any]:
										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()

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

														lowercase         =      ["pixel_values"]
														self.assertListEqual(arg_names[:1]		,    lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:Dict     )  ->Tuple:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:Union[str, Any]     )  ->Any:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:Union[str, Any]     )  ->int:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:int     )  ->str:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_semantic_segmentation(*lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:Dict     )  ->str:
										if not self.model_tester.is_training:
														return

										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()
										lowercase         =      True

										for model_class in self.all_model_classes:
														# we don't test BeitForMaskedImageModeling
														if model_class in [*get_values(lowerCAmelCase__     ), BeitForMaskedImageModeling]:
																		continue

														lowercase         =      model_class(lowerCAmelCase__     )
														model.to(lowerCAmelCase__     )
														model.train()
														lowercase         =      self._prepare_for_class(lowerCAmelCase__		,    lowerCAmelCase__		,    return_labels=lowerCAmelCase__     )
														lowercase         =      model(**lowerCAmelCase__     ).loss
														loss.backward()





						def        SCREAMING_SNAKE_CASE(			self							:List[Any]     )  ->str:
										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()
										if not self.model_tester.is_training:
														return

										lowercase         =      False
										lowercase         =      True

										for model_class in self.all_model_classes:
														# we don't test BeitForMaskedImageModeling
														if (
														    model_class in [*get_values(lowerCAmelCase__     ), BeitForMaskedImageModeling]
														    or not model_class.supports_gradient_checkpointing
														):
																		continue

														lowercase         =      model_class(lowerCAmelCase__     )
														model.gradient_checkpointing_enable()
														model.to(lowerCAmelCase__     )
														model.train()
														lowercase         =      self._prepare_for_class(lowerCAmelCase__		,    lowerCAmelCase__		,    return_labels=lowerCAmelCase__     )
														lowercase         =      model(**lowerCAmelCase__     ).loss
														loss.backward()





						def        SCREAMING_SNAKE_CASE(			self							:str     )  ->Dict:
										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()

										lowercase         =      _config_zero_init(lowerCAmelCase__     )
										for model_class in self.all_model_classes:
														lowercase         =      model_class(config=lowerCAmelCase__     )
														for name, param in model.named_parameters():
																		# we skip lambda parameters as these require special initial values
																		# determined by config.layer_scale_init_value
																		if "lambda" in name:
																						continue
																		if 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'''		,    )





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:int     )  ->Tuple:
										for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														lowercase         =      BeitModel.from_pretrained(lowerCAmelCase__     )
														self.assertIsNotNone(lowerCAmelCase__     )




def  __snake_case							(	):







				'''simple docstring'''


				lowercase         =      Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"						)
				return image





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







						'''simple docstring'''



						@cached_property
						def        SCREAMING_SNAKE_CASE(			self							:Any     )  ->List[str]:
										return BeitImageProcessor.from_pretrained("microsoft/beit-base-patch16-224"     ) if is_vision_available() else None





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:List[str]     )  ->List[str]:
										lowercase         =      BeitForMaskedImageModeling.from_pretrained("microsoft/beit-base-patch16-224-pt22k"     ).to(lowerCAmelCase__     )

										lowercase         =      self.default_image_processor
										lowercase         =      prepare_img()
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).pixel_values.to(lowerCAmelCase__     )

										# prepare bool_masked_pos
										lowercase         =      torch.ones((1, 196)		,    dtype=torch.bool     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(pixel_values=lowerCAmelCase__		,    bool_masked_pos=lowerCAmelCase__     )
										lowercase         =      outputs.logits

										# verify the logits
										lowercase         =      torch.Size((1, 196, 8192)     )
										self.assertEqual(logits.shape		,    lowerCAmelCase__     )

										lowercase         =      torch.tensor(
										    [[-3.24_37, 0.50_72, -13.91_74], [-3.24_56, 0.49_48, -13.94_01], [-3.20_33, 0.51_21, -13.85_50]]     ).to(lowerCAmelCase__     )

										self.assertTrue(torch.allclose(logits[bool_masked_pos][:3, :3]		,    lowerCAmelCase__		,    atol=1E-2     )     )





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:Optional[Any]     )  ->str:
										lowercase         =      BeitForImageClassification.from_pretrained("microsoft/beit-base-patch16-224"     ).to(lowerCAmelCase__     )

										lowercase         =      self.default_image_processor
										lowercase         =      prepare_img()
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(**lowerCAmelCase__     )
										lowercase         =      outputs.logits

										# verify the logits
										lowercase         =      torch.Size((1, 1000)     )
										self.assertEqual(logits.shape		,    lowerCAmelCase__     )

										lowercase         =      torch.tensor([-1.23_85, -1.09_87, -1.01_08]     ).to(lowerCAmelCase__     )

										self.assertTrue(torch.allclose(logits[0, :3]		,    lowerCAmelCase__		,    atol=1E-4     )     )

										lowercase         =      281
										self.assertEqual(logits.argmax(-1     ).item()		,    lowerCAmelCase__     )





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:List[str]     )  ->List[str]:
										lowercase         =      BeitForImageClassification.from_pretrained("microsoft/beit-large-patch16-224-pt22k-ft22k"     ).to(
										    lowerCAmelCase__     )

										lowercase         =      self.default_image_processor
										lowercase         =      prepare_img()
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(**lowerCAmelCase__     )
										lowercase         =      outputs.logits

										# verify the logits
										lowercase         =      torch.Size((1, 21841)     )
										self.assertEqual(logits.shape		,    lowerCAmelCase__     )

										lowercase         =      torch.tensor([1.68_81, -0.27_87, 0.59_01]     ).to(lowerCAmelCase__     )

										self.assertTrue(torch.allclose(logits[0, :3]		,    lowerCAmelCase__		,    atol=1E-4     )     )

										lowercase         =      2396
										self.assertEqual(logits.argmax(-1     ).item()		,    lowerCAmelCase__     )





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:int     )  ->Any:
										lowercase         =      BeitForSemanticSegmentation.from_pretrained("microsoft/beit-base-finetuned-ade-640-640"     )
										lowercase         =      model.to(lowerCAmelCase__     )

										lowercase         =      BeitImageProcessor(do_resize=lowerCAmelCase__		,    size=640		,    do_center_crop=lowerCAmelCase__     )

										lowercase         =      load_dataset("hf-internal-testing/fixtures_ade20k"		,    split="test"     )
										lowercase         =      Image.open(ds[0]["file"]     )
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(**lowerCAmelCase__     )
										lowercase         =      outputs.logits

										# verify the logits
										lowercase         =      torch.Size((1, 150, 160, 160)     )
										self.assertEqual(logits.shape		,    lowerCAmelCase__     )

										lowercase         =      version.parse(PIL.__version__     ) < version.parse("9.0.0"     )

										if is_pillow_less_than_a:
														lowercase         =      torch.tensor(
														    [
														        [[-4.92_25, -2.39_54, -3.05_22], [-2.88_22, -1.00_46, -1.75_61], [-2.95_49, -1.32_28, -2.13_47]],
														        [[-5.81_68, -3.41_29, -4.07_78], [-3.86_51, -2.22_14, -3.02_77], [-3.83_56, -2.46_43, -3.35_35]],
														        [[-0.00_78, 3.99_52, 4.07_54], [2.98_56, 4.69_44, 5.00_35], [3.24_13, 4.78_13, 4.99_69]],
														    ]		,    device=lowerCAmelCase__		,    )
										else:
														lowercase         =      torch.tensor(
														    [
														        [[-4.89_60, -2.36_88, -3.03_55], [-2.84_78, -0.98_36, -1.74_18], [-2.94_49, -1.33_32, -2.14_56]],
														        [[-5.80_81, -3.41_24, -4.10_06], [-3.85_61, -2.20_81, -3.03_23], [-3.83_65, -2.46_01, -3.36_69]],
														        [[-0.03_09, 3.98_68, 4.05_40], [2.96_40, 4.68_77, 4.99_76], [3.20_81, 4.76_90, 4.99_42]],
														    ]		,    device=lowerCAmelCase__		,    )

										self.assertTrue(torch.allclose(logits[0, :3, :3, :3]		,    lowerCAmelCase__		,    atol=1E-4     )     )





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:List[str]     )  ->Dict:
										lowercase         =      BeitForSemanticSegmentation.from_pretrained("microsoft/beit-base-finetuned-ade-640-640"     )
										lowercase         =      model.to(lowerCAmelCase__     )

										lowercase         =      BeitImageProcessor(do_resize=lowerCAmelCase__		,    size=640		,    do_center_crop=lowerCAmelCase__     )

										lowercase         =      load_dataset("hf-internal-testing/fixtures_ade20k"		,    split="test"     )
										lowercase         =      Image.open(ds[0]["file"]     )
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(**lowerCAmelCase__     )

										lowercase         =      outputs.logits.detach().cpu()

										lowercase         =      image_processor.post_process_semantic_segmentation(outputs=lowerCAmelCase__		,    target_sizes=[(500, 300)]     )
										lowercase         =      torch.Size((500, 300)     )
										self.assertEqual(segmentation[0].shape		,    lowerCAmelCase__     )

										lowercase         =      image_processor.post_process_semantic_segmentation(outputs=lowerCAmelCase__     )
										lowercase         =      torch.Size((160, 160)     )
										self.assertEqual(segmentation[0].shape		,    lowerCAmelCase__     )


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)
						_snake_case      :							Tuple     	=    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=1_28, 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')

						_snake_case      :							Optional[int]     	=    tf.keras.preprocessing.image.ImageDataGenerator(
						    rescale=1.0 / 2_55, shear_range=0.2, zoom_range=0.2, horizontal_flip=True
						)

						_snake_case      :							Any     	=    tf.keras.preprocessing.image.ImageDataGenerator(rescale=1.0 / 2_55)

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

						_snake_case      :							Dict     	=    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

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