Spaces:
Sleeping
Sleeping
Download prepare_features.py from rk147/federated_learning_model: direct link, hf CLI and curl.
- Browser
- Download file 879 Bytes
-
https://huggingface.co/spaces/rk147/federated_learning_model/resolve/main/prepare_features.py
- Command line
-
hf download hf://spaces/rk147/federated_learning_model/prepare_features.py
-
curl -L -o prepare_features.py https://huggingface.co/spaces/rk147/federated_learning_model/resolve/main/prepare_features.py
879 Bytes
| """Build the cached feature files ONCE (optional but recommended), then commit cache/*.npz | |
| so the Space boots instantly and never depends on the dataset downloads again. | |
| pip install torch torchvision datasets opencv-python-headless pillow numpy | |
| python prepare_features.py --task heart --n 150 | |
| python prepare_features.py --task diabetes --n 150 | |
| Runs fine on a free Google Colab CPU runtime or on a laptop (~2-5 min per task). | |
| """ | |
| import argparse | |
| from fl import data | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--task", choices=list(data.TASKS), required=True) | |
| ap.add_argument("--n", type=int, default=150, help="images per class") | |
| ap.add_argument("--seed", type=int, default=0) | |
| a = ap.parse_args() | |
| raw = data.load_raw(a.task, a.n, a.seed, allow_synthetic=False) | |
| print("OK:", a.task, raw["X"].shape, "positives:", int(raw["y"].sum()), "| groups:", raw["group_name"]) | |