Instructions to use Zipeng365/WISP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Zipeng365/WISP with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Zipeng365/WISP", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
File size: 1,437 Bytes
93a9282 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | """Context for shared feature blocks during a search (``_SEARCH``); ``_ACTIVE`` is never set here."""
from contextvars import ContextVar
_SEARCH = ContextVar("wisp_search_memory", default=None)
_ACTIVE = ContextVar("wisp_feature_store", default=None)
def transform_blocks(blocks, X):
config = _ACTIVE.get()
shared_search = _SEARCH.get()
if shared_search is not None and config is None:
return shared_search.transform(blocks,X)
if config is None:
shared = len(blocks)>=2 and all(getattr(b,"zscore",False) and hasattr(b,"transform_normalized") for b in blocks)
if shared:
from wisp.cpu.features import _as_3d, _safe_zscore_per_window
from . import features as fx
if X.flags.c_contiguous:
z=fx._normalize(_as_3d(X))
return [b.transform_normalized(z) for b in blocks]
canonical=(fx.RandomConvSketch,fx.IntervalDistributionSketch,fx.WearableFeatureExtractor)
if fx._time_major_view(X) and all(type(b) in canonical and not b.fast_profile for b in blocks):
# Keep the original reduction layout; reuse only if the actual
# normalized buffer can enter all three packed backends.
z=_safe_zscore_per_window(_as_3d(X))
if z.flags.c_contiguous:return [b.transform_normalized(z) for b in blocks]
return [block.transform(X) for block in blocks]
|