Skip to content

Commit

Permalink
fix minor bugs and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzuxin committed Jun 18, 2023
1 parent 5472c4a commit acc19c8
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 56 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ outputs/*
/MUJOCO_LOG.TXT
wandb
experiments/
experiments_saved/
clip/
gpt/
bert/
logs/

*.mp4
libero.egg-info/
.vscode/
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ https://github.com/Lifelong-Robot-Learning/LIBERO/assets/8097542/cbb1522f-0831-4
Please run the following commands in the given order to install the dependency for **LIBERO**.
```
conda create -n libero python=3.8.13
conda activate libero
git clone https://github.com/Lifelong-Robot-Learning/LIBERO.git
cd LIBERO
pip install -r requirements.txt
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
```

Then install the `libero` package:
```
git clone https://github.com/Lifelong-Robot-Learning/LIBERO.git
cd LIBERO
pip install -e .
```

Expand Down Expand Up @@ -116,7 +117,7 @@ then run the following:
export CUDA_VISIBLE_DEVICES=GPU_ID && \
export MUJOCO_EGL_DEVICE_ID=GPU_ID && \
python libero/lifelong/main.py seed=SEED \
benchmark_name=BENCHMARK
benchmark_name=BENCHMARK \
policy=POLICY \
lifelong=ALGO
```
Expand All @@ -131,7 +132,10 @@ python libero/lifelong/evaluate.py --benchmark BENCHMARK_NAME \
--task_id TASK_ID \
--algo ALGO_NAME \
--policy POLICY_NAME \
--seed SEED
--seed SEED \
--ep EPOCH \
--load_task LOAD_TASK \
--device_id CUDA_ID
```

# Citation
Expand Down
7 changes: 5 additions & 2 deletions libero/libero/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
config_file = os.path.join(libero_config_path, "config.yaml")


def get_default_path_dict():
benchmark_root_path = os.path.dirname(os.path.abspath(__file__))
def get_default_path_dict(custom_location=None):
if custom_location is None:
benchmark_root_path = os.path.dirname(os.path.abspath(__file__))
else:
benchmark_root_path = custom_location

# This is a default path for localizing all the default bddl files
bddl_files_default_path = os.path.join(benchmark_root_path, "./bddl_files")
Expand Down
2 changes: 1 addition & 1 deletion libero/lifelong/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def main():
if cfg.lifelong.algo == "PackNet":
algo.eval()
for module_idx, module in enumerate(algo.policy.modules()):
if isinstance(module, nn.Conv2d) or isinstance(module, nn.Linear):
if isinstance(module, torch.nn.Conv2d) or isinstance(module, torch.nn.Linear):
weight = module.weight.data
mask = algo.previous_masks[module_idx].to(cfg.device)
weight[mask.eq(0)] = 0.0
Expand Down
137 changes: 88 additions & 49 deletions notebooks/quick_walkthrough.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/zuxin/anaconda3/envs/libero/lib/python3.8/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"source": [
"from libero.libero import benchmark, get_libero_path, set_libero_path\n",
"from libero.libero import benchmark, get_libero_path, set_libero_default_path\n",
"import os\n",
"from termcolor import colored"
]
Expand Down Expand Up @@ -53,9 +62,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Default benchmark root path: /home/yifengz/workspace/libero-dev/libero/libero\n",
"Default dataset root path: /home/yifengz/workspace/libero-dev/libero/libero/../datasets\n",
"Default bddl files root path: /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files\n"
"Default benchmark root path: /home/zuxin/repo/LIBERO/libero/libero\n",
"Default dataset root path: /home/zuxin/repo/LIBERO/libero/libero/../datasets\n",
"Default bddl files root path: /home/zuxin/repo/LIBERO/libero/libero/./bddl_files\n"
]
}
],
Expand All @@ -79,21 +88,46 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Default benchmark root path: /home/yifengz/custom_project\n",
"Default dataset root path: /home/yifengz/custom_project/../datasets\n",
"Default bddl files root path: /home/yifengz/custom_project/./bddl_files\n"
"[Warning] You are changing the default path for Libero config. This will affect all the paths in the config file.\n",
"[Warning]: assets path /home/zuxin/custom_project/./assets does not exist!\n",
"[Warning]: bddl_files path /home/zuxin/custom_project/./bddl_files does not exist!\n",
"[Warning]: benchmark_root path /home/zuxin/custom_project does not exist!\n",
"[Warning]: datasets path /home/zuxin/custom_project/../datasets does not exist!\n",
"[Warning]: init_states path /home/zuxin/custom_project/./init_files does not exist!\n",
"[Warning]: assets path /home/zuxin/custom_project/./assets does not exist!\n",
"[Warning]: bddl_files path /home/zuxin/custom_project/./bddl_files does not exist!\n",
"[Warning]: benchmark_root path /home/zuxin/custom_project does not exist!\n",
"[Warning]: datasets path /home/zuxin/custom_project/../datasets does not exist!\n",
"[Warning]: init_states path /home/zuxin/custom_project/./init_files does not exist!\n",
"[Warning]: assets path /home/zuxin/custom_project/./assets does not exist!\n",
"[Warning]: bddl_files path /home/zuxin/custom_project/./bddl_files does not exist!\n",
"[Warning]: benchmark_root path /home/zuxin/custom_project does not exist!\n",
"[Warning]: datasets path /home/zuxin/custom_project/../datasets does not exist!\n",
"[Warning]: init_states path /home/zuxin/custom_project/./init_files does not exist!\n",
"[Warning]: assets path /home/zuxin/custom_project/./assets does not exist!\n",
"[Warning]: bddl_files path /home/zuxin/custom_project/./bddl_files does not exist!\n",
"[Warning]: benchmark_root path /home/zuxin/custom_project does not exist!\n",
"[Warning]: datasets path /home/zuxin/custom_project/../datasets does not exist!\n",
"[Warning]: init_states path /home/zuxin/custom_project/./init_files does not exist!\n",
"Default benchmark root path: /home/zuxin/custom_project\n",
"Default dataset root path: /home/zuxin/custom_project/../datasets\n",
"Default bddl files root path: /home/zuxin/custom_project/./bddl_files\n",
"[Warning] You are changing the default path for Libero config. This will affect all the paths in the config file.\n",
"Default benchmark root path: /home/zuxin/repo/LIBERO/libero/libero\n",
"Default dataset root path: /home/zuxin/repo/LIBERO/libero/libero/../datasets\n",
"Default bddl files root path: /home/zuxin/repo/LIBERO/libero/libero/./bddl_files\n"
]
}
],
"source": [
"set_libero_path(os.path.join(os.path.expanduser(\"~\"), \"custom_project\"))\n",
"set_libero_default_path(os.path.join(os.path.expanduser(\"~\"), \"custom_project\"))\n",
"benchmark_root_path = get_libero_path(\"benchmark_root\")\n",
"init_states_default_path = get_libero_path(\"init_states\")\n",
"datasets_default_path = get_libero_path(\"datasets\")\n",
Expand All @@ -102,13 +136,16 @@
"print(\"Default dataset root path: \", datasets_default_path)\n",
"print(\"Default bddl files root path: \", bddl_files_default_path)\n",
"\n",
"# If nothing is specified in the `set_libero_path` function, the path will be changed back to the default path\n",
"# If nothing is specified in the `set_libero_default_path` function, the path will be changed back to the default path\n",
"# We will set back the path to the default path for the subsequent examples\n",
"set_libero_path()\n",
"set_libero_default_path()\n",
"benchmark_root_path = get_libero_path(\"benchmark_root\")\n",
"init_states_default_path = get_libero_path(\"init_states\")\n",
"datasets_default_path = get_libero_path(\"datasets\")\n",
"bddl_files_default_path = get_libero_path(\"bddl_files\")"
"bddl_files_default_path = get_libero_path(\"bddl_files\")\n",
"print(\"Default benchmark root path: \", benchmark_root_path)\n",
"print(\"Default dataset root path: \", datasets_default_path)\n",
"print(\"Default bddl files root path: \", bddl_files_default_path)"
]
},
{
Expand All @@ -129,7 +166,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -155,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -165,16 +202,16 @@
"[info] using task orders [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n",
"10 tasks in the benchmark libero_10: \n",
"The benchmark contains the following tasks:\n",
"\t LIVING_ROOM_SCENE2_put_both_the_alphabet_soup_and_the_tomato_sauce_in_the_basket, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE2_put_both_the_alphabet_soup_and_the_tomato_sauce_in_the_basket.bddl\n",
"\t LIVING_ROOM_SCENE2_put_both_the_cream_cheese_box_and_the_butter_in_the_basket, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE2_put_both_the_cream_cheese_box_and_the_butter_in_the_basket.bddl\n",
"\t KITCHEN_SCENE3_turn_on_the_stove_and_put_the_moka_pot_on_it, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE3_turn_on_the_stove_and_put_the_moka_pot_on_it.bddl\n",
"\t KITCHEN_SCENE4_put_the_black_bowl_in_the_bottom_drawer_of_the_cabinet_and_close_it, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE4_put_the_black_bowl_in_the_bottom_drawer_of_the_cabinet_and_close_it.bddl\n",
"\t LIVING_ROOM_SCENE5_put_the_white_mug_on_the_left_plate_and_put_the_yellow_and_white_mug_on_the_right_plate, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE5_put_the_white_mug_on_the_left_plate_and_put_the_yellow_and_white_mug_on_the_right_plate.bddl\n",
"\t STUDY_SCENE1_pick_up_the_book_and_place_it_in_the_back_compartment_of_the_caddy, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/STUDY_SCENE1_pick_up_the_book_and_place_it_in_the_back_compartment_of_the_caddy.bddl\n",
"\t LIVING_ROOM_SCENE6_put_the_white_mug_on_the_plate_and_put_the_chocolate_pudding_to_the_right_of_the_plate, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE6_put_the_white_mug_on_the_plate_and_put_the_chocolate_pudding_to_the_right_of_the_plate.bddl\n",
"\t LIVING_ROOM_SCENE1_put_both_the_alphabet_soup_and_the_cream_cheese_box_in_the_basket, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE1_put_both_the_alphabet_soup_and_the_cream_cheese_box_in_the_basket.bddl\n",
"\t KITCHEN_SCENE8_put_both_moka_pots_on_the_stove, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE8_put_both_moka_pots_on_the_stove.bddl\n",
"\t KITCHEN_SCENE6_put_the_yellow_and_white_mug_in_the_microwave_and_close_it, detail definition stored in /home/yifengz/workspace/libero-dev/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE6_put_the_yellow_and_white_mug_in_the_microwave_and_close_it.bddl\n"
"\t LIVING_ROOM_SCENE2_put_both_the_alphabet_soup_and_the_tomato_sauce_in_the_basket, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE2_put_both_the_alphabet_soup_and_the_tomato_sauce_in_the_basket.bddl\n",
"\t LIVING_ROOM_SCENE2_put_both_the_cream_cheese_box_and_the_butter_in_the_basket, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE2_put_both_the_cream_cheese_box_and_the_butter_in_the_basket.bddl\n",
"\t KITCHEN_SCENE3_turn_on_the_stove_and_put_the_moka_pot_on_it, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE3_turn_on_the_stove_and_put_the_moka_pot_on_it.bddl\n",
"\t KITCHEN_SCENE4_put_the_black_bowl_in_the_bottom_drawer_of_the_cabinet_and_close_it, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE4_put_the_black_bowl_in_the_bottom_drawer_of_the_cabinet_and_close_it.bddl\n",
"\t LIVING_ROOM_SCENE5_put_the_white_mug_on_the_left_plate_and_put_the_yellow_and_white_mug_on_the_right_plate, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE5_put_the_white_mug_on_the_left_plate_and_put_the_yellow_and_white_mug_on_the_right_plate.bddl\n",
"\t STUDY_SCENE1_pick_up_the_book_and_place_it_in_the_back_compartment_of_the_caddy, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/STUDY_SCENE1_pick_up_the_book_and_place_it_in_the_back_compartment_of_the_caddy.bddl\n",
"\t LIVING_ROOM_SCENE6_put_the_white_mug_on_the_plate_and_put_the_chocolate_pudding_to_the_right_of_the_plate, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE6_put_the_white_mug_on_the_plate_and_put_the_chocolate_pudding_to_the_right_of_the_plate.bddl\n",
"\t LIVING_ROOM_SCENE1_put_both_the_alphabet_soup_and_the_cream_cheese_box_in_the_basket, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/LIVING_ROOM_SCENE1_put_both_the_alphabet_soup_and_the_cream_cheese_box_in_the_basket.bddl\n",
"\t KITCHEN_SCENE8_put_both_moka_pots_on_the_stove, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE8_put_both_moka_pots_on_the_stove.bddl\n",
"\t KITCHEN_SCENE6_put_the_yellow_and_white_mug_in_the_microwave_and_close_it, detail definition stored in /home/zuxin/repo/LIBERO/libero/libero/./bddl_files/libero_10/KITCHEN_SCENE6_put_the_yellow_and_white_mug_in_the_microwave_and_close_it.bddl\n"
]
}
],
Expand Down Expand Up @@ -207,7 +244,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -255,9 +292,9 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[33m[robosuite WARNING] \u001b[0mNo private macro file found! (__init__.py:7)\n",
"\u001b[1m\u001b[33m[robosuite WARNING] \u001b[0mIt is recommended to use a private macro file (__init__.py:8)\n",
"\u001b[1m\u001b[33m[robosuite WARNING] \u001b[0mTo setup, run: python /home/yifengz/workspace/robosuite-master/robosuite/scripts/setup_macros.py (__init__.py:9)\n"
"[robosuite WARNING] No private macro file found! (__init__.py:7)\n",
"[robosuite WARNING] It is recommended to use a private macro file (__init__.py:8)\n",
"[robosuite WARNING] To setup, run: python /home/zuxin/anaconda3/envs/libero/lib/python3.8/site-packages/robosuite/scripts/setup_macros.py (__init__.py:9)\n"
]
},
{
Expand Down Expand Up @@ -328,18 +365,26 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[32m[X] Dataset libero_object is complete\u001b[0m\n",
"\u001b[1m\u001b[32m[X] Dataset libero_goal is complete\u001b[0m\n",
"\u001b[1m\u001b[32m[X] Dataset libero_spatial is complete\u001b[0m\n",
"\u001b[1m\u001b[32m[X] Dataset libero_10 is complete\u001b[0m\n",
"\u001b[1m\u001b[32m[X] Dataset libero_90 is complete\u001b[0m\n"
"[ ] Dataset libero_object not found!!!\n",
"[ ] Dataset libero_goal not found!!!\n",
"[X] Dataset libero_spatial is complete\n",
"[X] Dataset libero_10 is complete\n",
"[X] Dataset libero_90 is complete\n",
"Downloading libero_spatial\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"04k94hyizn4huhbv5sz4ev9p2h1p6s7f.zip: 2.88GB [02:56, 16.3MB/s] \n"
]
}
],
Expand Down Expand Up @@ -371,7 +416,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1178,7 +1223,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -1222,7 +1267,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand All @@ -1231,14 +1276,6 @@
"text": [
"Number of tasks in the benchmark libero_10: 10\n"
]
},
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mThe Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
]
}
],
"source": [
Expand Down Expand Up @@ -1279,9 +1316,11 @@
}
],
"metadata": {
"interpreter": {
"hash": "64fd624917382b0c0ee6e40067ed4768d5d5501e9a56437104405cabbecfa898"
},
"kernelspec": {
"display_name": "new-continual-learning",
"language": "python",
"display_name": "Python 3.8.13 64-bit ('libero': conda)",
"name": "python3"
},
"language_info": {
Expand All @@ -1294,7 +1333,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.13"
},
"orig_nbformat": 4
},
Expand Down
36 changes: 36 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os

from libero.libero import benchmark
from libero.libero.envs import OffScreenRenderEnv


benchmark_dict = benchmark.get_benchmark_dict()
task_suite_name = "libero_10" # can also choose libero_spatial, libero_object, etc.
task_suite = benchmark_dict[task_suite_name]()

# retrieve a specific task
task_id = 0
task = task_suite.get_task(task_id)
task_name = task.name
task_description = task.language
task_bddl_file = os.path.join(benchmark.get_libero_path("bddl_files"), task.problem_folder, task.bddl_file)
print(f"[info] retrieving task {task_id} from suite {task_suite_name}, the " + \
f"language instruction is {task_description}, and the bddl file is {task_bddl_file}")

# step over the environment
env_args = {
"bddl_file_name": task_bddl_file,
"camera_heights": 128,
"camera_widths": 128
}
env = OffScreenRenderEnv(**env_args)
env.seed(0)
env.reset()
init_states = task_suite.get_task_init_states(task_id) # for benchmarking purpose, we fix the a set of initial states
init_state_id = 0
env.set_init_state(init_states[init_state_id])

dummy_action = [0.] * 7
for step in range(10):
obs, reward, done, info = env.step(dummy_action)
env.close()

0 comments on commit acc19c8

Please sign in to comment.