Spaces:
Running
Running
Commit
·
068bc79
1
Parent(s):
35c0e10
Update utils.py
Browse files
utils.py
CHANGED
@@ -7,11 +7,13 @@ def 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)
|
|
|
7 |
img = Image.open(img_path)
|
8 |
img = img.resize((256, 256))
|
9 |
img_array = np.array(img)
|
10 |
+
img_array = img_array[:, :, :3] # Keep only the first three channels (RGB)
|
11 |
img_array = np.expand_dims(img_array, axis=0) # Add an extra dimension for batch size
|
12 |
img_array = img_array / 255.0 # Normalize pixel values to the range [0, 1]
|
13 |
return img_array
|
14 |
|
15 |
|
16 |
+
|
17 |
# Function to classify the garbage
|
18 |
def classify_garbage(img_path, model):
|
19 |
processed_img = preprocess_image(img_path)
|