dino_v3.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import timm
  2. vit_model_to_out_indices = {
  3. 'vit_small_patch16_dinov3.lvd1689m': (3, 5, 7, 11),
  4. 'vit_small_plus_patch16_dinov3.lvd1689m': (3, 5, 7, 11),
  5. 'vit_base_patch16_dinov3.lvd1689m': (3, 5, 7, 11),
  6. 'vit_large_patch16_dinov3.lvd1689m': (5, 11, 17, 23),
  7. 'vit_huge_plus_patch16_dinov3.lvd1689m': (7, 15, 23, 31),
  8. 'vit_7b_patch16_dinov3.lvd1689m': (9, 19, 29, 39),
  9. }
  10. def dino_v3_s():
  11. model_name = 'vit_small_patch16_dinov3.lvd1689m'
  12. out_indices = vit_model_to_out_indices[model_name]
  13. backbone = timm.create_model(
  14. model_name=model_name,
  15. features_only=True,
  16. dynamic_img_size=True,
  17. out_indices=out_indices,
  18. # pretrained=True,
  19. # cache_dir='./tmp-timm_cache/DINOv3',
  20. )
  21. return backbone
  22. def dino_v3_s_plus():
  23. model_name = 'vit_small_plus_patch16_dinov3.lvd1689m'
  24. out_indices = vit_model_to_out_indices[model_name]
  25. backbone = timm.create_model(
  26. model_name=model_name,
  27. features_only=True,
  28. dynamic_img_size=True,
  29. out_indices=out_indices,
  30. )
  31. return backbone
  32. def dino_v3_b():
  33. model_name = 'vit_base_patch16_dinov3.lvd1689m'
  34. out_indices = vit_model_to_out_indices[model_name]
  35. backbone = timm.create_model(
  36. model_name=model_name,
  37. features_only=True,
  38. dynamic_img_size=True,
  39. out_indices=out_indices,
  40. )
  41. return backbone
  42. def dino_v3_l():
  43. model_name = 'vit_large_patch16_dinov3.lvd1689m'
  44. out_indices = vit_model_to_out_indices[model_name]
  45. backbone = timm.create_model(
  46. model_name=model_name,
  47. features_only=True,
  48. dynamic_img_size=True,
  49. out_indices=out_indices,
  50. )
  51. return backbone
  52. def dino_v3_h_plus():
  53. model_name = 'vit_huge_plus_patch16_dinov3.lvd1689m'
  54. out_indices = vit_model_to_out_indices[model_name]
  55. backbone = timm.create_model(
  56. model_name=model_name,
  57. features_only=True,
  58. dynamic_img_size=True,
  59. out_indices=out_indices,
  60. )
  61. return backbone
  62. def dino_v3_7b():
  63. model_name = 'vit_7b_patch16_dinov3.lvd1689m'
  64. out_indices = vit_model_to_out_indices[model_name]
  65. backbone = timm.create_model(
  66. model_name=model_name,
  67. features_only=True,
  68. dynamic_img_size=True,
  69. out_indices=out_indices,
  70. )
  71. return backbone