-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged procthor code #39
Open
jordis-ai2
wants to merge
16
commits into
allenai:main
Choose a base branch
from
jordis-ai2:procthor-2022
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4ef5bb1
Merged procthor code
jordis-ai2 41d3f84
Update README.md
jordis-ai2 14e25d5
Reduced code duplicity between procthor and ithor rearrange
jordis-ai2 ca2df36
Merge branch 'procthor-2022' of github.com:jordis-ai2/ai2thor-rearran…
jordis-ai2 8a10da7
Merged procthor code
jordis-ai2 0b30189
Merge branch 'allenai:main' into procthor-2022
jordis-ai2 2f817ae
procthor dataset via prior
jordis-ai2 8727618
Install procthor dataset from given revision
jordis-ai2 5e17883
2021 and 2022 episodes datasets installed via prior
jordis-ai2 956c445
Less verbosity in make_valid_houses_file
jordis-ai2 598eecf
Using procthor-10k rearrangement-2022 branch in Houses
jordis-ai2 49786ac
Update .gitignore
jordis-ai2 4906e34
Spurious debug print
jordis-ai2 ba685a5
Bug fix
jordis-ai2 6bedf2a
Bug fix
jordis-ai2 bbf0d6e
Fixed compress-json version
jordis-ai2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
data/2022procthor/mini_val_consolidated.pkl.gz filter=lfs diff=lfs merge=lfs -text | ||
data/2022procthor/split_mini_val filter=lfs diff=lfs merge=lfs -text | ||
data/2022procthor/split_mini_val/** filter=lfs diff=lfs merge=lfs -text | ||
data/2022procthor/split_train filter=lfs diff=lfs merge=lfs -text | ||
data/2022procthor/split_train/** filter=lfs diff=lfs merge=lfs -text | ||
data/2022procthor/train_consolidated.pkl.gz filter=lfs diff=lfs merge=lfs -text | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,3 +156,6 @@ dmypy.json | |
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm settings | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
222 changes: 222 additions & 0 deletions
222
baseline_configs/one_phase/procthor/eval/eval_minivalid_ithor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
from baseline_configs.one_phase.procthor.ithor.ithor_one_phase_rgb_fine_tune import ( | ||
OnePhaseRGBClipResNet50FineTuneExperimentConfig as BaseConfig, | ||
) | ||
|
||
import copy | ||
import platform | ||
from typing import Optional, List, Sequence | ||
|
||
import ai2thor.platform | ||
import torch | ||
|
||
from allenact.base_abstractions.sensor import ExpertActionSensor | ||
from allenact.utils.misc_utils import partition_sequence, md5_hash_str_as_int | ||
from allenact.utils.system import get_logger | ||
from allenact_plugins.ithor_plugin.ithor_sensors import ( | ||
BinnedPointCloudMapTHORSensor, | ||
SemanticMapTHORSensor, | ||
) | ||
from allenact_plugins.ithor_plugin.ithor_util import get_open_x_displays | ||
|
||
|
||
def get_scenes(stage: str) -> List[str]: | ||
"""Returns a list of iTHOR scene names for each stage.""" | ||
assert stage in { | ||
"train", | ||
"train_unseen", | ||
"val", | ||
"valid", | ||
"test", | ||
"all", | ||
"ithor_mini_val", | ||
"debug", | ||
} | ||
|
||
if stage == "debug": | ||
return ["FloorPlan1"] | ||
|
||
# [1-20] for train, [21-25] for val, [26-30] for test | ||
if stage in ["train", "train_unseen"]: | ||
scene_nums = range(1, 21) | ||
elif stage in ["val", "valid", "ithor_mini_val"]: | ||
scene_nums = range(21, 26) | ||
elif stage == "test": | ||
scene_nums = range(26, 31) | ||
elif stage == "all": | ||
scene_nums = range(1, 31) | ||
else: | ||
raise NotImplementedError | ||
|
||
kitchens = [f"FloorPlan{i}" for i in scene_nums] | ||
living_rooms = [f"FloorPlan{200+i}" for i in scene_nums] | ||
bedrooms = [f"FloorPlan{300+i}" for i in scene_nums] | ||
bathrooms = [f"FloorPlan{400+i}" for i in scene_nums] | ||
return kitchens + living_rooms + bedrooms + bathrooms | ||
|
||
|
||
class EvalConfig(BaseConfig): | ||
def stagewise_task_sampler_args( | ||
self, | ||
stage: str, | ||
process_ind: int, | ||
total_processes: int, | ||
allowed_rearrange_inds_subset: Optional[Sequence[int]] = None, | ||
allowed_scenes: Sequence[str] = None, | ||
devices: Optional[List[int]] = None, | ||
seeds: Optional[List[int]] = None, | ||
deterministic_cudnn: bool = False, | ||
): | ||
if allowed_scenes is not None: | ||
scenes = allowed_scenes | ||
elif stage == "combined": | ||
# Split scenes more evenly as the train scenes will have more episodes | ||
train_scenes = get_scenes("train") | ||
other_scenes = get_scenes("val") + get_scenes("test") | ||
assert len(train_scenes) == 2 * len(other_scenes) | ||
scenes = [] | ||
while len(train_scenes) != 0: | ||
scenes.append(train_scenes.pop()) | ||
scenes.append(train_scenes.pop()) | ||
scenes.append(other_scenes.pop()) | ||
assert len(train_scenes) == len(other_scenes) | ||
else: | ||
scenes = get_scenes(stage) | ||
|
||
if total_processes > len(scenes): | ||
assert stage == "train" and total_processes % len(scenes) == 0 | ||
scenes = scenes * (total_processes // len(scenes)) | ||
|
||
allowed_scenes = list( | ||
sorted(partition_sequence(seq=scenes, parts=total_processes,)[process_ind]) | ||
) | ||
|
||
scene_to_allowed_rearrange_inds = None | ||
if allowed_rearrange_inds_subset is not None: | ||
allowed_rearrange_inds_subset = tuple(allowed_rearrange_inds_subset) | ||
assert stage in ["valid", "train_unseen"] | ||
scene_to_allowed_rearrange_inds = { | ||
scene: allowed_rearrange_inds_subset for scene in allowed_scenes | ||
} | ||
seed = md5_hash_str_as_int(str(allowed_scenes)) | ||
|
||
device = ( | ||
devices[process_ind % len(devices)] | ||
if devices is not None and len(devices) > 0 | ||
else torch.device("cpu") | ||
) | ||
x_display: Optional[str] = None | ||
gpu_device: Optional[int] = None | ||
thor_platform: Optional[ai2thor.platform.BaseLinuxPlatform] = None | ||
if platform.system() == "Linux": | ||
try: | ||
x_displays = get_open_x_displays(throw_error_if_empty=True) | ||
|
||
if devices is not None and len( | ||
[d for d in devices if d != torch.device("cpu")] | ||
) > len(x_displays): | ||
get_logger().warning( | ||
f"More GPU devices found than X-displays (devices: `{x_displays}`, x_displays: `{x_displays}`)." | ||
f" This is not necessarily a bad thing but may mean that you're not using GPU memory as" | ||
f" efficiently as possible. Consider following the instructions here:" | ||
f" https://allenact.org/installation/installation-framework/#installation-of-ithor-ithor-plugin" | ||
f" describing how to start an X-display on every GPU." | ||
) | ||
x_display = x_displays[process_ind % len(x_displays)] | ||
except IOError: | ||
# Could not find an open `x_display`, use CloudRendering instead. | ||
assert all( | ||
[d != torch.device("cpu") and d >= 0 for d in devices] | ||
), "Cannot use CPU devices when there are no open x-displays as CloudRendering requires specifying a GPU." | ||
gpu_device = device | ||
thor_platform = ai2thor.platform.CloudRendering | ||
|
||
kwargs = { | ||
"stage": stage, | ||
"allowed_scenes": allowed_scenes, | ||
"scene_to_allowed_rearrange_inds": scene_to_allowed_rearrange_inds, | ||
"seed": seed, | ||
"x_display": x_display, | ||
"thor_controller_kwargs": { | ||
"gpu_device": gpu_device, | ||
"platform": thor_platform, | ||
}, | ||
} | ||
|
||
sensors = kwargs.get("sensors", copy.deepcopy(self.sensors())) | ||
kwargs["sensors"] = sensors | ||
|
||
sem_sensor = next( | ||
(s for s in kwargs["sensors"] if isinstance(s, SemanticMapTHORSensor)), None | ||
) | ||
binned_pc_sensor = next( | ||
( | ||
s | ||
for s in kwargs["sensors"] | ||
if isinstance(s, BinnedPointCloudMapTHORSensor) | ||
), | ||
None, | ||
) | ||
|
||
if sem_sensor is not None: | ||
sem_sensor.device = torch.device(device) | ||
|
||
if binned_pc_sensor is not None: | ||
binned_pc_sensor.device = torch.device(device) | ||
|
||
if stage != "train": | ||
# Don't include several sensors during validation/testing | ||
kwargs["sensors"] = [ | ||
s | ||
for s in kwargs["sensors"] | ||
if not isinstance( | ||
s, | ||
( | ||
ExpertActionSensor, | ||
SemanticMapTHORSensor, | ||
BinnedPointCloudMapTHORSensor, | ||
), | ||
) | ||
] | ||
return kwargs | ||
|
||
def test_task_sampler_args( | ||
self, | ||
process_ind: int, | ||
total_processes: int, | ||
devices=None, | ||
seeds=None, | ||
deterministic_cudnn: bool = False, | ||
task_spec_in_metrics: bool = False, | ||
): | ||
task_spec_in_metrics = False | ||
|
||
# Train_unseen | ||
# stage = "train_unseen" | ||
# allowed_rearrange_inds_subset = list(range(15)) | ||
|
||
# Val | ||
stage = "ithor_mini_val" | ||
allowed_rearrange_inds_subset = None | ||
|
||
# Test | ||
# stage = "test" | ||
# allowed_rearrange_inds_subset = None | ||
|
||
# Combined (Will run inference on all datasets) | ||
# stage = "combined" | ||
# allowed_rearrange_inds_subset = None | ||
|
||
return dict( | ||
force_cache_reset=True, | ||
epochs=1, | ||
task_spec_in_metrics=task_spec_in_metrics, | ||
**self.stagewise_task_sampler_args( | ||
stage=stage, | ||
allowed_rearrange_inds_subset=allowed_rearrange_inds_subset, | ||
process_ind=process_ind, | ||
total_processes=total_processes, | ||
devices=devices, | ||
seeds=seeds, | ||
deterministic_cudnn=deterministic_cudnn, | ||
), | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we have a dependency on
git-lfs
? Was this the issue we were talking about yesterday regarding how theprior
library handles things?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I was actually not planning on using prior to distribute the datasets, but rather following the current design of directly hosting the data in the repository (with the modification of using
git-lfs
to keep future changes in the data from piling up in the history). If I'm right, we just need to clone the repo and all the procthor data is available, as with the iTHOR data.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, I'd prefer we didn't introduce
git-lfs
as a dependency here as it's yet another thing to download and install (and getting this repository working in a new environment is already quite a lot for people). In theprior
package I do some things behind the scenes so that we download agit-lfs
binary onto the users machine in the background if someone doesn't have it so this is why the git lfs dependency isn't as much of an issue there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I guess I wasn't realizing I was able to directly clone the repository precisely because I had already installed
git-lfs
when I pushed the datasets. I'm not super confident about how to properly useprior
to distribute the data, but I guess the example for procthor-10k will do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to keep things more consistent, wouldn't it make more sense to just keep everything in this repo, i.e. without git-lfs given its downsides? We will still have to explain how to install the data in a reachable path (e.g. via additional instructions in README) if we use
prior
.Let me know if you're happy with the solution, and I'll add the dataset files to the repository. If
prior
is actually the preferred choice, then I would create a repo with all the datasets (also the 2021 and 2022 ithor ones) and install all the data via aninvoke
command callingprior.load_dataset
, if that sounds reasonable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and prepared an installer for the ProcTHOR dataset. If the design seems fine, we could port the regular iTHOR ones in a similar way.