Commit d528bc11 authored by Yanghan Wang's avatar Yanghan Wang Committed by Facebook GitHub Bot
Browse files

group fb override together

Reviewed By: sstsai-adl

Differential Revision: D31806054

fbshipit-source-id: 4ea98405e1f94176cb77ca69077adf9f4d22e77e
parent 3bc23a96
......@@ -7,10 +7,11 @@ import logging
import mock
import yaml
from d2go.utils.helper import reroute_config_path
from detectron2.config import CfgNode as _CfgNode
from fvcore.common.registry import Registry
from .utils import reroute_config_path
logger = logging.getLogger(__name__)
......
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
from typing import Dict, List
import pkg_resources
def reroute_config_path(path: str) -> str:
"""
Supporting rerouting the config files for convenience:
d2go:// -> mobile-vision/d2go/...
detectron2go:// -> mobile-vision/d2go/configs/...
detectron2:// -> vision/fair/detectron2/configs/...
flow:// -> fblearner/flow/projects/mobile_vision/detectron2go/...
mv_experimental:// -> mobile-vision/experimental/...
(see //mobile-vision/experimental:mv_experimental_d2go_yaml_files)
Those config are considered as code, so they'll reflect your current checkout,
try using canary if you have local changes.
"""
if path.startswith("d2go://"):
rel_path = path[len("d2go://") :]
config_in_resource = pkg_resources.resource_filename(
"d2go.model_zoo", os.path.join("configs", rel_path)
)
return config_in_resource
elif path.startswith("detectron2go://"):
rel_path = path[len("detectron2go://") :]
config_in_resource = pkg_resources.resource_filename(
"d2go.model_zoo", os.path.join("configs", rel_path)
)
return config_in_resource
elif path.startswith("detectron2://"):
rel_path = path[len("detectron2://") :]
config_in_resource = pkg_resources.resource_filename(
"detectron2.model_zoo", os.path.join("configs", rel_path)
)
return config_in_resource
return path
def _flatten_config_dict(x, reorder, prefix):
if not isinstance(x, dict):
......
......@@ -190,45 +190,3 @@ class D2Trainer(DefaultTrainer):
elif len(evaluator_list) == 1:
return evaluator_list[0]
return DatasetEvaluators(evaluator_list)
def reroute_config_path(path: str) -> str:
"""
Supporting rerouting the config files for convenience:
d2go:// -> mobile-vision/d2go/...
detectron2go:// -> mobile-vision/d2go/configs/...
detectron2:// -> vision/fair/detectron2/configs/...
flow:// -> fblearner/flow/projects/mobile_vision/detectron2go/...
mv_experimental:// -> mobile-vision/experimental/...
(see //mobile-vision/experimental:mv_experimental_d2go_yaml_files)
Those config are considered as code, so they'll reflect your current checkout,
try using canary if you have local changes.
"""
if path.startswith("d2go://"):
rel_path = path[len("d2go://") :]
config_in_resource = pkg_resources.resource_filename(
"d2go.model_zoo", os.path.join("configs", rel_path)
)
return config_in_resource
elif path.startswith("detectron2go://"):
rel_path = path[len("detectron2go://") :]
config_in_resource = pkg_resources.resource_filename(
"d2go.model_zoo", os.path.join("configs", rel_path)
)
return config_in_resource
elif path.startswith("detectron2://"):
rel_path = path[len("detectron2://") :]
config_in_resource = pkg_resources.resource_filename(
"detectron2.model_zoo", os.path.join("configs", rel_path)
)
return config_in_resource
elif path.startswith("mv_experimental://"):
rel_path = path[len("mv_experimental://") :]
# pyre-fixme[21]: Could not find module `mv_experimental_d2go_yaml_files`.
import mv_experimental_d2go_yaml_files
package_path = get_dir_path(mv_experimental_d2go_yaml_files.__name__)
return os.path.join(package_path, rel_path)
return path
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment