skills/cv/frame-differencing-temporal-encoding/SKILL.md
Encode motion and velocity by computing per-channel pixel differences between consecutive frames instead of stacking raw frames for RL visual observations
npx skillsauth add wenmin-wu/ds-skills cv-frame-differencing-temporal-encodingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Frame stacking (concatenating the last N frames) is the standard way to give RL agents temporal information from visual observations. Frame differencing is a lighter alternative: subtract the previous frame from the current one to produce a motion-only image. Moving objects appear as non-zero pixels while static backgrounds cancel out, giving the network explicit velocity signals without doubling the input channels.
import numpy as np
from collections import deque
class FrameDiffWrapper:
def __init__(self, env, n_channels=4):
self.env = env
self.n_channels = n_channels
self.buffer = deque(maxlen=2)
def reset(self):
obs = self.env.reset()
frame = obs / 255.0
self.buffer.append(frame)
self.buffer.append(np.zeros_like(frame))
return self._diff()
def step(self, action):
obs, reward, done, info = self.env.step(action)
self.buffer.append(obs / 255.0)
return self._diff(), reward, done, info
def _diff(self):
diff = np.empty_like(self.buffer[1])
for c in range(diff.shape[-1]):
diff[..., c] = self.buffer[1][..., c] - self.buffer[0][..., c]
return diff
current - previousdata-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF