deepextractor.model =================== .. py:module:: deepextractor.model .. autoapi-nested-parse:: High-level DeepExtractor model wrapper for inference. Module Contents --------------- .. py:data:: logger .. py:class:: DeepExtractorModel(checkpoint: str = 'DeepExtractor_257', checkpoint_filename: str = CHECKPOINT_BILBY, checkpoint_dir: str | None = None, device: str | torch.device | None = None, scaler_path: str | None = None, n_fft: int = 512, win_length: int = 64, hop_length: int = 32) High-level wrapper around a pretrained DeepExtractor UNET2D model. Bundles the PyTorch model, StandardScaler, and STFT parameters into a single object so callers don't need to manage them separately. :param checkpoint: Model name / checkpoint key. Defaults to ``"DeepExtractor_257"``. :type checkpoint: str :param checkpoint_filename: Checkpoint file name within the model subdirectory on HuggingFace Hub or local ``checkpoint_dir``. Defaults to ``CHECKPOINT_BILBY``. :type checkpoint_filename: str :param checkpoint_dir: Local directory to search for checkpoint files before falling back to HuggingFace Hub. Pass ``None`` to always use the Hub. :type checkpoint_dir: str | None :param device: Compute device. Auto-detects CUDA if available when ``None``. :type device: str | torch.device | None :param scaler_path: Path to the scaler ``.pkl`` file. Defaults to the bundled ``assets/scaler_bilby.pkl``. :type scaler_path: str | None :param n_fft: STFT FFT size. Default 512. :type n_fft: int :param win_length: STFT window length. Default 64. :type win_length: int :param hop_length: STFT hop length. Default 32. :type hop_length: int .. py:attribute:: device .. py:attribute:: n_fft :value: 512 .. py:attribute:: win_length :value: 64 .. py:attribute:: hop_length :value: 32 .. py:method:: background(noisy_input: numpy.ndarray) -> numpy.ndarray Estimate the background (noise-only) component. :param noisy_input: 1-D array of shape ``(T,)`` or 2-D batch of shape ``(N, T)``. :type noisy_input: np.ndarray :returns: Background estimate, same shape as ``noisy_input``. :rtype: np.ndarray .. py:method:: reconstruct(noisy_input: numpy.ndarray) -> numpy.ndarray Extract the transient signal by subtracting the predicted background. :param noisy_input: 1-D array of shape ``(T,)`` or 2-D batch of shape ``(N, T)``. :type noisy_input: np.ndarray :returns: Reconstructed signal, same shape as ``noisy_input``. :rtype: np.ndarray