MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / AsyncDemo

Class AsyncDemo

slowfast/visualization/async_predictor.py:237–273  ·  view source on GitHub ↗

Asynchronous Action Prediction and Visualization pipeline with AsyncVis.

Source from the content-addressed store, hash-verified

235
236
237class AsyncDemo:
238 """
239 Asynchronous Action Prediction and Visualization pipeline with AsyncVis.
240 """
241
242 def __init__(self, cfg, async_vis):
243 """
244 Args:
245 cfg (CfgNode): configs. Details can be found in
246 slowfast/config/defaults.py
247 async_vis (AsyncVis object): asynchronous visualizer.
248 """
249 self.model = AsycnActionPredictor(
250 cfg=cfg, result_queue=async_vis.task_queue
251 )
252 self.async_vis = async_vis
253
254 def put(self, task):
255 """
256 Put task into task queue for prediction and visualization.
257 Args:
258 task (TaskInfo object): task object that contain
259 the necessary information for action prediction. (e.g. frames)
260 """
261 self.async_vis.get_indices_ls.append(task.id)
262 self.model.put(task)
263
264 def get(self):
265 """
266 Get the visualized clips if any.
267 """
268 try:
269 task = self.async_vis.get()
270 except (queue.Empty, IndexError):
271 raise IndexError("Results are not available yet.")
272
273 return task
274
275
276def draw_predictions(task, video_vis):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected