Spaces:
Running on L40S
Running on L40S
Download cosmos-framework/cosmos_framework/utils/count_params.py from nvidia/Cosmos3-Action-Viewer: direct link, hf CLI and curl.
- Browser
- Download file 428 Bytes
-
https://huggingface.co/spaces/nvidia/Cosmos3-Action-Viewer/resolve/main/cosmos-framework/cosmos_framework/utils/count_params.py
- Command line
-
hf download hf://spaces/nvidia/Cosmos3-Action-Viewer/cosmos-framework/cosmos_framework/utils/count_params.py
-
curl -L -o count_params.py https://huggingface.co/spaces/nvidia/Cosmos3-Action-Viewer/resolve/main/cosmos-framework/cosmos_framework/utils/count_params.py
428 Bytes
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |
| # SPDX-License-Identifier: OpenMDW-1.1 | |
| from torch import nn | |
| def count_params(model: nn.Module, verbose=False) -> int: | |
| total_params = sum(p.numel() for p in model.parameters() if p.requires_grad) | |
| if verbose: | |
| print(f"{model.__class__.__name__} has {total_params * 1.0e-6:.2f} M params.") | |
| return total_params | |