Spaces:
Configuration error
Configuration error
Danila-Pechenev
commited on
Commit
•
03def4f
1
Parent(s):
c63c2cd
Cosmetics
Browse files- app/model.py +4 -4
app/model.py
CHANGED
@@ -10,12 +10,12 @@ def create_model() -> keras.Model:
|
|
10 |
|
11 |
|
12 |
def run_model(image_bytes: io.BytesIO, model: keras.Model) -> Image.Image:
|
13 |
-
|
14 |
width: int
|
15 |
height: int
|
16 |
-
width, height =
|
17 |
-
|
18 |
-
image_array1: np.ndarray = keras.utils.img_to_array(
|
19 |
image_array2: np.ndarray = image_array1.astype("float32") / 255.0
|
20 |
image_array3: np.ndarray = np.expand_dims(image_array2, axis=0)
|
21 |
output: np.ndarray = model.predict(image_array3)
|
|
|
10 |
|
11 |
|
12 |
def run_model(image_bytes: io.BytesIO, model: keras.Model) -> Image.Image:
|
13 |
+
image1: Image.Image = Image.open(image_bytes)
|
14 |
width: int
|
15 |
height: int
|
16 |
+
width, height = image1.size
|
17 |
+
image2: Image.Image = image1.resize((960, 640))
|
18 |
+
image_array1: np.ndarray = keras.utils.img_to_array(image2)
|
19 |
image_array2: np.ndarray = image_array1.astype("float32") / 255.0
|
20 |
image_array3: np.ndarray = np.expand_dims(image_array2, axis=0)
|
21 |
output: np.ndarray = model.predict(image_array3)
|