File size: 755 Bytes
92142d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Usage: bash count_npz npz_540p
(
  echo "scene,repr,counts"
  ls $1 | while read line; do
    scene_name=$(echo $line | cut -d "_" -f1);
    ls $1/$line | while read line2; do
      n_files=$(find $1/$line/"$line2" -name "*.npz" | wc -l);
      echo "$scene_name","$line2","$n_files";
    done;
  done ) | python -c '''
import sys, pandas as pd;
df = pd.read_csv(sys.stdin);
df2 = df.groupby("scene").apply(lambda x: dict(zip(x["repr"], x["counts"])), include_groups=False).reset_index();
df3 = pd.json_normalize(df2[0]).set_index(df2["scene"]).fillna(0).astype(int);
df4 = df3.reindex(columns=["rgb", *sorted(x for x in df3.columns if x != "rgb")])
df4.columns = [f"{x[0:18]}.." if len(x) > 20 else x for x in df4.columns]
print(df4.to_markdown())
'''