MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / exec

Method exec

flow-python/examples/application/simple_det_classify/det.py:47–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

45 return val
46
47 def exec(self):
48 envelope = self.inp.recv()
49 if envelope is None:
50 return
51
52 msg = envelope.msg
53 msg['items'] = []
54
55 process = envelope.partial_id % self._interval == 0
56 if process:
57 data = msg['data']
58 outputs = self._predictor.inference(data)
59 # skip if detect nothing
60 if outputs is not None:
61 items = []
62
63 for i in range(outputs.shape[0]):
64 output = outputs[i]
65 item = dict()
66 item["bbox"] = output[0:4]
67 item["det_score"] = output[4] * output[5]
68 items.append(item)
69 msg['items'] = items
70
71 # import cv2
72 # x = self._predictor.visual(outputs, data)
73 # name = 'frame{0:07d}.jpg'.format(envelope.partial_id)
74 # cv2.imwrite(name, x)
75
76 if self._visualize == 1:
77 msg['data'] = self._predictor.visual(outputs, data)
78 self.out.send(envelope)

Callers

nothing calls this directly

Calls 6

rangeFunction · 0.85
appendMethod · 0.80
visualMethod · 0.80
recvMethod · 0.45
inferenceMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected