回答編集履歴

2

コード修正

2021/11/23 02:50

投稿

jbpb0
jbpb0

スコア7651

test CHANGED
@@ -68,7 +68,7 @@
68
68
 
69
69
 
70
70
 
71
- image = load_image('dog.996.jpg')
71
+ image = load_image('DSC_0897.jpg')
72
72
 
73
73
  #--------------------------------------------------------
74
74
 

1

コード修正

2021/11/23 02:50

投稿

jbpb0
jbpb0

スコア7651

test CHANGED
@@ -58,17 +58,17 @@
58
58
 
59
59
  def load_image(img_path: str):
60
60
 
61
- image = img.load_img(img_path, target_size=(224, 224))
61
+ image = img.load_img(img_path, target_size=(224, 224))
62
62
 
63
- plt.imshow(image)
63
+ plt.imshow(image)
64
64
 
65
- x = img.img_to_array(image)
65
+ x = img.img_to_array(image)
66
66
 
67
- return x
67
+ return x
68
68
 
69
69
 
70
70
 
71
- image = load_image('DSC_0897.jpg')
71
+ image = load_image('dog.996.jpg')
72
72
 
73
73
  #--------------------------------------------------------
74
74
 
@@ -84,7 +84,7 @@
84
84
 
85
85
  fmodel = foolbox.models.KerasModel(kmodel, bounds=(0, 255),
86
86
 
87
- preprocessing=preprocessing)
87
+ preprocessing=preprocessing)
88
88
 
89
89
 
90
90
 
@@ -92,9 +92,9 @@
92
92
 
93
93
  preds = kmodel.predict(to_classify)
94
94
 
95
- print('Predicted:',
95
+ print('Predicted:',
96
96
 
97
- pp.pprint(decode_predictions(preds, top=20)[0]))
97
+ pp.pprint(decode_predictions(preds, top=20)[0]))
98
98
 
99
99
  label = np.argmax(preds)
100
100
 
@@ -106,7 +106,7 @@
106
106
 
107
107
  attack = foolbox.v1.attacks.FGSM(fmodel, threshold=.9,
108
108
 
109
- criterion=ConfidentMisclassification(.9))
109
+ criterion=ConfidentMisclassification(.9))
110
110
 
111
111
  adversarial = attack(image, label)
112
112
 
@@ -114,8 +114,8 @@
114
114
 
115
115
  new_preds = kmodel.predict(np.expand_dims(adversarial, axis=0))
116
116
 
117
- print('Predicted:',
117
+ print('Predicted:',
118
118
 
119
- pp.pprint(decode_predictions(new_preds, top=20)[0]))
119
+ pp.pprint(decode_predictions(new_preds, top=20)[0]))
120
120
 
121
121
  ```