bauckluc commited on
Commit
ef8a428
·
verified ·
1 Parent(s): a4e4ac9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -4,7 +4,7 @@ from PIL import Image
4
  import numpy as np
5
 
6
  # Load your custom regression model
7
- model_path = "kia_mnist_keras_model.weights.h5"
8
  model_path = "pokemon_transferlearning.keras"
9
 
10
  model = tf.keras.models.load_model(model_path)
@@ -15,9 +15,8 @@ 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((150, 150)).convert('RGB') # Resize the image to 150x150 and convert it to RGB
19
  image = np.array(image)
20
- image = image / 255.0 # Normalize the image to [0, 1]
21
  print(image.shape)
22
  # Predict
23
  prediction = model.predict(image[None, ...]) # Assuming single regression value
 
4
  import numpy as np
5
 
6
  # Load your custom regression model
7
+ # model_path = "kia_mnist_keras_model.weights.h5"
8
  model_path = "pokemon_transferlearning.keras"
9
 
10
  model = tf.keras.models.load_model(model_path)
 
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((150, 150)).convert('L') # Resize the image to 150x150 and convert it to RGB
19
  image = np.array(image)
 
20
  print(image.shape)
21
  # Predict
22
  prediction = model.predict(image[None, ...]) # Assuming single regression value