Skip to content

Commit

Permalink
mmdet version fix (#2279)
Browse files Browse the repository at this point in the history
* mmdet version fix

* Fixed missing configs

* Removed comments

* MMDet version check

* fixed assertion error

* Fixed linting

* Fixed black

* Moved data to testing account

* Removed comments

* Fixed typo

---------

Co-authored-by: adolkhan <adilkhan.sarsen@alumni.nu.edu.kz>
  • Loading branch information
adolkhan and adolkhan committed Apr 11, 2023
1 parent 02a6466 commit 3e09809
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
11 changes: 10 additions & 1 deletion deeplake/integrations/mmdet/mmdet_.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,16 @@

from typing import Callable, Optional, List, Dict

from mmdet.apis.train import auto_scale_lr # type: ignore

try:
from mmdet.apis.train import auto_scale_lr # type: ignore
except Exception:
import mmdet # type: ignore

version = mmdet.__version__
raise Exception(
f"MMDet {version} version is not supported. The latest supported MMDet version with deeplake is 2.28.1."
)
from mmdet.utils import ( # type: ignore
build_dp,
compat_cfg,
Expand Down
22 changes: 13 additions & 9 deletions deeplake/integrations/tests/test_mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@


os.system("wandb offline")
os.environ["ACTIVELOOP_HUB_USERNAME"] = "testingacc2"
os.environ["ACTIVELOOP_HUB_PASSWORD"] = "snarkai123"

_THIS_FILE = pathlib.Path(__file__).parent.absolute()
_COCO_PATH = "hub://activeloop/coco-train"
_BALLOON_PATH = "hub://adilkhan/balloon-train"
_BALLOON_PATH = "hub://testingacc2/balloon-train"
_MMDET_KEYS = ["img", "gt_bboxes", "gt_labels", "gt_masks"]
_COCO_KEYS = ["images", "boxes", "categories", "masks"]
_BALLOON_KEYS = ["images", "bounding_boxes", "labels", "segmentation_polygons"]
Expand Down Expand Up @@ -284,13 +286,13 @@ def get_test_config(
if model_name == "mask_rcnn":
model_path = os.path.join(
"mask_rcnn",
"mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco.py",
"mask_rcnn_r50_fpn_poly_1x_coco.py",
)

elif model_name == "yolo":
model_path = os.path.join(
"yolo",
"yolov3_d53_mstrain-608_273e_coco.py",
"yolov3_d53_320_273e_coco.py",
)

cfg = Config.fromfile(
Expand Down Expand Up @@ -355,8 +357,8 @@ def get_test_config(
@pytest.mark.parametrize(
"dataset_path",
[
# "hub://activeloop/coco-train",
"hub://adilkhan/balloon-train",
"hub://activeloop/coco-train",
"hub://testingacc2/balloon-train",
],
)
@pytest.mark.parametrize(
Expand All @@ -366,7 +368,9 @@ def get_test_config(
"False",
],
)
def test_mmdet(mmdet_path, model_name, dataset_path, tensors_specified):
def test_mmdet(
mmdet_path, model_name, dataset_path, tensors_specified, hub_cloud_dev_token
):
import mmcv
from deeplake.integrations import mmdet

Expand All @@ -375,9 +379,9 @@ def test_mmdet(mmdet_path, model_name, dataset_path, tensors_specified):
deeplake_tensors = get_deeplake_tensors(dataset_path, model_name)
cfg = get_test_config(mmdet_path, model_name=model_name, dataset_path=dataset_path)
cfg = process_cfg(cfg, model_name, dataset_path)
ds_train = dp.load(dataset_path)[:2]
ds_val = dp.load(dataset_path)[:2]
if dataset_path == "hub://adilkhan/balloon-train":
ds_train = dp.load(dataset_path, token=hub_cloud_dev_token)[:2]
ds_val = dp.load(dataset_path, token=hub_cloud_dev_token)[:2]
if dataset_path == "hub://testingacc2/balloon-train":
ds_train_with_none = dp.empty("ds_train", overwrite=True)
ds_val_with_none = dp.empty("ds_val", overwrite=True)

Expand Down
5 changes: 3 additions & 2 deletions deeplake/requirements/plugins.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ tensorflow_datasets
pickle5>=0.0.11; python_version < "3.8" and python_version >= "3.6"
ray==1.6.0
datasets~=1.17
mmcv-full==1.7.0; platform_system == "Linux" and python_version >= "3.7"
mmdet; platform_system == "Linux" and python_version >= "3.7"
mmcv-full==1.7.1; platform_system == "Linux" and python_version >= "3.7"
mmdet==2.28.1; platform_system == "Linux" and python_version >= "3.7"
mmengine
18 changes: 17 additions & 1 deletion deeplake/tests/path_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ def _repo_name_from_git_url(url):
return repo_name


def _git_clone_with_branch(branch_name, url):
_repo_name = _repo_name_from_git_url(url)
cached_dir = _GIT_CLONE_CACHE_DIR + "/" + _repo_name
if not os.path.isdir(cached_dir):
if not os.path.isdir(_GIT_CLONE_CACHE_DIR):
os.mkdir(_GIT_CLONE_CACHE_DIR)
cwd = os.getcwd()
os.chdir(_GIT_CLONE_CACHE_DIR)
try:
os.system(f"git clone -b {branch_name} {url}")
finally:
os.chdir(cwd)
assert os.path.isdir(cached_dir)
return cached_dir


def _git_clone(url):
_repo_name = _repo_name_from_git_url(url)
cached_dir = _GIT_CLONE_CACHE_DIR + "/" + _repo_name
Expand Down Expand Up @@ -412,7 +428,7 @@ def grayscale_image_paths():

@pytest.fixture(scope="session")
def mmdet_path():
return _git_clone(_MMDET_URL)
return _git_clone_with_branch("dev-2.x", _MMDET_URL)


@pytest.fixture(scope="session")
Expand Down

0 comments on commit 3e09809

Please sign in to comment.