feat(exp): sequence support for exp options merge function (#1614)
Browse files- yolox/exp/base_exp.py +12 -1
yolox/exp/base_exp.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
import ast
|
6 |
import pprint
|
7 |
from abc import ABCMeta, abstractmethod
|
8 |
-
from typing import Dict
|
9 |
from tabulate import tabulate
|
10 |
|
11 |
import torch
|
@@ -72,6 +72,17 @@ class BaseExp(metaclass=ABCMeta):
|
|
72 |
if hasattr(self, k):
|
73 |
src_value = getattr(self, k)
|
74 |
src_type = type(src_value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
if src_value is not None and src_type != type(v):
|
76 |
try:
|
77 |
v = src_type(v)
|
|
|
5 |
import ast
|
6 |
import pprint
|
7 |
from abc import ABCMeta, abstractmethod
|
8 |
+
from typing import Dict, List, Tuple
|
9 |
from tabulate import tabulate
|
10 |
|
11 |
import torch
|
|
|
72 |
if hasattr(self, k):
|
73 |
src_value = getattr(self, k)
|
74 |
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 |
+
|
86 |
if src_value is not None and src_type != type(v):
|
87 |
try:
|
88 |
v = src_type(v)
|