MattF3550 commited on
Commit
a451e18
·
verified ·
1 Parent(s): a443620

Upload lapa_bridge_3d_all.sh

Browse files
Files changed (1) hide show
  1. lapa_bridge_3d_all.sh +147 -0
lapa_bridge_3d_all.sh ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Full SimplerEnv Bridge suite (4 tasks x 24 episodes) - finetune-matched LAPA config.
3
+ # Intended for product_vq_3d (or any ckpt); same flags as lapa_bridge_smoke.sh.
4
+ #
5
+ # Archives existing ./results and evaluation_results.txt before running.
6
+ #
7
+ # export CKPT_PATH=params::/path/to/streaming_params_N
8
+ # bash "${LAPA_ROOT}/SimplerEnv/scripts/lapa_bridge_3d_all.sh"
9
+ #
10
+ # Optional: EPISODE_END=24 (default), ARCHIVE_PREVIOUS=1 (default), SKIP_TASKS=carrot (comma list)
11
+
12
+ set -euo pipefail
13
+
14
+ gpu_id=0
15
+ policy_model=lapa
16
+
17
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
+ SIMPLER_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
19
+ LAPA_ROOT="$(cd "${SIMPLER_ROOT}/.." && pwd)"
20
+
21
+ : "${CKPT_PATH:?Set CKPT_PATH to params::/abs/path/to/streaming_params_*}"
22
+
23
+ ACTION_SCALE_FILE="${ACTION_SCALE_FILE:-${LAPA_ROOT}/data/bridge_finetune_filtered.csv}"
24
+ EPISODE_START="${EPISODE_START:-0}"
25
+ EPISODE_END="${EPISODE_END:-24}"
26
+ ARCHIVE_PREVIOUS="${ARCHIVE_PREVIOUS:-1}"
27
+ SKIP_TASKS="${SKIP_TASKS:-}"
28
+
29
+ LLAMA_UPDATE_CFG='dict(action_vocab_size=256,delta_vocab_size=8,sample_mode='"'"'text'"'"',theta=50000000,max_sequence_length=32768,scan_attention=False,scan_query_chunk_size=128,scan_key_chunk_size=128,scan_mlp=False,scan_mlp_chunk_size=8192,scan_layers=True)'
30
+
31
+ ckpt_dir="${CKPT_PATH#params::}"
32
+ for f in "${ACTION_SCALE_FILE}" "${LAPA_ROOT}/lapa_checkpoints/tokenizer.model" "${LAPA_ROOT}/lapa_checkpoints/vqgan"; do
33
+ [[ -f "${f}" ]] || { echo "ERROR: missing ${f}"; exit 1; }
34
+ done
35
+ [[ -e "${ckpt_dir}" ]] || { echo "ERROR: checkpoint not found: ${ckpt_dir}"; exit 1; }
36
+
37
+ _should_skip() {
38
+ local tag="$1"
39
+ [[ -z "${SKIP_TASKS}" ]] && return 1
40
+ case ",${SKIP_TASKS}," in
41
+ *",${tag},"*) return 0 ;;
42
+ esac
43
+ return 1
44
+ }
45
+
46
+ _archive_previous() {
47
+ [[ "${ARCHIVE_PREVIOUS}" == "1" ]] || return 0
48
+ if [[ ! -d "${SIMPLER_ROOT}/results" && ! -f "${SIMPLER_ROOT}/evaluation_results.txt" ]]; then
49
+ echo "No prior results to archive."
50
+ return 0
51
+ fi
52
+ local stamp
53
+ stamp="$(date -u +%Y%m%dT%H%M%SZ)"
54
+ local archive_dir="${SIMPLER_ROOT}/results_archive/${stamp}_pre_full_bridge"
55
+ mkdir -p "${archive_dir}"
56
+ if [[ -d "${SIMPLER_ROOT}/results" ]]; then
57
+ mv "${SIMPLER_ROOT}/results" "${archive_dir}/results"
58
+ echo "Archived results -> ${archive_dir}/results"
59
+ fi
60
+ if [[ -f "${SIMPLER_ROOT}/evaluation_results.txt" ]]; then
61
+ mv "${SIMPLER_ROOT}/evaluation_results.txt" "${archive_dir}/evaluation_results.txt"
62
+ echo "Archived evaluation_results.txt -> ${archive_dir}/"
63
+ fi
64
+ mkdir -p "${SIMPLER_ROOT}/results"
65
+ }
66
+
67
+ _run_task() {
68
+ local tag="$1"
69
+ local env_name="$2"
70
+ local scene_name="$3"
71
+ local robot="$4"
72
+ local overlay="$5"
73
+ local max_steps="$6"
74
+ local robot_x="$7"
75
+ local robot_y="$8"
76
+
77
+ if _should_skip "${tag}"; then
78
+ echo "=== SKIP task ${tag} (${env_name}) ==="
79
+ return 0
80
+ fi
81
+
82
+ [[ -f "${overlay}" ]] || { echo "ERROR: missing overlay ${overlay} for ${tag}"; exit 1; }
83
+
84
+ echo ""
85
+ echo "=== LAPA Bridge eval: ${tag} ==="
86
+ echo "ENV_NAME=${env_name} episodes=[${EPISODE_START},${EPISODE_END}) max_steps=${max_steps}"
87
+ echo "scene=${scene_name} robot=${robot}"
88
+ nvidia-smi || true
89
+
90
+ CUDA_VISIBLE_DEVICES=${gpu_id} python "${SIMPLER_ROOT}/simpler_env/main_inference_lapa.py" \
91
+ --policy-model "${policy_model}" \
92
+ --ckpt-path "${CKPT_PATH}" \
93
+ --robot "${robot}" \
94
+ --policy-setup widowx_bridge \
95
+ --action-scale-file "${ACTION_SCALE_FILE}" \
96
+ --control-freq 5 \
97
+ --sim-freq 500 \
98
+ --max-episode-steps "${max_steps}" \
99
+ --env-name "${env_name}" \
100
+ --scene-name "${scene_name}" \
101
+ --rgb-overlay-path "${overlay}" \
102
+ --robot-init-x "${robot_x}" "${robot_x}" 1 \
103
+ --robot-init-y "${robot_y}" "${robot_y}" 1 \
104
+ --obj-variation-mode episode \
105
+ --obj-episode-range "${EPISODE_START}" "${EPISODE_END}" \
106
+ --robot-init-rot-quat-center 0 0 0 1 \
107
+ --robot-init-rot-rpy-range 0 0 1 0 0 1 0 0 1 \
108
+ --load-llama-config 7b \
109
+ --update-llama-config "${LLAMA_UPDATE_CFG}" \
110
+ --vocab-file "${LAPA_ROOT}/lapa_checkpoints/tokenizer.model" \
111
+ --vqgan-checkpoint "${LAPA_ROOT}/lapa_checkpoints/vqgan" \
112
+ --mesh-dim '1,-1,1,1' \
113
+ --tokens-per-action 7 \
114
+ --tokens-per-delta 4 \
115
+ --tf-memory-limit 2048
116
+ }
117
+
118
+ cd "${SIMPLER_ROOT}"
119
+ _archive_previous
120
+
121
+ OVERLAY_V1="${SIMPLER_ROOT}/ManiSkill2_real2sim/data/real_inpainting/bridge_real_eval_1.png"
122
+ OVERLAY_SINK="${SIMPLER_ROOT}/ManiSkill2_real2sim/data/real_inpainting/bridge_sink.png"
123
+
124
+ echo "=== LAPA Bridge full suite (3D / finetune config) ==="
125
+ echo "CKPT_PATH=${CKPT_PATH}"
126
+ echo "ACTION_SCALE_FILE=${ACTION_SCALE_FILE}"
127
+ echo "EPISODE_RANGE=[${EPISODE_START},${EPISODE_END})"
128
+
129
+ _run_task stack \
130
+ StackGreenCubeOnYellowCubeBakedTexInScene-v0 \
131
+ bridge_table_1_v1 widowx "${OVERLAY_V1}" 60 0.147 0.028
132
+
133
+ _run_task carrot \
134
+ PutCarrotOnPlateInScene-v0 \
135
+ bridge_table_1_v1 widowx "${OVERLAY_V1}" 60 0.147 0.028
136
+
137
+ _run_task spoon \
138
+ PutSpoonOnTableClothInScene-v0 \
139
+ bridge_table_1_v1 widowx "${OVERLAY_V1}" 60 0.147 0.028
140
+
141
+ _run_task eggplant \
142
+ PutEggplantInBasketScene-v0 \
143
+ bridge_table_1_v2 widowx_sink_camera_setup "${OVERLAY_SINK}" 120 0.127 0.06
144
+
145
+ echo ""
146
+ echo "Done. Fresh results under ${SIMPLER_ROOT}/results/"
147
+ echo "Summary appended to ${SIMPLER_ROOT}/evaluation_results.txt"