friesti1 commited on
Commit
ee0849a
·
verified ·
1 Parent(s): 5a45819

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -12,9 +12,10 @@ def predict_pokemon_type(uploaded_file):
12
  model = tf.keras.models.load_model('biomes-xception-model.keras')
13
 
14
  # Load the image from the file path
15
- with Image.open(uploaded_file) as img:
16
  img = img.resize((150, 150))
17
  img_array = np.array(img)
 
18
 
19
  prediction = model.predict(np.expand_dims(img_array, axis=0))
20
 
 
12
  model = tf.keras.models.load_model('biomes-xception-model.keras')
13
 
14
  # Load the image from the file path
15
+ with Image.open(uploaded_file).convert('RGB') as img:
16
  img = img.resize((150, 150))
17
  img_array = np.array(img)
18
+ img_array = (img_array / 127.5) - 1.0 # Rescale the image as the model expects
19
 
20
  prediction = model.predict(np.expand_dims(img_array, axis=0))
21