Aryan-EcoClim commited on
Commit
35c0e10
·
1 Parent(s): 846e726

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +3 -0
utils.py CHANGED
@@ -7,8 +7,11 @@ def preprocess_image(img_path):
7
  img = Image.open(img_path)
8
  img = img.resize((256, 256))
9
  img_array = np.array(img)
 
 
10
  return img_array
11
 
 
12
  # Function to classify the garbage
13
  def classify_garbage(img_path, model):
14
  processed_img = preprocess_image(img_path)
 
7
  img = Image.open(img_path)
8
  img = img.resize((256, 256))
9
  img_array = np.array(img)
10
+ img_array = np.expand_dims(img_array, axis=0) # Add an extra dimension for batch size
11
+ img_array = img_array / 255.0 # Normalize pixel values to the range [0, 1]
12
  return img_array
13
 
14
+
15
  # Function to classify the garbage
16
  def classify_garbage(img_path, model):
17
  processed_img = preprocess_image(img_path)