Download README.md from quangduc/casopad2: direct link, hf CLI and curl.
- Browser
- Download file 7.22 kB
-
https://huggingface.co/quangduc/casopad2/resolve/main/README.md
- Command line
-
hf download hf://quangduc/casopad2/README.md
-
curl -L -o README.md https://huggingface.co/quangduc/casopad2/resolve/main/README.md
library_name: pytorch
tags:
- face-anti-spoofing
- presentation-attack-detection
- facepad
- caso-pad
- mobilenetv3
- involution
- offline
- air-gapped
pipeline_tag: image-classification
license: other
CASO-PAD — offline bundle (native python, không Docker)
Bundle chạy toàn bộ chương trình train CASO-PAD trên cụm GPU không có internet:
code + 17 file weight ImageNet (1.42 GB) cho 13 backbone. Không cần tải bất cứ thứ gì
ở runtime (đã kiểm chứng bằng check_weights.py với mọi download bị chặn).
File
| File | Size | Mô tả |
|---|---|---|
caso-pad-offline-2026-11-27.zip |
~1.3 GB | toàn bộ bundle (code + weight + scripts + README) — đã gồm fix 2026-11-30 |
caso-pad-patch-2026-11-30.zip |
20 KB | patch xử lý ảnh hỏng — chỉ cần nếu bạn đã tải bản 2026-11-27 |
preflight.sh |
8 KB | script kiểm tra trước khi train (dùng được với mọi bản zip) |
cvpr2024-cvpr2023-offline-patch-2026-12-01.zip |
68 MB | patch cho repo cvpr2024-face-anti-spoofing-challenge: train protocol p2.1 trên CVPR2023, 2 GPU, offline (kèm wheelhouse/ 69 MB). Hướng dẫn: CVPR2023_TRAIN.md trong zip |
SHA256SUMS.txt |
— | checksum của các file zip |
sha256sum -c SHA256SUMS.txt
Nội dung zip
caso-pad-offline/
├── CASO-PAD-code/ # 16 .py: train.py, train_node1/2.py, ddp_common.py,
│ # build_data.py (+ loader CVPR2023), build_model.py,
│ # evaluate.py, evaluate_fn.py, check_cvpr_dataset.py…
├── torch_cache/hub/checkpoints/ # 17 .pth (1422 MB): 13 backbone × 2 API torchvision
├── env.sh # source -> TORCH_HOME + PYTHONPATH
├── check_env.py # kiểm tra thư viện / GPU / weight / dataset
├── check_weights.py # kiểm tra đủ weight, CHẶN mọi download
├── preflight.sh # kiểm tra toàn bộ trước khi train (PASS/WARN/FAIL)
├── requirements.txt # torch 2.4.1+cu124, torchvision 0.19.1, numpy 2.1.1,
│ # opencv-headless 4.10, scikit-learn 1.5.2, pillow,
│ # tqdm, tensorboard
├── CASO-PAD-code/check_dataset_integrity.py # quét ảnh hỏng (zero-byte/truncated)
├── make_wheelhouse.sh # (tuỳ chọn) sinh .whl để pip offline
├── dataset_paths.example.json
├── MANIFEST.sha256 # sha256 của 50 file
├── VERSION.txt # commit gốc 9fc5604 (2026-08-04)
└── README.md # hướng dẫn đầy đủ (bản trong zip)
Backbone đã cache (cả 2 API weights="DEFAULT" và pretrained=True):
mobilenet_v3_large, mobilenet_v3_small, mobilenet_v2, resnet18, resnet34,
resnet50, efficientnet_b0/b1/b2, convnext_tiny/small, vgg16, shufflenet_v2_x1_0.
Chạy nhanh
scp caso-pad-offline-2026-11-27.zip user@h100:/data/tools/
cd /data/tools && unzip caso-pad-offline-2026-11-27.zip && cd caso-pad-offline
source env.sh
bash preflight.sh # 8 mục: thư viện, weight, code, dataset, ảnh hỏng, GPU, đĩa
python check_weights.py # -> OK: đủ weight cho 13 backbone (17 file), không cần internet
cp dataset_paths.example.json dataset_paths.json
vi dataset_paths.json # { "CVPR": "/data/datasets/CVPR2023/Train" }
# 1 GPU
python CASO-PAD-code/train.py --paper_method caso_pad --training_mode single \
--datasets CVPR --img_size 256 --num_frames 1 --num_frames_val 1 \
--batch_size 32 --num_workers 8 --num_epochs 30 --lr 1e-4 \
--early_stop_patience 5 --inv_kernel 5 --inv_groups 120 --inv_reduce 4
# 1 node x 4 GPU (global batch = 4 x 64 = 256)
CUDA_VISIBLE_DEVICES=0,1,2,3 OMP_NUM_THREADS=1 torchrun --nproc_per_node=4 \
CASO-PAD-code/train_node1.py \
--paper_method caso_pad --training_mode single --datasets CVPR \
--img_size 256 --num_frames 1 --num_frames_val 1 \
--batch_size 64 --num_workers 8 --amp bf16 \
--num_epochs 30 --lr 3e-4 --optimizer adam --scheduler none \
--early_stop_patience 5 \
--inv_kernel 5 --inv_groups 120 --inv_reduce 4
# 1 node x 8 GPU (global batch = 8 x 64 = 512)
OMP_NUM_THREADS=1 torchrun --nproc_per_node=8 \
CASO-PAD-code/train_node1.py \
--paper_method caso_pad --training_mode single --datasets CVPR \
--img_size 256 --num_frames 1 --num_frames_val 1 \
--batch_size 64 --num_workers 8 --amp bf16 \
--num_epochs 30 --lr 4e-4 --optimizer adam --scheduler none \
--early_stop_patience 5 \
--inv_kernel 5 --inv_groups 120 --inv_reduce 4
--batch_size là per-GPU; --lr scale theo global batch
(1 GPU/32 → 1e-4, 4 GPU × 64 → 3e-4, 8 GPU × 64 → 4e-4, quy tắc 1e-4 × sqrt(global/32)).
⚠️ 5 cờ có default khác cấu hình paper — bỏ đi vẫn chạy nhưng ra model khác:
--img_size(default 224),--num_frames/--num_frames_val(default 3),--scheduler(defaultcosine),--early_stop_patience(default 30),--inv_kernel(default 7, paper là 5 — đây là kiến trúc, không chỉ hyperparameter). Bảng giải thích đầy đủ mọi tham số nằm trongREADME.mdbên trong file zip.
Yêu cầu: Python 3.9–3.12, PyTorch ≥ 2.0 + torchvision, numpy/opencv/scikit-learn/pillow/tqdm/tensorboard.
Nếu cụm thiếu thư viện → ./make_wheelhouse.sh trên máy có internet rồi
pip install --no-index --find-links wheelhouse -r requirements.txt.
Dataset (không kèm trong zip)
- Loader có sẵn:
CVPR(CVPR2023 Wild layoutliving/+spoof/<type>/<subject>/), cùng OULU-NPU, SiW-Mv2, MSU-MFSD, CASIA-FASD, Replay-Attack/Mobile, ROSE-Youtu. - Khai báo đường dẫn trong
dataset_paths.json(đường dẫn trên máy đích). - Kiểm tra trước khi train:
python CASO-PAD-code/check_cvpr_dataset.py --root /data/datasets/CVPR2023/Train --limit 1000
Liên quan
- Docker image (đã cài sẵn mọi thứ):
quangducc/caso-pad-face-spoofingtrên Docker Hub. - Upstream code: https://github.com/Shujaat123/CASO-PAD
Đã kiểm chứng (2026-11-27)
| Test | Kết quả |
|---|---|
sha256sum -c MANIFEST.sha256 (50 file) |
✅ |
check_weights.py khi mạng bị chặn |
✅ 13 backbone / 17 file |
train.py 1 epoch khi mạng bị chặn |
✅ không request download |
unzip -t file zip |
✅ no errors |
Fix 2026-11-30 — PIL.UnidentifiedImageError
Nếu dataset có file 0 byte / truncated / không phải ảnh, loader không còn crash:
- bỏ qua file 0 byte khi scan, cảnh báo;
- frame lỗi → tự thử frame khác cùng session, cuối cùng dùng ảnh đen;
- mọi file lỗi ghi vào
corrupt_images.txt.
Quét và dọn toàn bộ dataset trước khi train:
python CASO-PAD-code/check_dataset_integrity.py --root /data/CVPR2023/Train --workers 16 --out corrupt_images.txt # thêm --deep / --delete nếu muốn