-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
45 lines (25 loc) · 1.05 KB
/
utils.py
File metadata and controls
45 lines (25 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
from pathlib import Path
def get_img_num(folder):
"""
calculate the number of images in a folder
"""
img_suffix = [".jpg", ".jpeg", ".png", ".bmp", ".tiff", ".tif", ".webp"]
img_num = 0
for suffix in img_suffix:
img_num += len(list(Path(folder).rglob(f"*{suffix}")))
return img_num
def get_json_num(folder):
"""
calculate the number of json files in a folder
"""
json_num = len(list(Path(folder).rglob("*.json")))
return json_num
flickr_res_json_dir="/root/ultra_louis_work/runs/flickr_engine_buffer/model_predict"
print("number of json files:", get_json_num(flickr_res_json_dir))
flickr_img_dir="/root/ultra_louis_work/datasets/flickr/full_images"
print("number of flickr images:", get_img_num(flickr_img_dir))
mixed_img_dir="/root/ultra_louis_work/datasets/mixed_grounding/gqa/images"
print("number of images:", get_img_num(mixed_img_dir))
mixed_res_json_dir="/root/ultra_louis_work/runs/mixed_engine_buffer/model_predict"
print("number of json files:", get_json_num(mixed_res_json_dir))