MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / smooth_process

Function smooth_process

detrsmpl/utils/demo_utils.py:316–366  ·  view source on GitHub ↗

Smooth the array with the specified smoothing type. Args: x (np.ndarray): Shape should be (frame,num_person,K,C) or (frame,K,C). smooth_type (str, optional): Smooth type. choose in ['oneeuro', 'gaus1d', 'savgol','smoothnet', 'smoothnet_win

(x,
                   smooth_type='savgol',
                   cfg_base_dir='configs/_base_/post_processing/')

Source from the content-addressed store, hash-verified

314
315
316def smooth_process(x,
317 smooth_type='savgol',
318 cfg_base_dir='configs/_base_/post_processing/'):
319 """Smooth the array with the specified smoothing type.
320
321 Args:
322 x (np.ndarray): Shape should be (frame,num_person,K,C)
323 or (frame,K,C).
324 smooth_type (str, optional): Smooth type.
325 choose in ['oneeuro', 'gaus1d', 'savgol','smoothnet',
326 'smoothnet_windowsize8','smoothnet_windowsize16',
327 'smoothnet_windowsize32','smoothnet_windowsize64'].
328 Defaults to 'savgol'. 'smoothnet' is default with windowsize=8.
329 cfg_base_dir (str, optional): Config base dir,
330 default configs/_base_/post_processing/
331 Raises:
332 ValueError: check the input smoothing type.
333
334 Returns:
335 np.ndarray: Smoothed data. The shape should be
336 (frame,num_person,K,C) or (frame,K,C).
337 """
338 if smooth_type == 'smoothnet':
339 smooth_type = 'smoothnet_windowsize8'
340
341 assert smooth_type in [
342 'oneeuro', 'gaus1d', 'savgol', 'smoothnet_windowsize8',
343 'smoothnet_windowsize16', 'smoothnet_windowsize32',
344 'smoothnet_windowsize64'
345 ]
346
347 cfg = os.path.join(cfg_base_dir, smooth_type + '.py')
348 if isinstance(cfg, str):
349 cfg = mmcv.Config.fromfile(cfg)
350 elif not isinstance(cfg, mmcv.Config):
351 raise TypeError('config must be a filename or Config object, '
352 f'but got {type(cfg)}')
353
354 x = x.copy()
355
356 assert x.ndim == 3 or x.ndim == 4
357
358 smooth_func = build_post_processing(dict(cfg['smooth_cfg']))
359
360 if x.ndim == 4:
361 for i in range(x.shape[1]):
362 x[:, i] = smooth_func(x[:, i])
363 elif x.ndim == 3:
364 x = smooth_func(x)
365
366 return x
367
368
369def speed_up_process(x,

Callers

nothing calls this directly

Calls 3

build_post_processingFunction · 0.90
copyMethod · 0.80
fromfileMethod · 0.45

Tested by

no test coverage detected