目录
fvcore库的简介
fvcore是一个轻量级的核心库,它提供了在各种计算机视觉框架(如Detectron2)中共享的最常见和最基本的功能。这个库基于Python 3.6+和PyTorch。这个库中的所有组件都经过了类型注释、测试和基准测试。Facebook 的人工智能实验室即FAIR的计算机视觉组负责维护这个库。
github地址:https://github.com/facebookresearch/fvcore
fvcore库的安装
pip install -U 'git+https://github.com/facebookresearch/fvcore'
fvcore库的使用方法
1、基础用法
1. """Configs.""" 2. from fvcore.common.config import CfgNode 3. 4. # ----------------------------------------------------------------------------- 5. # Config definition 6. # ----------------------------------------------------------------------------- 7. _C = CfgNode() 8. 9. 10. # ---------------------------------------------------------------------------- # 11. # Batch norm options 12. # ---------------------------------------------------------------------------- # 13. _C.BN = CfgNode() 14. 15. # BN epsilon. 16. _C.BN.EPSILON = 1e-5 17. 18. # BN momentum. 19. _C.BN.MOMENTUM = 0.1 20. 21. # Precise BN stats. 22. _C.BN.USE_PRECISE_STATS = False 23. 24. # Number of samples use to compute precise bn. 25. _C.BN.NUM_BATCHES_PRECISE = 200 26. 27. # Weight decay value that applies on BN. 28. _C.BN.WEIGHT_DECAY = 0.0 29. 30. 31. # ---------------------------------------------------------------------------- # 32. # Training options. 33. # ---------------------------------------------------------------------------- # 34. _C.TRAIN = CfgNode() 35. 36. # If True Train the model, else skip training. 37. _C.TRAIN.ENABLE = True 38. 39. # Dataset. 40. _C.TRAIN.DATASET = "kinetics" 41. 42. # Total mini-batch size. 43. _C.TRAIN.BATCH_SIZE = 64 44. 45. # Evaluate model on test data every eval period epochs. 46. _C.TRAIN.EVAL_PERIOD = 1 47. 48. # Save model checkpoint every checkpoint period epochs. 49. _C.TRAIN.CHECKPOINT_PERIOD = 1 50. 51. # Resume training from the latest checkpoint in the output directory. 52. _C.TRAIN.AUTO_RESUME = True 53. 54. # Path to the checkpoint to load the initial weight. 55. _C.TRAIN.CHECKPOINT_FILE_PATH = "" 56. 57. # Checkpoint types include `caffe2` or `pytorch`. 58. _C.TRAIN.CHECKPOINT_TYPE = "pytorch" 59. 60. # If True, perform inflation when loading checkpoint. 61. _C.TRAIN.CHECKPOINT_INFLATE = False