Skip to content

Commit 618fd8c

Browse files
authored
feat(exp): sequence support for exp options merge function (Megvii-BaseDetection#1614)
feat(exp): sequence support for exp options merge function
1 parent b3a80be commit 618fd8c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

yolox/exp/base_exp.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import ast
66
import pprint
77
from abc import ABCMeta, abstractmethod
8-
from typing import Dict
8+
from typing import Dict, List, Tuple
99
from tabulate import tabulate
1010

1111
import torch
@@ -72,6 +72,17 @@ def merge(self, cfg_list):
7272
if hasattr(self, k):
7373
src_value = getattr(self, k)
7474
src_type = type(src_value)
75+
76+
# pre-process input if source type is list or tuple
77+
if isinstance(src_value, List) or isinstance(src_value, Tuple):
78+
v = v.strip("[]()")
79+
v = [t.strip() for t in v.split(",")]
80+
81+
# find type of tuple
82+
if len(src_value) > 0:
83+
src_item_type = type(src_value[0])
84+
v = [src_item_type(t) for t in v]
85+
7586
if src_value is not None and src_type != type(v):
7687
try:
7788
v = src_type(v)

0 commit comments

Comments
 (0)