deepecgkit.utils¶
Utility functions for CSV reading and pretrained weight management.
read_csv
¶
read_csv(
csv_file: str,
delimiter: str = ",",
transpose: bool = False,
skip_header: bool = True,
dtype: Optional[type] = None,
) -> Tuple[np.ndarray, Dict[str, int]]
Read CSV file and return data array and header mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_file
|
str
|
Path to the CSV file |
required |
delimiter
|
str
|
Column delimiter (default: ',') |
','
|
transpose
|
bool
|
Whether to transpose the data array |
False
|
skip_header
|
bool
|
Whether to skip the first row as header |
True
|
dtype
|
Optional[type]
|
Data type for the numpy array |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, Dict[str, int]]
|
Tuple of (data_array, header_mapping) |
Source code in deepecgkit/utils/__init__.py
list_pretrained_weights
¶
load_pretrained_weights
¶
load_pretrained_weights(
weight_name: str,
map_location: Optional[Union[str, device]] = None,
force_download: bool = False,
) -> Dict
Load pretrained weights by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight_name
|
str
|
Name of the pretrained weights |
required |
map_location
|
Optional[Union[str, device]]
|
Device to map weights to (e.g., "cpu", "cuda") |
None
|
force_download
|
bool
|
If True, re-download weights even if cached |
False
|
Returns:
| Type | Description |
|---|---|
Dict
|
State dict containing model weights |
Source code in deepecgkit/utils/weights.py
register_weights
¶
register_weights(
name: str,
url: str,
model_class: str,
model_kwargs: Dict,
description: str = "",
) -> None
Register custom pretrained weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique name for the weights |
required |
url
|
str
|
URL to download weights from |
required |
model_class
|
str
|
Name of the model class these weights are for |
required |
model_kwargs
|
Dict
|
Keyword arguments to instantiate the model |
required |
description
|
str
|
Human-readable description of the weights |
''
|