Simple debug version
Browse files- pipeline.py +10 -13
pipeline.py
CHANGED
@@ -8,25 +8,22 @@ from tensorflow.keras.models import load_model
|
|
8 |
# most of this code has been obtained from Datature's prediction script
|
9 |
# https://github.com/datature/resources/blob/main/scripts/bounding_box/prediction.py
|
10 |
|
11 |
-
|
12 |
-
|
13 |
class PreTrainedPipeline():
|
14 |
def __init__(self, path: str):
|
15 |
# load the model
|
16 |
-
|
17 |
-
|
18 |
-
def __call__(self, inputs: "Image.Image")-> List[Dict[str, Any]]:
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
25 |
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
|
31 |
|
32 |
# # -----------------
|
|
|
8 |
# most of this code has been obtained from Datature's prediction script
|
9 |
# https://github.com/datature/resources/blob/main/scripts/bounding_box/prediction.py
|
10 |
|
|
|
|
|
11 |
class PreTrainedPipeline():
|
12 |
def __init__(self, path: str):
|
13 |
# load the model
|
14 |
+
self.model = tf.saved_model.load('./saved_model')
|
|
|
|
|
15 |
|
16 |
+
def __call__(self, inputs):
|
17 |
+
image = np.array(inputs)
|
18 |
+
image = tf.cast(image, tf.float32)
|
19 |
+
image = tf.image.resize(image, [150, 150])
|
20 |
+
image = np.expand_dims(image, axis = 0)
|
21 |
+
predictions = self.model.predict(image)
|
22 |
|
23 |
+
labels = []
|
24 |
+
labels = [{"score":0.9509243965148926,"label":"car","box":{"xmin":142,"ymin":106,"xmax":376,"ymax":229}},{"score":0.9981777667999268,"label":"car","box":{"xmin":405,"ymin":146,"xmax":640,"ymax":297}},{"score":0.9963648915290833,"label":"car","box":{"xmin":0,"ymin":115,"xmax":61,"ymax":167}},{"score":0.974663257598877,"label":"car","box":{"xmin":155,"ymin":104,"xmax":290,"ymax":141}},{"score":0.9986898303031921,"label":"car","box":{"xmin":39,"ymin":117,"xmax":169,"ymax":188}},{"score":0.9998276233673096,"label":"person","box":{"xmin":172,"ymin":60,"xmax":482,"ymax":396}},{"score":0.9996274709701538,"label":"skateboard","box":{"xmin":265,"ymin":348,"xmax":440,"ymax":413}}]
|
25 |
|
26 |
+
return labels
|
27 |
|
28 |
|
29 |
# # -----------------
|