BunkerMinecraft commited on
Commit
c2fac1c
·
verified ·
1 Parent(s): 0a9c3ca

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +7 -3
inference.py CHANGED
@@ -21,10 +21,14 @@ model = models.Sequential([
21
  ])
22
  model.load_weights("model.weights.h5")
23
 
 
 
 
 
 
 
24
  def predict(image: Image.Image):
25
- img = image.resize((224, 224))
26
- x = np.array(img) / 255.0
27
- x = np.expand_dims(x, 0)
28
  y = model.predict(x)
29
  class_idx = int(np.argmax(y, axis=1)[0])
30
  confidence = float(np.max(y))
 
21
  ])
22
  model.load_weights("model.weights.h5")
23
 
24
+ def preprocess(image: Image.Image):
25
+ image = image.resize((224, 224))
26
+ image = np.array(image) / 255.0
27
+ image = np.expand_dims(image, axis=0)
28
+ return image
29
+
30
  def predict(image: Image.Image):
31
+ x = preprocess(image)
 
 
32
  y = model.predict(x)
33
  class_idx = int(np.argmax(y, axis=1)[0])
34
  confidence = float(np.max(y))