Spaces:
Running
Running
Commit
·
413ef10
1
Parent(s):
8237807
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -37,8 +37,11 @@ base_model.trainable = True
|
|
| 37 |
def preprocess(image_or_path):
|
| 38 |
if isinstance(image_or_path, str): # Check if the input is a string (image path)
|
| 39 |
img = Image.open(image_or_path)
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# Print image dimensions for debugging
|
| 44 |
print(f"Original image dimensions: {img.size}")
|
|
|
|
| 37 |
def preprocess(image_or_path):
|
| 38 |
if isinstance(image_or_path, str): # Check if the input is a string (image path)
|
| 39 |
img = Image.open(image_or_path)
|
| 40 |
+
elif isinstance(image_or_path, np.ndarray): # Check if the input is a numpy array
|
| 41 |
+
# Convert the numpy array to a PIL Image
|
| 42 |
+
img = Image.fromarray((image_or_path * 255).astype(np.uint8))
|
| 43 |
+
else:
|
| 44 |
+
raise ValueError("Unsupported input type. Expected string path or numpy array.")
|
| 45 |
|
| 46 |
# Print image dimensions for debugging
|
| 47 |
print(f"Original image dimensions: {img.size}")
|