File size: 1,279 Bytes
ad44ad4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
#!/usr/bin/env bash
TOTAL=${1:-}
if ! [[ "$TOTAL" =~ ^[0-9]+$ ]]; then
  echo "Usage: $0 TOTAL_SAMPLES"
  exit 1
fi

conda activate /mnt/prev_nas/qhy/env/torch240
cd /mnt/prev_nas/qhy/MagicMotion/trajectory_construction/Grounded_SAM2

SCRIPT=/mnt/prev_nas/qhy/MagicMotion/trajectory_construction/image_mask_batch.py

PROMPTS_JSON=/mnt/prev_nas/qhy_1/datasets/unedit_image_prompts/genspace_prompts_vlm.json
DIR_JSONL=/mnt/5T_nas/cwl/wan/OmniGen2/data_configs/train/example/edit/qwen_direction_merged.jsonl
IMG_ROOT=/mnt/prev_nas/qhy_1/datasets/flux_gen_images
OUT_DIR=/mnt/prev_nas/qhy_1/datasets/flux_gen_images_masks

GPUS=(0 1 2 3 4 5 6 7)

N=${#GPUS[@]}
CHUNK=$(( (TOTAL + N - 1) / N ))

echo "TOTAL=${TOTAL}, N=${N}, CHUNK=${CHUNK}"
mkdir -p "${OUT_DIR}"

for i in "${!GPUS[@]}"; do
  GPU=${GPUS[$i]}
  START=$(( i * CHUNK ))
  END=$(( (i + 1) * CHUNK ))
  if [ "$END" -gt "$TOTAL" ]; then END="$TOTAL"; fi
  if [ "$START" -ge "$TOTAL" ]; then continue; fi

  echo "Launch GPU ${GPU}: [${START}, ${END})"
  CUDA_VISIBLE_DEVICES=${GPU} \
  python "$SCRIPT" \
    --prompts_json "$PROMPTS_JSON" \
    --dir_jsonl "$DIR_JSONL" \
    --img_root "$IMG_ROOT" \
    --img_ext ".png" \
    --out_dir "$OUT_DIR" \
    --start "$START" \
    --end "$END" &
done

wait
echo "All done."