-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
280 lines (254 loc) · 13.3 KB
/
Makefile
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
SHELL = /bin/bash
TASK_TYPE = tshirt_short
# TASK_TYPE = nut
# TASK_TYPE = rope
TASK_VERSION = debug
EXP_NAME_SUPERVISED = ${TASK_TYPE}-supervised_${TASK_VERSION}
EXP_NAME_SUPERVISED_CLASSIFICATION_DETECTION = ${TASK_TYPE}-supervised_classification_detection_${TASK_VERSION}
EXP_NAME_SUPERVISED_VR = Tshirt-short-action14-dataset-v7_real-hybrid_zero_center_supervised_vr
EXP_NAME_SUPERVISED_DEBUG = ${TASK_TYPE}-supervised_debug
EXP_NAME_FINETUNE = ${TASK_TYPE}-finetune_${TASK_VERSION}
EXP_NAME_FINETUNE_REWARD_PREDICTION = ${TASK_TYPE}-finetune_reward_prediction_${TASK_VERSION}
EXP_NAME_FINETUNE_DEBUG = ${TASK_TYPE}-finetune_debug
EXP_NAME_TEST = ${TASK_TYPE}-action14_test
LOGGING_TAG_SUPERVISED = ${TASK_TYPE}_supervised_${TASK_VERSION}
LOGGING_TAG_SUPERVISED_CLASSIFICATION_DETECTION = ${TASK_TYPE}_supervised_classification_detection_${TASK_VERSION}
LOGGING_TAG_SUPERVISED_DEBUG = ${TASK_TYPE}_supervised_debug
LOGGING_TAG_FINETUNE = ${TASK_TYPE}_finetune_${TASK_VERSION}
LOGGING_TAG_FINETUNE_DEBUG = ${TASK_TYPE}_finetune_debug
LOGGING_TAG_TEST= ${TASK_TYPE}_test
RAW_LOG_NAMESPACE_SUPERVISED = experiment_supervised
RAW_LOG_NAMESPACE_FINETUNE = experiment_finetune
RAW_LOG_NAMESPACE_TEST = experiment_test
START_EPISODE = 0
CONFIG_MVCAM_DEV = $(shell lsusb | grep MindVision | awk 'END { if (NR==0 || $$2=="") print "--"; else print "/dev/bus/usb/"$$2"/"$$4;}' | head -c -2) #/dev/bus/usb/002/002
SECOND_ROBOT_LEFT_CLIENT_PATH = /home/xuehan/2.10.9_flexiv_elements/FlexivElements_v2.10.9_left_v
SECOND_ROBOT_RIGHT_CLIENT_PATH = /home/xuehan/2.10.9_flexiv_elements/FlexivElements_v2.10.9_right_v
ROBOT_LEFT_CLIENT_PATH = /home/xuehan/2.10.9_flexiv_elements/FlexivElements_v2.10.9_left_w
ROBOT_RIGHT_CLIENT_PATH = /home/xuehan/2.10.9_flexiv_elements/FlexivElements_v2.10.9_right_w
DISPLAY_PORT = 12000
ANNO_PORT = 13240
MULTI_POSE_NUM = 10
COMPARE_K = 16
INFERENCE_POINT_NUM = 16
KEYPOINT_NUM = 4
CALIBRATION_PATH = /path/to/calibration/folder
# select the camera to use
CAMERA_PARAM = phoxi_camera_with_rgb
SUPERVISED_MODEL_CKPT_PATH = /path/to/supervised_model/folder
TEST_MODEL_CKPT_PATH = /path/to/test_model/folder
.PHONY: all
all:
@echo "Please specify a target"
manipulation.prerun:
@perm=$$(ls -ld ${CONFIG_MVCAM_DEV} | cut -b 1-10); \
if [ $$perm != "crwxrwxrwx" ]; then \
echo "Changing permissions of ${CONFIG_MVCAM_DEV} to 777"; \
sudo chmod 777 ${CONFIG_MVCAM_DEV}; \
else \
echo "${CONFIG_MVCAM_DEV} permissions have been set!"; \
fi
umask 002
test_experiment: manipulation.prerun
export PYTHONPATH=$$PYTHONPATH:$(shell pwd); \
python \
manipulation/experiment_real.py \
experiment.compat.calibration_path=${CALIBRATION_PATH} \
camera_param=${CAMERA_PARAM} \
# only real data collection (no training)
supervised.run_real: manipulation.prerun
python \
run.py --config-name experiment_supervised_${TASK_TYPE}.yaml \
hydra.job.chdir=True \
experiment.runtime_training_config_override.logger.experiment_name=${EXP_NAME_SUPERVISED} \
experiment.strategy.skip_all_errors=True \
experiment.strategy.start_episode=0 \
experiment.strategy.random_exploration.enable=False \
experiment.strategy.random_lift_in_each_trial=False \
experiment.compat.calibration_path=${CALIBRATION_PATH} \
camera_param=${CAMERA_PARAM} \
logging.tag=${LOGGING_TAG_SUPERVISED} \
inference.model_path=${SUPERVISED_MODEL_CKPT_PATH} \
inference.args.vis_action=False \
inference.args.vis_all_fling_pred=False \
inference.args.manual_operation.remote_args.enable=False \
inference.args.manual_operation.remote_args.display_port=${DISPLAY_PORT} \
inference.args.manual_operation.remote_args.anno_port=${ANNO_PORT} \
inference.args.only_success=False \
inference.args.only_smoothing=True \
experiment.compat.use_real_robots=True
scripts.remote_operation:
export PYTHONPATH=$$PYTHONPATH:$(shell pwd); \
python ./tools/remote_operation/client.py --host 192.168.2.223 \
--display_port ${DISPLAY_PORT} \
--anno_port ${ANNO_PORT}
scripts.run_supervised_annotation:
export PYTHONPATH=$$PYTHONPATH:$(shell pwd); \
python ./tools/run_annotation --raw_log_namespace ${RAW_LOG_NAMESPACE_SUPERVISED} \
--root_dir ${LOGGING_TAG_SUPERVISED} \
--object_type ${TASK_TYPE} \
--annotation_type new_pipeline_supervised \
--multi_pose_num ${MULTI_POSE_NUM} \
--keypoint_num ${KEYPOINT_NUM}
# supervised training using VR data
supervised.train_vr:
python train_supervised.py --config-name train_supervised_tshirt_short_vr.yaml \
hydra.job.chdir=True \
logger.experiment_name=${EXP_NAME_SUPERVISED_VR} \
logger.run_name=action14_supervised_vr \
# supervised training using real data
supervised.train_real:
python train.py --config-name train_supervised_${TASK_TYPE}_real.yaml \
hydra.job.chdir=True \
logger.experiment_name=${EXP_NAME_SUPERVISED} \
logger.run_name=action14_supervised_real \
runtime_datamodule.namespace=${RAW_LOG_NAMESPACE_SUPERVISED} \
runtime_datamodule.tag=${LOGGING_TAG_SUPERVISED} \
runtime_datamodule.num_multiple_poses=${MULTI_POSE_NUM}
# test sampling
test_model:
python test.py \
--config-path outputs/2024-03-23/23-17-41 \
hydra.job.chdir=True \
+save_bson=True \
+scheduler_type=ddpm \
+num_inference_steps=10 \
+ddim_eta=0.0
# only real data collection (no training)
finetune.run_real: manipulation.prerun
python \
run.py --config-path config/finetune_experiment \
--config-name experiment_finetune_${TASK_TYPE}.yaml \
hydra.job.chdir=True \
experiment.runtime_training_config_override.logger.experiment_name=${EXP_NAME_FINETUNE} \
experiment.strategy.skip_all_errors=True \
experiment.strategy.start_episode=0 \
experiment.strategy.random_exploration.enable=False \
experiment.strategy.random_lift_in_each_trial=False \
experiment.compat.calibration_path=${CALIBRATION_PATH} \
camera_param=${CAMERA_PARAM} \
logging.namespace=${RAW_LOG_NAMESPACE_FINETUNE} \
logging.tag=${LOGGING_TAG_FINETUNE} \
inference.model_path=${SUPERVISED_MODEL_CKPT_PATH} \
inference.args.vis_action=True \
inference.args.vis_all_fling_pred=True \
inference.args.vis_pred_order=False \
inference.model_name=last\
inference.args.manual_operation.remote_args.enable=False \
inference.args.manual_operation.remote_args.display_port=${DISPLAY_PORT} \
inference.args.manual_operation.remote_args.anno_port=${ANNO_PORT} \
inference.args.model.diffusion_head_params.scheduler_type=ddim \
inference.args.model.diffusion_head_params.num_inference_steps=100 \
inference.args.model.diffusion_head_params.ddim_eta=1.0 \
+inference.args.model.use_dpo_reward_for_inference=False \
+inference.args.model.random_select_diffusion_action_pair_for_inference=True \
+inference.args.model.inference_point_num=${INFERENCE_POINT_NUM} \
inference.args.only_success=False \
inference.args.only_smoothing=True \
experiment.compat.use_real_robots=True
scripts.run_finetune_sort_annotation:
export PYTHONPATH=$$PYTHONPATH:$(shell pwd); \
python ./tools/run_annotation --raw_log_namespace ${RAW_LOG_NAMESPACE_FINETUNE} \
--root_dir ${LOGGING_TAG_FINETUNE} \
--object_type ${TASK_TYPE} \
--annotation_type new_pipeline_finetune_sort \
--multi_pose_num ${MULTI_POSE_NUM} \
--K ${COMPARE_K} \
--keypoint_num ${KEYPOINT_NUM}
# finetuning using real data
finetune.train_real:
python train.py --config-path config/finetune_experiment \
--config-name train_finetune_${TASK_TYPE}_real.yaml \
hydra.job.chdir=True \
logger.experiment_name=${EXP_NAME_FINETUNE} \
logger.run_name=action14_finetune_real \
runtime_datamodule.namespace=${RAW_LOG_NAMESPACE_FINETUNE} \
runtime_datamodule.tag=${LOGGING_TAG_FINETUNE} \
+runtime_datamodule.manual_num_rankings_per_sample=${COMPARE_K} \
+model.reference_model_path=${SUPERVISED_MODEL_CKPT_PATH} \
# finetuning using real data with reward prediction
finetune.train_real_reward_prediction:
python train.py --config-path config/finetune_experiment \
--config-name train_finetune_reward_prediction_${TASK_TYPE}_real.yaml \
hydra.job.chdir=True \
logger.experiment_name=${EXP_NAME_FINETUNE_REWARD_PREDICTION} \
logger.run_name=action14_finetune_real \
runtime_datamodule.namespace=${RAW_LOG_NAMESPACE_FINETUNE} \
runtime_datamodule.tag=${LOGGING_TAG_FINETUNE} \
+runtime_datamodule.manual_num_rankings_per_sample=${COMPARE_K} \
+model.reference_model_path=${SUPERVISED_MODEL_CKPT_PATH} \
STEP_NUM_PER_TRIAL = $(shell if [ ${TASK_TYPE} = "tshirt_short" ]; then echo 10; \
elif [ ${TASK_TYPE} = "tshirt_long" ]; then echo 10; \
elif [ ${TASK_TYPE} = "nut" ]; then echo 15; \
elif [ ${TASK_TYPE} = "rope" ]; then echo 20; \
else echo "unknown_task_type"; fi)
ACTION_TYPE_OVERRIDE = $(shell if [ ${TASK_TYPE} = "tshirt_short" ]; then echo "null"; \
elif [ ${TASK_TYPE} = "tshirt_long" ]; then echo "null"; \
elif [ ${TASK_TYPE} = "nut" ]; then echo "sweep"; \
elif [ ${TASK_TYPE} = "rope" ]; then echo "single_pick_and_place"; \
else echo "unknown_task_type"; fi)
DDIM_ETA = $(shell if [ ${TASK_TYPE} = "tshirt_short" ]; then echo 0.0; \
elif [ ${TASK_TYPE} = "tshirt_long" ]; then echo 0.0; \
elif [ ${TASK_TYPE} = "nut" ]; then echo 0.0; \
elif [ ${TASK_TYPE} = "rope" ]; then echo 1.0; \
else echo "unknown_task_type"; fi)
# only real data collection (no training)
test_real: manipulation.prerun
python \
run.py --config-path config/finetune_experiment \
--config-name experiment_finetune_${TASK_TYPE}.yaml \
hydra.job.chdir=True \
experiment.runtime_training_config_override.logger.experiment_name=${EXP_NAME_TEST} \
experiment.strategy.skip_all_errors=True \
experiment.strategy.start_episode=0 \
experiment.strategy.step_num_per_trial=${STEP_NUM_PER_TRIAL} \
experiment.strategy.random_exploration.enable=False \
experiment.strategy.random_lift_in_each_trial=False \
experiment.compat.calibration_path=${CALIBRATION_PATH} \
experiment.compat.only_capture_pcd_before_action=False \
camera_param=${CAMERA_PARAM} \
logging.namespace=${RAW_LOG_NAMESPACE_TEST} \
logging.tag=${LOGGING_TAG_TEST} \
inference.model_path=${TEST_MODEL_CKPT_PATH} \
inference.args.vis_action=True \
inference.args.vis_all_fling_pred=True \
inference.args.vis_pred_order=False \
inference.args.vis_pred_order_num=4 \
inference.model_name=last\
+inference.args.test_mode=True \
inference.args.manual_operation.enable=True \
inference.args.manual_operation.remote_args.enable=False \
inference.args.manual_operation.remote_args.display_port=${DISPLAY_PORT} \
inference.args.manual_operation.remote_args.anno_port=${ANNO_PORT} \
inference.args.model.diffusion_head_params.scheduler_type=ddim \
inference.args.model.diffusion_head_params.num_inference_steps=100 \
inference.args.model.diffusion_head_params.ddim_eta=${DDIM_ETA} \
+inference.args.model.use_dpo_reward_for_inference=True \
+inference.args.model.dpo_reward_sample_num=100 \
+inference.args.model.random_select_diffusion_action_pair_for_inference=False \
inference.args.model.manually_select_diffusion_action_pair_for_inference=False \
+inference.args.model.inference_point_num=${INFERENCE_POINT_NUM} \
inference.args.action_type_override.type=${ACTION_TYPE_OVERRIDE} \
inference.args.only_success=False \
inference.args.only_smoothing=True \
inference.args.enable_record=False \
experiment.compat.use_real_robots=True \
tools.capture_gt_pcd: manipulation.prerun
python \
tools/capture_canonical_general.py --config-name experiment_finetune_${TASK_TYPE}.yaml \
hydra.job.chdir=False \
camera_param=${CAMERA_PARAM} \
experiment.compat.segmentation.grounding_dino_config_path=data/checkpoints/GroundingDINO_SwinT_OGC.cfg.py \
experiment.compat.segmentation.grounding_dino_checkpoint_path=data/checkpoints/groundingdino_swint_ogc.pth \
experiment.compat.segmentation.sam_checkpoint_path=data/checkpoints/sam_vit_b_01ec64.pth
debug.controller:
python tools/debug_controller.py
scripts.check_annotation:
export PYTHONPATH=$$PYTHONPATH:$(shell pwd); \
python ./tools/run_annotation --exam_mode \
--multi_pose_num ${MULTI_POSE_NUM} \
--K ${COMPARE_K} \
--keypoint_num ${KEYPOINT_NUM}
.PHONY: clean
clean:
@echo "Cleaning up..."