@@ -14,26 +14,26 @@ def test_missing_input_image(self):
1414 with self .assertRaises (FileNotFoundError ):
1515 main ().preprocess_image ('/nonexistent/image.jpg' )
1616
17- # def test_tensor_size(self):
18- # image, img_shape, img_type = main().preprocess_image('/input/resized_image.jpg')
19- # print(img_shape, img_type)
20- # self.assertEqual(img_shape, (1,2,3), 'Not Equal Shape')
21- #
22- # def test_image_type(self):
23- # image, img_shape, img_type = main().preprocess_image('/input/resized_image.jpg')
24- # print(img_shape, img_type)
25- # self.assertEqual(img_type, int, 'Not Equal Image Type')
26- #
27- # def test_image_class(self):
28- # model = MobileNetV2()
29- # model.load_state_dict(torch.load("./model/weights/mobilenetv2.pt", weights_only=True)) # weights ported from torchvision
30- # model.float()
31- #
32- # predicted_label = main().inference(model, '/input/resized_image.jpg',
33- # '/output_raw/output_prediction.txt')
34- #
35- # print('Label in output:',predicted_label)
36- # self.assertEqual(predicted_label, 'Aar', 'Wrong classification')
17+ def test_tensor_size (self ):
18+ image , img_shape , img_type = main ().preprocess_image ('/input/resized_image.jpg' )
19+ print (img_shape , img_type )
20+ self .assertEqual (img_shape , (1 ,2 ,3 ), 'Not Equal Shape' )
21+
22+ def test_image_type (self ):
23+ image , img_shape , img_type = main ().preprocess_image ('/input/resized_image.jpg' )
24+ print (img_shape , img_type )
25+ self .assertEqual (img_type , int , 'Not Equal Image Type' )
26+
27+ def test_image_class (self ):
28+ model = MobileNetV2 ()
29+ model .load_state_dict (torch .load ("./model/weights/mobilenetv2.pt" , weights_only = True )) # weights ported from torchvision
30+ model .float ()
31+
32+ predicted_label = main ().inference (model , '/input/resized_image.jpg' ,
33+ '/output_raw/output_prediction.txt' )
34+
35+ print ('Label in output:' ,predicted_label )
36+ self .assertEqual (predicted_label , 'Aar' , 'Wrong classification' )
3737
3838if __name__ == '__main__' :
3939 unittest .main ()
0 commit comments