Update pipeline.py
Browse files- pipeline.py +3 -3
pipeline.py
CHANGED
|
@@ -19,12 +19,12 @@ class PreTrainedPipeline():
|
|
| 19 |
def __call__(self, inputs: "Image.Image")-> List[Dict[str, Any]]:
|
| 20 |
|
| 21 |
# convert img to numpy array, resize and normalize to make the prediction
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
im = tf.image.resize(img, (128, 128))
|
| 26 |
im = tf.cast(im, tf.float32) / 255.0
|
| 27 |
-
pred_mask = model.predict(im[tf.newaxis, ...])
|
| 28 |
|
| 29 |
# take the best performing class for each pixel
|
| 30 |
# the output of argmax looks like this [[1, 2, 0], ...]
|
|
|
|
| 19 |
def __call__(self, inputs: "Image.Image")-> List[Dict[str, Any]]:
|
| 20 |
|
| 21 |
# convert img to numpy array, resize and normalize to make the prediction
|
| 22 |
+
with Image.open(inputs) as img:
|
| 23 |
+
img = np.array(inputs)
|
| 24 |
|
| 25 |
im = tf.image.resize(img, (128, 128))
|
| 26 |
im = tf.cast(im, tf.float32) / 255.0
|
| 27 |
+
pred_mask = self.model.predict(im[tf.newaxis, ...])
|
| 28 |
|
| 29 |
# take the best performing class for each pixel
|
| 30 |
# the output of argmax looks like this [[1, 2, 0], ...]
|