### Install Python Dependencies with pip Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Installs the required Python packages for SemiUHPE: opencv-python, tqdm, matplotlib, scipy, tensorboard, configargparse, lmdb, and pyyaml. ```bash pip install opencv-python tqdm matplotlib scipy tensorboard configargparse lmdb pyyaml ``` -------------------------------- ### Training and Evaluation Example 1: Fully Supervised Training (20% Labeled 300WLP) Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Runs fully supervised training with 20% labeled 300WLP data (unlabeled 300WLP not used) and evaluates on AFLW2000. The eval command loads the best checkpoint from the specified directory. ```bash $ python train.py --config settings/300WLP_AFLW2000.yml --test_set AFLW2000 --network effinetv2 --num_workers 4 --stage1_iteration 60000 --max_iteration 60000 --ss_ratio 0.2 --gpu_ids 0 --batch_size 32 --val_frequency 500 ``` ```bash $ python eval.py SSL1.0_r0.2_ce_effinetv2_t-5.3_b32_ema/Julxx_xxxxxx/best \ --config settings/300WLP_AFLW2000.yml --network effinetv2 --batch_size 32 --gpu_ids 0 ``` -------------------------------- ### Training and Evaluation Example 2: Semi-Supervised Training (SemiUHPE) 20% Labeled + Unlabeled 300WLP Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Semi-supervised training with 20% labeled 300WLP and unlabeled 300WLP (used), evaluated on AFLW2000. Includes augmentation and dynamic threshold flags. ```bash $ python train.py --config settings/300WLP_AFLW2000.yml --network effinetv2 --num_workers 4 --stage1_iteration 60000 \ --max_iteration 100000 --ss_ratio 0.20 --gpu_ids 0 --batch_size 32 --val_frequency 500 --ulb_batch_ratio 4 \ --dynamic_thres --cutout_aug --cutmix_aug --SSL_lambda 1.0 --left_ratio 0.95 ``` ```bash $ python eval.py SSL1.0_r0.2_ce_effinetv2_tDyna0.95_b32_ema_CO_CM/Julxx_xxxxxx/best \ --config settings/300WLP_AFLW2000.yml --network effinetv2 --batch_size 32 --gpu_ids 0 ``` -------------------------------- ### Training and Evaluation Example 4: SemiUHPE with All Labeled 300WLP + COCOHead Unlabeled Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Semi-supervised training using all labeled 300WLP and unlabeled COCOHead, evaluated on AFLW2000. Uses dynamic threshold and mix augmentations. ```bash $ python train.py --config settings/300WLP_COCOHead.yml --network effinetv2 --num_workers 8 --stage1_iteration 90000 \ --max_iteration 120000 --gpu_ids 1 --batch_size 32 --val_frequency 500 --ulb_batch_ratio 8 --dynamic_thres \ --cutout_aug --cutmix_aug --SSL_lambda 1.0 --left_ratio 0.75 ``` ```bash $ python eval.py SSL1.0_r0.05_ce_effinetv2_tDyna0.75_b32_ema_CO_CM/Julxx_xxxxxx/best \ --config settings/300WLP_COCOHead.yml --network effinetv2 --batch_size 32 --gpu_ids 0 ``` -------------------------------- ### Training and Evaluation Example 5: SemiUHPE on DAD3DHeads with COCOHead Unlabeled Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Semi-supervised training on DAD3DHeads train set with unlabeled COCOHead, evaluated on DAD3DHeads val set. Includes rotation augmentation and is_full_range flag. ```bash $ python train.py --config settings/DAD3DHeads_COCOHead.yml --network effinetv2 --num_workers 4 --stage1_iteration 100000 \ --max_iteration 200000 --gpu_ids 1 --batch_size 32 --val_frequency 500 --ulb_batch_ratio 4 --is_full_range \ --dynamic_thres --cutout_aug --cutmix_aug --rotate_aug --SSL_lambda 1.0 --left_ratio 0.75 ``` ```bash $ python eval.py SSL1.0_r0.05_ce_effinetv2_tDyna0.75_b32_ema_RO_CO_CM_full/Julxx_xxxxxx/best --is_full_range \ --config settings/DAD3DHeads_COCOHead.yml --network effinetv2 --batch_size 32 --gpu_ids 0 ``` -------------------------------- ### Training and Evaluation Example 3: Semi-Supervised Baseline (10% Labeled) Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Semi-supervised baseline with 10% labeled 300WLP and unlabeled 300WLP, evaluated on AFLW2000. Uses a confidence threshold of -5.4. ```bash $ python train.py --config settings/300WLP_AFLW2000.yml --network effinetv2 --num_workers 4 --stage1_iteration 40000 \ --max_iteration 80000 --ss_ratio 0.10 --gpu_ids 1 --batch_size 32 --val_frequency 500 --ulb_batch_ratio 4 --conf_thres -5.4 ``` ```bash $ python eval.py SSL1.0_r0.1_ce_effinetv2_t-5.4_b32_ema/Julxx_xxxxxx/best \ --config settings/300WLP_AFLW2000.yml --network effinetv2 --batch_size 32 --gpu_ids 0 ``` -------------------------------- ### Build Sim3DR with setup.py Source: https://github.com/hnuzhy/semiuhpe/blob/main/Sim3DR/readme.md Builds the Sim3DR C++ and Cython extension in place, generating the compiled module in the current directory. ```shell script python3 setup.py build_ext --inplace ``` -------------------------------- ### Run inference on videos with SemiUHPE + effinetv2-s Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Runs video inference using the DAD-WildHead-EffNetV2-S-best pretrained model. Uses the WildHead configuration and effinetv2 backbone. The corresponding weight file 'DAD-WildHead-EffNetV2-S-best.pth' is available on Hugging Face or hf-mirror. ```bash $ python video.py DAD-WildHead-EffNetV2-S-best --is_full_range --config settings/DAD3DHeads_WildHead.yml \ --network effinetv2 --gpu_ids 1 ``` -------------------------------- ### Evaluate SemiUHPE + effinetv2-s on DAD3DHeads test set Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Runs the DAD3DHeads evaluation script with the effinetv2-s backbone (WildHead configuration). Uses the checkpoint from the 'SSL1.0_r0.05_ce_effinetv2_tDyna0.75_b64_ema_RO_CO_CM_full' experiment. Requires the --is_full_range flag and the specified config file. ```bash $ python eval_DAD3DHeads.py SSL1.0_r0.05_ce_effinetv2_tDyna0.75_b64_ema_RO_CO_CM_full/Julxx_xxxxxx/best \ --is_full_range --config settings/DAD3DHeads_WildHead.yml --network effinetv2 --gpu_ids 1 ``` -------------------------------- ### Set W&B project and run name Source: https://github.com/hnuzhy/semiuhpe/blob/main/utils/loggers/wandb/README.md Use this command to manually set the W&B project and run name when training YOLOv5. The default project is 'YOLOv5'. ```shell $ python train.py --project ... --name ... ``` -------------------------------- ### Evaluate SemiUHPE + resnet50 on DAD3DHeads test set Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Runs the DAD3DHeads evaluation script with the resnet50 backbone (COCOHead configuration). Uses the checkpoint from the 'SSL1.0_r0.05_ce_tDyna0.75_b16_ema_RO_CO_CM_full' experiment. The resulting JSON files must be emailed to dad3dheads@gmail.com for benchmark submission. ```bash $ python eval_DAD3DHeads.py SSL1.0_r0.05_ce_tDyna0.75_b16_ema_RO_CO_CM_full/Sep20_195132/best \ --is_full_range --config settings/DAD3DHeads_COCOHead.yml --network resnet50 --gpu_ids 1 ``` -------------------------------- ### Train and Log Evaluation with Dataset Upload Source: https://github.com/hnuzhy/semiuhpe/blob/main/utils/loggers/wandb/README.md Trains a model and logs evaluation metrics after uploading the dataset. This also creates an evaluation table comparing predictions and ground truths, using references to already uploaded datasets to avoid re-uploading images. ```bash $ python utils/logger/wandb/log_dataset.py --data .. --upload_data ``` -------------------------------- ### Run inference on images with SemiUHPE + resnet50 Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Runs image inference using the DAD-COCOHead-ResNet50-best pretrained model. Uses the COCOHead configuration and resnet50 backbone. The corresponding weight file 'DAD-COCOHead-ResNet50-best.pth' is available on Hugging Face or hf-mirror. ```bash $ python image.py DAD-COCOHead-ResNet50-best --is_full_range --config settings/DAD3DHeads_COCOHead.yml \ --network resnet50 --gpu_ids 1 ``` -------------------------------- ### Log Dataset as W&B Table Source: https://github.com/hnuzhy/semiuhpe/blob/main/utils/loggers/wandb/README.md Logs a dataset as a W&B Table, generating a {dataset}_wandb.yaml file for training from the dataset artifact. Use this command to visualize and version your dataset. ```bash $ python utils/logger/wandb/log_dataset.py --project ... --name ... --data .. ``` -------------------------------- ### Train Using Dataset Artifact Source: https://github.com/hnuzhy/semiuhpe/blob/main/utils/loggers/wandb/README.md Trains a model directly from a dataset artifact by using the generated {data}_wandb.yaml file. This also logs evaluation metrics. ```bash $ python utils/logger/wandb/log_dataset.py --data {data}_wandb.yaml ``` -------------------------------- ### Save Model Checkpoints as Artifacts Source: https://github.com/hnuzhy/semiuhpe/blob/main/utils/loggers/wandb/README.md Saves and versions model checkpoints during training by passing --save_period n. If not passed, only the final model is logged. ```bash $ python train.py --save_period 1 ``` -------------------------------- ### Resume Runs from Checkpoint Artifacts Source: https://github.com/hnuzhy/semiuhpe/blob/main/utils/loggers/wandb/README.md Resumes a run from a checkpoint artifact using the wandb-artifact:// prefix with the run path. This does not require the model checkpoint to be present locally. ```bash $ python train.py --resume wandb-artifact://{run_path} ``` -------------------------------- ### BibTeX citation for SemiUHPE paper Source: https://github.com/hnuzhy/semiuhpe/blob/main/README.md Use this BibTeX entry to cite the SemiUHPE paper in academic work. It references the arXiv preprint with the title 'Semi-Supervised Unconstrained Head Pose Estimation in the Wild' and the authors listed. ```bibtex @article{zhou2024semi, title={Semi-Supervised Unconstrained Head Pose Estimation in the Wild}, author={Zhou, Huayi and Jiang, Fei and Jin, Yuan and Yong, Rui and Lu, Hongtao and Kui, Jia}, journal={arXiv preprint arXiv:2404.02544}, year={2024} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.