bauckluc commited on
Commit
c48b1e4
·
verified ·
1 Parent(s): bec246f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -6,7 +6,6 @@ import numpy as np
6
  # Load your custom regression model
7
  model_path = "pokemon_transferlearning.keras"
8
 
9
- #model.load_weights(model_path)
10
  model = tf.keras.models.load_model(model_path)
11
 
12
  labels = ['Porygon', 'Seel', 'Vaporeon']
@@ -15,8 +14,9 @@ labels = ['Porygon', 'Seel', 'Vaporeon']
15
  def predict_regression(image):
16
  # Preprocess image
17
  image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
18
- image = image.resize((28, 28)).convert('L') #resize the image to 28x28 and converts it to gray scale
19
  image = np.array(image)
 
20
  print(image.shape)
21
  # Predict
22
  prediction = model.predict(image[None, ...]) # Assuming single regression value
 
6
  # Load your custom regression model
7
  model_path = "pokemon_transferlearning.keras"
8
 
 
9
  model = tf.keras.models.load_model(model_path)
10
 
11
  labels = ['Porygon', 'Seel', 'Vaporeon']
 
14
  def predict_regression(image):
15
  # Preprocess image
16
  image = Image.fromarray(image.astype('uint8')) # Convert numpy array to PIL image
17
+ image = image.resize((150, 150)).convert('RGB') # Resize the image to 150x150 and convert it to RGB
18
  image = np.array(image)
19
+ image = image / 255.0 # Normalize the image to [0, 1]
20
  print(image.shape)
21
  # Predict
22
  prediction = model.predict(image[None, ...]) # Assuming single regression value