File size: 1,290 Bytes
1d4b965
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Download (if needed) and extract the SyncLight base files.
#
#   bash scripts/extract.sh <dest> [source] [split]
#     source: all (default) | infinigen | blenderkit | real
#     split:  all (default) | train | test
#
# Result:
#   <dest>/infinigen/{train,test}/<room>/<seed>/rendered/...
#   <dest>/blenderkit/{train,test}/<scene>/rendered/...
#   <dest>/real/{train,test}/<scene>/captured/...
set -euo pipefail

DEST=${1:?usage: extract.sh <dest> [all|infinigen|blenderkit|real] [all|train|test]}
SOURCE=${2:-all}
SPLIT=${3:-all}
REPO=${SYNCLIGHT_REPO:-davidserra9/synclight}
HERE=$(cd "$(dirname "$0")/.." && pwd)

src_glob=$([ "$SOURCE" = all ] && echo "*" || echo "$SOURCE")
split_glob=$([ "$SPLIT" = all ] && echo "*" || echo "$SPLIT")

if ! compgen -G "$HERE/$src_glob/$split_glob/*.tar" > /dev/null; then
  echo "Downloading $src_glob/$split_glob/*.tar from $REPO ..."
  hf download "$REPO" --repo-type dataset --include "$src_glob/$split_glob/*.tar" --local-dir "$HERE"
fi

for t in "$HERE"/$src_glob/$split_glob/*.tar; do
  rel=${t#"$HERE/"}                # <source>/<split>/<scene>.tar
  src=${rel%%/*}; rest=${rel#*/}; split=${rest%%/*}
  mkdir -p "$DEST/$src/$split"
  echo "extracting $rel"
  tar -xf "$t" -C "$DEST/$src/$split"
done
echo "done: $DEST"