yupikopi commited on
Commit
aeffca2
1 Parent(s): 1c54a6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -5,17 +5,19 @@ import numpy as np
5
 
6
  model = load_model('Pikachu_and_Raichu.h5')
7
 
8
- #class_names[labels] = ['Pikachu', 'Raichu']
9
 
10
  def predict(img):
11
- img=img.reshape(160,160,3)
12
  """images_list = []
13
  images_list.append(np.array(img))
14
  x = np.asarray(images_list)"""
15
- prediction = model.predict(img)[0]
16
- return {class_names[labels[i]]: float(prediction[i]) for i in range(len(class_names[labels]))}
 
 
17
 
18
- image = gr.inputs.Image(shape=(160, 160))
19
  label = gr.outputs.Label(num_top_classes=2)
20
 
21
  gr.Interface(fn=predict, inputs=image, title="Garbage Classifier",
 
5
 
6
  model = load_model('Pikachu_and_Raichu.h5')
7
 
8
+ labels = ['Pikachu', 'Raichu']
9
 
10
  def predict(img):
11
+ img=img.reshape(-1,224,224,3)
12
  """images_list = []
13
  images_list.append(np.array(img))
14
  x = np.asarray(images_list)"""
15
+ #prediction = model.predict(img)[0]
16
+ prediction = model.predict(img).flatten()
17
+ confidences = {labels[i]: float(prediction[i]) for i in range(2)}
18
+ return confidences
19
 
20
+ image = gr.inputs.Image(shape=(224, 224))
21
  label = gr.outputs.Label(num_top_classes=2)
22
 
23
  gr.Interface(fn=predict, inputs=image, title="Garbage Classifier",