Asynchronous Action Prediction and Visualization pipeline with AsyncVis.
| 235 | |
| 236 | |
| 237 | class 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 | |
| 276 | def draw_predictions(task, video_vis): |
nothing calls this directly
no outgoing calls
no test coverage detected