imdebamrita commited on
Commit
355fce8
·
verified ·
1 Parent(s): 9cac1de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -11,12 +11,16 @@ ImageFile.LOAD_TRUNCATED_IMAGES = True
11
  new_model = tf.keras.models.load_model('tree-not-tree.keras')
12
 
13
  def TreeOrNotTree(img):
14
- img = img.resize((128, 128))
15
-
16
- # Convert the image to a numpy array and normalize it
17
- img_array = np.array(img) / 255.0
 
 
 
 
18
 
19
- # Reshape to add batch dimension (1, 128, 128, 3) if needed
20
  img_array = np.expand_dims(img_array, axis=0)
21
 
22
  # Make prediction
 
11
  new_model = tf.keras.models.load_model('tree-not-tree.keras')
12
 
13
  def TreeOrNotTree(img):
14
+ # Convert PIL image to a numpy array (RGB format)
15
+ img_array = np.array(img)
16
+
17
+ # Resize the image to the expected input size (128x128) using cv2
18
+ img_array = cv2.resize(img_array, (128, 128))
19
+
20
+ # Normalize the image
21
+ img_array = img_array / 255.0
22
 
23
+ # Reshape to add batch dimension (1, 128, 128, 3)
24
  img_array = np.expand_dims(img_array, axis=0)
25
 
26
  # Make prediction