Anas090 commited on
Commit
4c1483c
·
verified ·
1 Parent(s): 8a23dfe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -39,14 +39,17 @@ def predict_image(image_path, model):
39
  img = np.expand_dims(img, axis=0) # Add batch dimension
40
  img = img / 255.0 # Normalize pixel values
41
  if model == "Vgg19":
42
- prediction = model_vgg19.run(None, {"input": img})[0]
 
 
 
43
  elif model == "Vgg16":
44
  prediction = model_vgg16.run(None, {"input": img})[0]
45
  elif model == "InceptionV3":
46
  prediction = model_inceptionv3.run(None, {"input": img})[0]
47
  elif model == "Resnet101":
48
  prediction = model_resnet101.run(None, {"input": img})[0]
49
- prediction = np.argmax(prediction)
50
  pre_class = labels[prediction]
51
 
52
  return pre_class
 
39
  img = np.expand_dims(img, axis=0) # Add batch dimension
40
  img = img / 255.0 # Normalize pixel values
41
  if model == "Vgg19":
42
+ input_name = model_vgg19.get_inputs()[0].name
43
+ output_name= model_vgg19.get_outputs()[0].name
44
+ prediction = model_vgg19.run(None, {input_name: img})
45
+
46
  elif model == "Vgg16":
47
  prediction = model_vgg16.run(None, {"input": img})[0]
48
  elif model == "InceptionV3":
49
  prediction = model_inceptionv3.run(None, {"input": img})[0]
50
  elif model == "Resnet101":
51
  prediction = model_resnet101.run(None, {"input": img})[0]
52
+ prediction = np.argmax(prediction[0][0])
53
  pre_class = labels[prediction]
54
 
55
  return pre_class