Spaces:
Runtime error
Runtime error
Update src/util/image.py
Browse files- src/util/image.py +9 -0
src/util/image.py
CHANGED
@@ -11,3 +11,12 @@ def load_image_url(url, required_size = (224,224), image_type = 'array'):
|
|
11 |
if image_type == 'array':
|
12 |
img = (np.expand_dims(np.array(img), 0)/255).astype(np.float32)
|
13 |
return img
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
if image_type == 'array':
|
12 |
img = (np.expand_dims(np.array(img), 0)/255).astype(np.float32)
|
13 |
return img
|
14 |
+
|
15 |
+
def load_image_path(path, required_size = (224,224), image_type = 'array'):
|
16 |
+
img = Image.open(path)
|
17 |
+
img = Image.fromarray(np.array(img))
|
18 |
+
if required_size is not None:
|
19 |
+
img = img.resize(required_size)
|
20 |
+
if image_type == 'array':
|
21 |
+
img = (np.expand_dims(np.array(img), 0)/255).astype(np.float32)
|
22 |
+
return img
|