Upload process_ubody.py with huggingface_hub
Browse files- process_ubody.py +29 -0
process_ubody.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import argparse
|
| 3 |
+
from multiprocessing import Pool
|
| 4 |
+
|
| 5 |
+
def findAllFile(base):
|
| 6 |
+
file_path = []
|
| 7 |
+
for root, ds, fs in os.walk(base):
|
| 8 |
+
for f in fs:
|
| 9 |
+
fullname = os.path.join(root, f)
|
| 10 |
+
file_path.append(fullname)
|
| 11 |
+
return file_path
|
| 12 |
+
|
| 13 |
+
def convert(video_path):
|
| 14 |
+
video_name = video_path.split('/')[-1]
|
| 15 |
+
image_path = video_path.replace(video_name, video_name.split('.')[0])
|
| 16 |
+
image_path = image_path.replace('/UBody/', '/UBody_images/')
|
| 17 |
+
os.makedirs(image_path, exist_ok=True)
|
| 18 |
+
os.system(f'ffmpeg -i {video_path} -f image2 -r 30 -b:v 5626k {image_path}/%06d.png')
|
| 19 |
+
|
| 20 |
+
if __name__ == '__main__':
|
| 21 |
+
parser = argparse.ArgumentParser()
|
| 22 |
+
parser.add_argument('--video_folder', type=str, default='./UBody/')
|
| 23 |
+
args = parser.parse_args()
|
| 24 |
+
video_paths = findAllFile(args.video_folder)
|
| 25 |
+
pool = Pool(processes=8)
|
| 26 |
+
pool.map(convert, video_paths)
|
| 27 |
+
pool.close()
|
| 28 |
+
pool.join()
|
| 29 |
+
print(1)
|