video-representations-extractor 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. video-representations-extractor-1.0.0/LICENSE.TXT +13 -0
  2. video-representations-extractor-1.0.0/PKG-INFO +203 -0
  3. video-representations-extractor-1.0.0/README.md +168 -0
  4. video-representations-extractor-1.0.0/bin/vre +85 -0
  5. video-representations-extractor-1.0.0/setup.cfg +4 -0
  6. video-representations-extractor-1.0.0/setup.py +52 -0
  7. video-representations-extractor-1.0.0/video_representations_extractor.egg-info/PKG-INFO +203 -0
  8. video-representations-extractor-1.0.0/video_representations_extractor.egg-info/SOURCES.txt +162 -0
  9. video-representations-extractor-1.0.0/video_representations_extractor.egg-info/dependency_links.txt +1 -0
  10. video-representations-extractor-1.0.0/video_representations_extractor.egg-info/requires.txt +25 -0
  11. video-representations-extractor-1.0.0/video_representations_extractor.egg-info/top_level.txt +1 -0
  12. video-representations-extractor-1.0.0/vre/__init__.py +7 -0
  13. video-representations-extractor-1.0.0/vre/data_storer.py +71 -0
  14. video-representations-extractor-1.0.0/vre/logger.py +69 -0
  15. video-representations-extractor-1.0.0/vre/representation.py +55 -0
  16. video-representations-extractor-1.0.0/vre/representations/__init__.py +2 -0
  17. video-representations-extractor-1.0.0/vre/representations/build_representations.py +118 -0
  18. video-representations-extractor-1.0.0/vre/representations/depth/__init__.py +0 -0
  19. video-representations-extractor-1.0.0/vre/representations/depth/dpt/__init__.py +2 -0
  20. video-representations-extractor-1.0.0/vre/representations/depth/dpt/depth_dpt.py +98 -0
  21. video-representations-extractor-1.0.0/vre/representations/depth/dpt/dpt_impl/__init__.py +0 -0
  22. video-representations-extractor-1.0.0/vre/representations/depth/dpt/dpt_impl/base_model.py +17 -0
  23. video-representations-extractor-1.0.0/vre/representations/depth/dpt/dpt_impl/blocks.py +341 -0
  24. video-representations-extractor-1.0.0/vre/representations/depth/dpt/dpt_impl/dpt_depth.py +107 -0
  25. video-representations-extractor-1.0.0/vre/representations/depth/dpt/dpt_impl/vit.py +492 -0
  26. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/__init__.py +2 -0
  27. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/depth_odo_flow.py +116 -0
  28. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/__init__.py +0 -0
  29. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/cam.py +77 -0
  30. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/camera_info.py +93 -0
  31. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/depth_from_flow.py +734 -0
  32. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/loss.py +88 -0
  33. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/polyfit.py +87 -0
  34. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/utils.py +364 -0
  35. video-representations-extractor-1.0.0/vre/representations/depth/odo_flow/odo_flow_impl/utils_geometry.py +337 -0
  36. video-representations-extractor-1.0.0/vre/representations/dummy_representation.py +26 -0
  37. video-representations-extractor-1.0.0/vre/representations/edges/__init__.py +0 -0
  38. video-representations-extractor-1.0.0/vre/representations/edges/canny.py +39 -0
  39. video-representations-extractor-1.0.0/vre/representations/edges/dexined/__init__.py +2 -0
  40. video-representations-extractor-1.0.0/vre/representations/edges/dexined/dexined.py +82 -0
  41. video-representations-extractor-1.0.0/vre/representations/edges/dexined/model_dexined.py +279 -0
  42. video-representations-extractor-1.0.0/vre/representations/hsv.py +24 -0
  43. video-representations-extractor-1.0.0/vre/representations/normals/__init__.py +0 -0
  44. video-representations-extractor-1.0.0/vre/representations/normals/depth_svd/__init__.py +2 -0
  45. video-representations-extractor-1.0.0/vre/representations/normals/depth_svd/depth_normals_svd.py +78 -0
  46. video-representations-extractor-1.0.0/vre/representations/normals/depth_svd/depth_svd_impl/__init__.py +0 -0
  47. video-representations-extractor-1.0.0/vre/representations/normals/depth_svd/depth_svd_impl/cam.py +77 -0
  48. video-representations-extractor-1.0.0/vre/representations/normals/depth_svd/depth_svd_impl/utils.py +84 -0
  49. video-representations-extractor-1.0.0/vre/representations/optical_flow/__init__.py +0 -0
  50. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/__init__.py +2 -0
  51. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/flow_raft.py +101 -0
  52. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/__init__.py +0 -0
  53. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/corr.py +92 -0
  54. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/datasets.py +236 -0
  55. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/extractor.py +268 -0
  56. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/raft.py +129 -0
  57. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/update.py +140 -0
  58. video-representations-extractor-1.0.0/vre/representations/optical_flow/raft/raft_impl/utils.py +84 -0
  59. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/__init__.py +2 -0
  60. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/flow_rife.py +103 -0
  61. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/rife_impl/IFNet_HD.py +122 -0
  62. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/rife_impl/IFNet_HDv2.py +96 -0
  63. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/rife_impl/RIFE_HDv2.py +216 -0
  64. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/rife_impl/__init__.py +0 -0
  65. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/rife_impl/loss.py +85 -0
  66. video-representations-extractor-1.0.0/vre/representations/optical_flow/rife/rife_impl/warplayer.py +24 -0
  67. video-representations-extractor-1.0.0/vre/representations/rgb.py +23 -0
  68. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/__init__.py +0 -0
  69. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/__init__.py +2 -0
  70. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam.py +174 -0
  71. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam_impl/__init__.py +10 -0
  72. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam_impl/decoder.py +131 -0
  73. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam_impl/model.py +107 -0
  74. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam_impl/predict.py +13 -0
  75. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam_impl/prompt.py +446 -0
  76. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/fastsam/fastsam_impl/utils.py +87 -0
  77. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/__init__.py +2 -0
  78. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/convert.py +852 -0
  79. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former.py +174 -0
  80. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/__init__.py +6 -0
  81. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/comm.py +239 -0
  82. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/__init__.py +3 -0
  83. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/__init__.py +11 -0
  84. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_ade20k_full.py +965 -0
  85. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_ade20k_instance.py +48 -0
  86. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_ade20k_panoptic.py +387 -0
  87. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_coco_panoptic_annos_semseg.py +177 -0
  88. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_coco_stuff_10k.py +224 -0
  89. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_mapillary_vistas.py +508 -0
  90. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/data/datasets/register_mapillary_vistas_panoptic.py +505 -0
  91. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/__init__.py +20 -0
  92. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/benchmark.py +225 -0
  93. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/build.py +687 -0
  94. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/catalog.py +227 -0
  95. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/common.py +370 -0
  96. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/dataset_mapper.py +189 -0
  97. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/__init__.py +10 -0
  98. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/builtin.py +260 -0
  99. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/builtin_meta.py +351 -0
  100. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/cityscapes.py +287 -0
  101. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/cityscapes_panoptic.py +189 -0
  102. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/coco.py +547 -0
  103. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/coco_panoptic.py +190 -0
  104. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/lvis.py +232 -0
  105. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/lvis_v0_5_categories.py +14 -0
  106. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/lvis_v1_categories.py +17 -0
  107. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/lvis_v1_category_image_count.py +21 -0
  108. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/pascal_voc.py +83 -0
  109. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/datasets/register_coco.py +4 -0
  110. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/detection_utils.py +651 -0
  111. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/samplers/__init__.py +18 -0
  112. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/samplers/distributed_sampler.py +291 -0
  113. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/samplers/grouped_batch_sampler.py +48 -0
  114. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/transforms/__init__.py +9 -0
  115. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/transforms/augmentation.py +381 -0
  116. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/transforms/augmentation_impl.py +736 -0
  117. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/det2_data/transforms/transform.py +352 -0
  118. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/file_io.py +40 -0
  119. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/layers/__init__.py +7 -0
  120. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/layers/blocks.py +112 -0
  121. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/layers/deform_conv.py +509 -0
  122. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/layers/norm.py +265 -0
  123. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/layers/shape_spec.py +19 -0
  124. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/layers/wrappers.py +45 -0
  125. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/maskformer_model.py +410 -0
  126. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/__init__.py +5 -0
  127. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/backbone/__init__.py +0 -0
  128. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/backbone/swin.py +770 -0
  129. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/meta_arch/__init__.py +0 -0
  130. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/meta_arch/mask_former_head.py +123 -0
  131. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/pixel_decoder/__init__.py +0 -0
  132. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/pixel_decoder/fpn.py +294 -0
  133. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/pixel_decoder/ms_deform_attn.py +140 -0
  134. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/pixel_decoder/msdeformattn.py +354 -0
  135. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/resnet.py +741 -0
  136. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/transformer_decoder/__init__.py +4 -0
  137. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/transformer_decoder/mask2former_transformer_decoder.py +455 -0
  138. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/transformer_decoder/maskformer_transformer_decoder.py +178 -0
  139. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/transformer_decoder/position_encoding.py +65 -0
  140. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/modeling/transformer_decoder/transformer.py +370 -0
  141. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/__init__.py +10 -0
  142. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/boxes.py +426 -0
  143. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/image_list.py +156 -0
  144. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/instances.py +195 -0
  145. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/keypoints.py +236 -0
  146. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/masks.py +532 -0
  147. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/structures/rotated_boxes.py +504 -0
  148. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/mask2former/mask2former_impl/visualizer.py +1368 -0
  149. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/safeuav/Map2Map.py +109 -0
  150. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/safeuav/__init__.py +2 -0
  151. video-representations-extractor-1.0.0/vre/representations/semantic_segmentation/safeuav/safeuav.py +96 -0
  152. video-representations-extractor-1.0.0/vre/representations/soft_segmentation/__init__.py +0 -0
  153. video-representations-extractor-1.0.0/vre/representations/soft_segmentation/generalized_boundaries/__init__.py +2 -0
  154. video-representations-extractor-1.0.0/vre/representations/soft_segmentation/generalized_boundaries/generalized_boundaries.py +44 -0
  155. video-representations-extractor-1.0.0/vre/representations/soft_segmentation/halftone/__init__.py +2 -0
  156. video-representations-extractor-1.0.0/vre/representations/soft_segmentation/halftone/halftone.py +177 -0
  157. video-representations-extractor-1.0.0/vre/representations/soft_segmentation/kmeans.py +85 -0
  158. video-representations-extractor-1.0.0/vre/utils/__init__.py +4 -0
  159. video-representations-extractor-1.0.0/vre/utils/fake_video.py +25 -0
  160. video-representations-extractor-1.0.0/vre/utils/topological_sort.py +37 -0
  161. video-representations-extractor-1.0.0/vre/utils/utils.py +115 -0
  162. video-representations-extractor-1.0.0/vre/video_representations_extractor.py +130 -0
  163. video-representations-extractor-1.0.0/vre/vre_representation_mixin.py +27 -0
  164. video-representations-extractor-1.0.0/vre/vre_runtime_args.py +125 -0
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.1
2
+ Name: video-representations-extractor
3
+ Version: 1.0.0
4
+ Summary: Video Representations Extractor (VRE) for computing algorithmic or neural representations of each frame.
5
+ Home-page: https://gitlab.com/meehai/video-representations-extractor
6
+ License: WTFPL
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE.TXT
10
+ Requires-Dist: numpy>=1.21.6
11
+ Requires-Dist: PyYAML==6.0
12
+ Requires-Dist: argparse==1.1
13
+ Requires-Dist: pims==0.6.1
14
+ Requires-Dist: tqdm==4.66.1
15
+ Requires-Dist: scikit-image==0.19.3
16
+ Requires-Dist: natsort==8.2.0
17
+ Requires-Dist: gitpython==3.1.31
18
+ Requires-Dist: gdown==4.6.0
19
+ Requires-Dist: torch==2.1.0
20
+ Requires-Dist: torchvision==0.16.0
21
+ Requires-Dist: timm==0.6.13
22
+ Requires-Dist: transforms3d==0.4.1
23
+ Requires-Dist: pyproj>=3.2.0
24
+ Requires-Dist: overrides==7.3.1
25
+ Requires-Dist: pandas==2.1.3
26
+ Requires-Dist: matplotlib==3.7.1
27
+ Requires-Dist: flow_vis==0.1
28
+ Requires-Dist: colorama==0.4.6
29
+ Requires-Dist: omegaconf==2.3.0
30
+ Requires-Dist: lovely_tensors==0.1.15
31
+ Requires-Dist: ultralytics==8.0.120
32
+ Requires-Dist: fvcore==0.1.5.post20221221
33
+ Requires-Dist: pycocotools==2.0.7
34
+ Requires-Dist: cloudpickle==3.0.0
35
+
36
+ # Video Representation Extractor
37
+
38
+ ![logo](logo.png)
39
+
40
+ ## 1. Description
41
+
42
+ The purpose of this repository is to export various representations starting from RGB videos only. Representations are
43
+ defined as ways of 'looking at the world'. One can watch at various levels of information:
44
+ - low level: colors, edges
45
+ - mid level: depth, orientation of planes (normals)
46
+ - high level: semantics and actions
47
+
48
+ For GitHub users: this is a mirror of the
49
+ [gitlab repository](https://gitlab.com/meehai/video-representations-extractor).
50
+
51
+ <u>Supported representations</u>
52
+
53
+ - See [here](vre/representations/build_representations.py) for a comprehensive list, since it updates faster
54
+ than this README.
55
+
56
+ Weights repository for supported pretrained neural-network based representations is
57
+ [here](https://drive.google.com/drive/folders/1bWKEAiTXDpgaY2YOAFBvMqqyOGSafoIm?usp=sharing).
58
+
59
+ ## 2. Usage
60
+
61
+ Add `bin/` directory to your `PATH` env variable to be able to access the `vre` tool directly from cli.
62
+
63
+ ```bash
64
+ vre <path/to/video.mp4> --cfg_path <path/to/cfg> -o <path/to/export_dir>
65
+ ```
66
+
67
+ The magic happens inside the config file, where we define *what* representations to extract and *what* parameters are
68
+ used to instantiate said representations.
69
+
70
+ ### Single image usage
71
+
72
+ You can get the representations for a single image (or a directory of images) by placing your image in a standalone
73
+ directory.
74
+
75
+ ```bash
76
+ vre <path/to/dir_of_images> --cfg_path <path/to/cfg> -o <path/to/export_dir>
77
+ ```
78
+
79
+ Note: use `--cfg_path resources/cfgs/testCfg_ootb.yaml` for 'out of the box' working representations.
80
+ Note2: Use `VRE_DEVICE=cuda vre...` to use cuda. For some representations, this speeds up the process by a lot.
81
+
82
+ ## 3. CFG file
83
+
84
+ The config file will have the hyperparameters required to instantiate each supported method as well as global
85
+ hyperparameters for the output. This means that if a depth method is pre-traied for 0-300m, this information will be
86
+ encoded in the CFG file and passed to the constructor of that particular depth method. There are also export level
87
+ parameters, such as the output resolution of the representations.
88
+
89
+ High level format:
90
+
91
+ ```
92
+ name of representation:
93
+ type: some high level type (such as depth, semantic, edges, etc.)
94
+ name: the implemented method's name (i.e. dexined, dpt, odoflow etc.)
95
+ dependencies: [a list of dependencies given by their names]
96
+ parameters: (as defined in the constructor of the implementation)
97
+ param1: value1
98
+ param2: value2
99
+
100
+ name of representation 2:
101
+ type: some other type
102
+ name: some other method
103
+ dependencies: [name of representation]
104
+ parameters: []
105
+ ```
106
+
107
+ Example cfg file: See [out of the box supported representations](cfgs/testCfg_ootb.yaml) and the CFG defined in
108
+ the [CI process](.gitlab-ci.yml) for an actual export that is done at every commit on a real video.
109
+
110
+ Note: If the topological sort fails (because cycle dependencies), an error will be thrown.
111
+
112
+ Note2: dependencies are provided by names and apply only to the case where one representation (say odo flow) depends
113
+ on a generic secondary representation. In this case *any* optical flow would work as long as we have a motion field
114
+ vector for each frame returned by the required dependency. In cases where dependencies can be infered automatically,
115
+ this is done behind the scenes. All representations require RGB, for example, but this is expected, so we don't need
116
+ to specify it.
117
+
118
+ ## 4. Output format
119
+
120
+ All the outputs are going to be stored as [0-1] float32 npz files, one for each frame in a directory specified by
121
+ `--output_dir/-o`. A subdirectory will be created for each representation.
122
+
123
+ For the above CFG file, 2 subdirectories will be created:
124
+
125
+ ```
126
+ /path/to/output_dir/
127
+ name of representation/
128
+ 1.npz, ..., N.npz + cfg.yaml
129
+ name of representation 2/
130
+ 1.npz, ..., N.npz + cfg.yaml
131
+ ```
132
+
133
+ The `cfg.yaml` file for each representation is created so that we know what parameters were used for that
134
+ representation.
135
+
136
+ ### 4.1 Exporting PNG images
137
+
138
+ We can also export images as a grid collage of all exported representations by adding the CLI argument
139
+ `--export_collage` to the `vre` tool.
140
+
141
+ This yields a new directory with PNGs:
142
+
143
+ ```
144
+ /path/to/output_dir/
145
+ npy/
146
+ 1.npz, ..., N.npz
147
+ png/
148
+ 1.png, ..., N.png
149
+ ```
150
+
151
+ ## 5. Bonus
152
+
153
+ ### 5.1: Exporting video from PNGs
154
+
155
+ After exporting pngs, use this command (requires `ffmpeg`)
156
+
157
+ ```bash
158
+ old_path=`pwd`
159
+ cd /path/to/output_dir/collage
160
+ ffmpeg -start_number 1 -framerate 30 -i %d.png -c:v libx264 -pix_fmt yuv420p $oldPath/collage.mp4;
161
+ cd -;
162
+ ```
163
+
164
+ ### 5.2 Run in docker
165
+ - use `meehai/vre:latest` from docker hub.
166
+
167
+ ```
168
+ mkdir example
169
+ # move the cfg and the video in some local dir
170
+ gdown https://drive.google.com/uc?id=158U-W-Gal6eXxYtS1ca1DAAxHvknqwAk -O example/vid.mp4
171
+ wget https://gitlab.com/meehai/video-representations-extractor/-/raw/df15af177edf5c101bbb241428c43faac333cea4/test/end_to_end/imgur/cfg.yaml -O example/cfg.yaml
172
+ docker run \
173
+ -v `pwd`/example:/app/resources \
174
+ meehai/vre \
175
+ /app/resources/vid.mp4 --cfg_path /app/resources/cfg.yaml -o /app/resources/result --start_frame 5 --end_frame 6
176
+ ```
177
+
178
+ ### 5.3 Batched experiment
179
+
180
+ Last updated at: 2023.11.11
181
+
182
+ See [implementation](examples/batched_experiment.py) for cfg and code.
183
+
184
+ | | batch=1 | batch=3 | ratio 1/3 | batch=5 | ratio 1/5 |
185
+ |:-----------------------|-----------:|-----------:|------------:|-----------:|------------:|
186
+ | rgb | 0.00287311 | 0.00285926 | 1.00485 | 0.00355646 | 0.807857 |
187
+ | hsv | 0.227086 | 0.23222 | 0.977893 | 0.234075 | 0.970141 |
188
+ | normals svd (dpth) | 3.05688 | 3.04678 | 1.00331 | 3.096 | 0.987362 |
189
+ | halftone | 3.1492 | 3.14151 | 1.00245 | 3.13804 | 1.00356 |
190
+ | softseg kmeans | 0.821758 | 0.818581 | 1.00388 | 0.816683 | 1.00621 |
191
+ | canny | 0.0149038 | 0.0143591 | 1.03793 | 0.0142797 | 1.0437 |
192
+ | softseg gb | 0.256591 | 0.244486 | 1.04952 | 0.236025 | 1.08714 |
193
+ | dexined | 0.121858 | 0.10822 | 1.12602 | 0.105016 | 1.16038 |
194
+ | depth dpt | 0.134931 | 0.121348 | 1.11193 | 0.113324 | 1.19066 |
195
+ | depth odoflow (raft) | 1.39505 | 1.17315 | 1.18915 | 1.15518 | 1.20764 |
196
+ | fastsam (x) | 0.0565283 | 0.0414641 | 1.36331 | 0.0392864 | 1.43888 |
197
+ | opticalflow rife | 0.0435189 | 0.0308007 | 1.41292 | 0.0288509 | 1.50841 |
198
+ | opticalflow raft | 0.999548 | 0.742625 | 1.34597 | 0.650921 | 1.53559 |
199
+ | fastsam (s) | 0.0348993 | 0.0215417 | 1.62008 | 0.019354 | 1.80321 |
200
+ | semantic safeuav torch | 0.0251322 | 0.012268 | 2.04859 | 0.00914755 | 2.74742 |
201
+
202
+ We can easily observe that some representations are not batched yet (all with ratios close to 1). We can also observe
203
+ that some of them are super slow (svd, halftone, odoflow).
@@ -0,0 +1,168 @@
1
+ # Video Representation Extractor
2
+
3
+ ![logo](logo.png)
4
+
5
+ ## 1. Description
6
+
7
+ The purpose of this repository is to export various representations starting from RGB videos only. Representations are
8
+ defined as ways of 'looking at the world'. One can watch at various levels of information:
9
+ - low level: colors, edges
10
+ - mid level: depth, orientation of planes (normals)
11
+ - high level: semantics and actions
12
+
13
+ For GitHub users: this is a mirror of the
14
+ [gitlab repository](https://gitlab.com/meehai/video-representations-extractor).
15
+
16
+ <u>Supported representations</u>
17
+
18
+ - See [here](vre/representations/build_representations.py) for a comprehensive list, since it updates faster
19
+ than this README.
20
+
21
+ Weights repository for supported pretrained neural-network based representations is
22
+ [here](https://drive.google.com/drive/folders/1bWKEAiTXDpgaY2YOAFBvMqqyOGSafoIm?usp=sharing).
23
+
24
+ ## 2. Usage
25
+
26
+ Add `bin/` directory to your `PATH` env variable to be able to access the `vre` tool directly from cli.
27
+
28
+ ```bash
29
+ vre <path/to/video.mp4> --cfg_path <path/to/cfg> -o <path/to/export_dir>
30
+ ```
31
+
32
+ The magic happens inside the config file, where we define *what* representations to extract and *what* parameters are
33
+ used to instantiate said representations.
34
+
35
+ ### Single image usage
36
+
37
+ You can get the representations for a single image (or a directory of images) by placing your image in a standalone
38
+ directory.
39
+
40
+ ```bash
41
+ vre <path/to/dir_of_images> --cfg_path <path/to/cfg> -o <path/to/export_dir>
42
+ ```
43
+
44
+ Note: use `--cfg_path resources/cfgs/testCfg_ootb.yaml` for 'out of the box' working representations.
45
+ Note2: Use `VRE_DEVICE=cuda vre...` to use cuda. For some representations, this speeds up the process by a lot.
46
+
47
+ ## 3. CFG file
48
+
49
+ The config file will have the hyperparameters required to instantiate each supported method as well as global
50
+ hyperparameters for the output. This means that if a depth method is pre-traied for 0-300m, this information will be
51
+ encoded in the CFG file and passed to the constructor of that particular depth method. There are also export level
52
+ parameters, such as the output resolution of the representations.
53
+
54
+ High level format:
55
+
56
+ ```
57
+ name of representation:
58
+ type: some high level type (such as depth, semantic, edges, etc.)
59
+ name: the implemented method's name (i.e. dexined, dpt, odoflow etc.)
60
+ dependencies: [a list of dependencies given by their names]
61
+ parameters: (as defined in the constructor of the implementation)
62
+ param1: value1
63
+ param2: value2
64
+
65
+ name of representation 2:
66
+ type: some other type
67
+ name: some other method
68
+ dependencies: [name of representation]
69
+ parameters: []
70
+ ```
71
+
72
+ Example cfg file: See [out of the box supported representations](cfgs/testCfg_ootb.yaml) and the CFG defined in
73
+ the [CI process](.gitlab-ci.yml) for an actual export that is done at every commit on a real video.
74
+
75
+ Note: If the topological sort fails (because cycle dependencies), an error will be thrown.
76
+
77
+ Note2: dependencies are provided by names and apply only to the case where one representation (say odo flow) depends
78
+ on a generic secondary representation. In this case *any* optical flow would work as long as we have a motion field
79
+ vector for each frame returned by the required dependency. In cases where dependencies can be infered automatically,
80
+ this is done behind the scenes. All representations require RGB, for example, but this is expected, so we don't need
81
+ to specify it.
82
+
83
+ ## 4. Output format
84
+
85
+ All the outputs are going to be stored as [0-1] float32 npz files, one for each frame in a directory specified by
86
+ `--output_dir/-o`. A subdirectory will be created for each representation.
87
+
88
+ For the above CFG file, 2 subdirectories will be created:
89
+
90
+ ```
91
+ /path/to/output_dir/
92
+ name of representation/
93
+ 1.npz, ..., N.npz + cfg.yaml
94
+ name of representation 2/
95
+ 1.npz, ..., N.npz + cfg.yaml
96
+ ```
97
+
98
+ The `cfg.yaml` file for each representation is created so that we know what parameters were used for that
99
+ representation.
100
+
101
+ ### 4.1 Exporting PNG images
102
+
103
+ We can also export images as a grid collage of all exported representations by adding the CLI argument
104
+ `--export_collage` to the `vre` tool.
105
+
106
+ This yields a new directory with PNGs:
107
+
108
+ ```
109
+ /path/to/output_dir/
110
+ npy/
111
+ 1.npz, ..., N.npz
112
+ png/
113
+ 1.png, ..., N.png
114
+ ```
115
+
116
+ ## 5. Bonus
117
+
118
+ ### 5.1: Exporting video from PNGs
119
+
120
+ After exporting pngs, use this command (requires `ffmpeg`)
121
+
122
+ ```bash
123
+ old_path=`pwd`
124
+ cd /path/to/output_dir/collage
125
+ ffmpeg -start_number 1 -framerate 30 -i %d.png -c:v libx264 -pix_fmt yuv420p $oldPath/collage.mp4;
126
+ cd -;
127
+ ```
128
+
129
+ ### 5.2 Run in docker
130
+ - use `meehai/vre:latest` from docker hub.
131
+
132
+ ```
133
+ mkdir example
134
+ # move the cfg and the video in some local dir
135
+ gdown https://drive.google.com/uc?id=158U-W-Gal6eXxYtS1ca1DAAxHvknqwAk -O example/vid.mp4
136
+ wget https://gitlab.com/meehai/video-representations-extractor/-/raw/df15af177edf5c101bbb241428c43faac333cea4/test/end_to_end/imgur/cfg.yaml -O example/cfg.yaml
137
+ docker run \
138
+ -v `pwd`/example:/app/resources \
139
+ meehai/vre \
140
+ /app/resources/vid.mp4 --cfg_path /app/resources/cfg.yaml -o /app/resources/result --start_frame 5 --end_frame 6
141
+ ```
142
+
143
+ ### 5.3 Batched experiment
144
+
145
+ Last updated at: 2023.11.11
146
+
147
+ See [implementation](examples/batched_experiment.py) for cfg and code.
148
+
149
+ | | batch=1 | batch=3 | ratio 1/3 | batch=5 | ratio 1/5 |
150
+ |:-----------------------|-----------:|-----------:|------------:|-----------:|------------:|
151
+ | rgb | 0.00287311 | 0.00285926 | 1.00485 | 0.00355646 | 0.807857 |
152
+ | hsv | 0.227086 | 0.23222 | 0.977893 | 0.234075 | 0.970141 |
153
+ | normals svd (dpth) | 3.05688 | 3.04678 | 1.00331 | 3.096 | 0.987362 |
154
+ | halftone | 3.1492 | 3.14151 | 1.00245 | 3.13804 | 1.00356 |
155
+ | softseg kmeans | 0.821758 | 0.818581 | 1.00388 | 0.816683 | 1.00621 |
156
+ | canny | 0.0149038 | 0.0143591 | 1.03793 | 0.0142797 | 1.0437 |
157
+ | softseg gb | 0.256591 | 0.244486 | 1.04952 | 0.236025 | 1.08714 |
158
+ | dexined | 0.121858 | 0.10822 | 1.12602 | 0.105016 | 1.16038 |
159
+ | depth dpt | 0.134931 | 0.121348 | 1.11193 | 0.113324 | 1.19066 |
160
+ | depth odoflow (raft) | 1.39505 | 1.17315 | 1.18915 | 1.15518 | 1.20764 |
161
+ | fastsam (x) | 0.0565283 | 0.0414641 | 1.36331 | 0.0392864 | 1.43888 |
162
+ | opticalflow rife | 0.0435189 | 0.0308007 | 1.41292 | 0.0288509 | 1.50841 |
163
+ | opticalflow raft | 0.999548 | 0.742625 | 1.34597 | 0.650921 | 1.53559 |
164
+ | fastsam (s) | 0.0348993 | 0.0215417 | 1.62008 | 0.019354 | 1.80321 |
165
+ | semantic safeuav torch | 0.0251322 | 0.012268 | 2.04859 | 0.00914755 | 2.74742 |
166
+
167
+ We can easily observe that some representations are not batched yet (all with ratios close to 1). We can also observe
168
+ that some of them are super slow (svd, halftone, odoflow).
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env python3
2
+ from argparse import ArgumentParser
3
+ from typing import List
4
+ from pathlib import Path
5
+ from datetime import datetime
6
+ import os
7
+ from natsort import natsorted
8
+ import numpy as np
9
+ import pandas as pd
10
+ import pims
11
+ from vre import VRE
12
+ from vre.utils import FakeVideo, image_read, get_project_root
13
+ from vre.representations import build_representations_from_cfg
14
+ from vre.logger import logger
15
+ from omegaconf import OmegaConf
16
+
17
+ def _print_and_store_run_stats(run_stats: pd.DataFrame):
18
+ print(run_stats if len(run_stats) > 1 else run_stats.T)
19
+ (logs_dir := Path(os.getenv("VRE_LOGS_DIR", get_project_root() / "logs"))).mkdir(exist_ok=True, parents=True)
20
+ run_stats_out_file = f"{logs_dir}/run_stats_{datetime.now().replace(microsecond=0).isoformat()}.csv"
21
+ logger.info(f"Stored vre run log file at '{run_stats_out_file}")
22
+ run_stats.to_csv(run_stats_out_file)
23
+
24
+ def get_args():
25
+ """cli args"""
26
+ parser = ArgumentParser()
27
+ parser.add_argument("video_path", help="Path to the scene video we are processing")
28
+ parser.add_argument("--output_path", "-o", required=True,
29
+ help="Path to the output directory where representations are stored")
30
+ parser.add_argument("--cfg_path", required=True, help="Path to global YAML cfg file")
31
+ parser.add_argument("--start_frame", type=int, default=0, help="The first frame. If not set, defaults to first.")
32
+ parser.add_argument("--end_frame", type=int, help="End frame. If not set, defaults to length of video")
33
+ parser.add_argument("--output_dir_exist_mode", choices=["overwrite", "skip_computed", "raise"])
34
+ parser.add_argument("--frame_rate", type=int, help="For a directory of images. Required for optical flow")
35
+ parser.add_argument("--batch_size", type=int)
36
+ parser.add_argument("--output_size", nargs="+", default=["video_shape"])
37
+ parser.add_argument("--representations", nargs="+", help="Subset of representations to run VRE for")
38
+ parser.add_argument("--n_threads_data_storer", type=int, default=0)
39
+
40
+ args = parser.parse_args()
41
+ args.video_path = Path(args.video_path).absolute()
42
+ args.output_path = Path(args.output_path).absolute()
43
+ assert 0 < len(args.output_size) < 3, args.output_size
44
+ args.output_size = args.output_size[0] if len(args.output_size) == 1 else tuple(map(int, args.output_size))
45
+ args.cfg_path = Path(args.cfg_path).absolute() if args.cfg_path is not None else args.cfg_path
46
+ return args
47
+
48
+ def get_cfg():
49
+ """cfg and cli args"""
50
+ args = get_args()
51
+ cfg = OmegaConf.load(open(args.cfg_path, "r"))
52
+
53
+ def _update_cfg_from_args(cfg, args, items: List[str]):
54
+ for item in items:
55
+ if getattr(args, item) is None:
56
+ continue
57
+ cfg[item] = getattr(args, item)
58
+ logger.warning(f"--{item} is set to '{cfg[item]}'. Will update the cfg value")
59
+
60
+ return cfg
61
+
62
+ cfg.vre = _update_cfg_from_args(cfg.vre, args, ["start_frame", "end_frame", "output_dir_exist_mode",
63
+ "batch_size", "output_size", "n_threads_data_storer"])
64
+ if args.representations is not None:
65
+ assert (d := set(args.representations).difference(r := cfg.representations.keys())) == set(), f"{d} not in {r}"
66
+ logger.info(f"Keeping only {args.representations} from the config")
67
+ cfg.representations = {k: v for k, v in cfg.representations.items() if k in args.representations}
68
+ return args, cfg
69
+
70
+ def main():
71
+ args, cfg = get_cfg()
72
+ if args.video_path.is_dir():
73
+ raw_data = [image_read(f) for f in natsorted(args.video_path.glob("*.png"), key=lambda p: p.name)]
74
+ assert all(x.shape == raw_data[0].shape for x in raw_data), f"Images shape differ in '{args.video_path}'"
75
+ logger.info(f"--video_path is a directory. Assuming a directory of images. Found {len(raw_data)} images.")
76
+ video = FakeVideo(np.array(raw_data, dtype=np.uint8), frame_rate=args.frame_rate)
77
+ else:
78
+ video = pims.Video(args.video_path)
79
+ representations = build_representations_from_cfg(cfg.representations)
80
+ vre = VRE(video, representations)
81
+ run_stats = vre(args.output_path, **cfg.vre)
82
+ _print_and_store_run_stats(run_stats)
83
+
84
+ if __name__ == "__main__":
85
+ main()
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,52 @@
1
+ from setuptools import setup, find_packages
2
+ from os import path
3
+
4
+
5
+ def get_reqs(requirements):
6
+ # Do not add to required lines pointing to Git repositories
7
+ required, dependency_links = [], []
8
+ EGG_MARK = "#egg="
9
+ for line in requirements:
10
+ if line.startswith("-e git:") or line.startswith("-e git+") or line.startswith("git:") \
11
+ or line.startswith("git+"):
12
+ line = line.lstrip("-e ") # in case that is using "-e"
13
+ if EGG_MARK in line:
14
+ package_name = line[line.find(EGG_MARK) + len(EGG_MARK) :]
15
+ repository = line[: line.find(EGG_MARK)]
16
+ required.append(f"{package_name} @ {repository}")
17
+ dependency_links.append(line)
18
+ else:
19
+ print("Dependency to a git repository should have the format:")
20
+ print("git+ssh://git@github.com/xxxxx/xxxxxx#egg=package_name")
21
+ else:
22
+ required.append(line)
23
+ return required, dependency_links
24
+
25
+
26
+ name = "video-representations-extractor"
27
+ version = "1.0.0"
28
+ description = "Video Representations Extractor (VRE) for computing algorithmic or neural representations of each frame."
29
+ url = "https://gitlab.com/meehai/video-representations-extractor"
30
+
31
+ loc = path.abspath(path.dirname(__file__))
32
+ with open(f"{loc}/README.md", "r", encoding="utf-8") as fh:
33
+ long_description = fh.read()
34
+
35
+ with open(f"{loc}/requirements.txt") as f:
36
+ requirements = f.read().splitlines()
37
+ required, dependency_links = get_reqs(requirements)
38
+
39
+ setup(
40
+ name=name,
41
+ version=version,
42
+ description=description,
43
+ long_description=long_description,
44
+ long_description_content_type="text/markdown",
45
+ url=url,
46
+ packages=find_packages(),
47
+ install_requires=required,
48
+ dependency_links=dependency_links,
49
+ license="WTFPL",
50
+ python_requires=">=3.9",
51
+ scripts=["bin/vre"],
52
+ )