Feng Wang
commited on
Commit
·
a4569b7
1
Parent(s):
ab8809b
revert "chore(core): update launch backend to subprocess (#158)" (#176)
Browse files- tools/train.py +3 -3
- yolox/core/launch.py +9 -11
- yolox/data/datasets/mosaicdetection.py +1 -1
- yolox/utils/boxes.py +1 -9
- yolox/utils/metric.py +0 -7
- yolox/utils/setup_env.py +0 -2
tools/train.py
CHANGED
@@ -12,7 +12,7 @@ import torch.backends.cudnn as cudnn
|
|
12 |
|
13 |
from yolox.core import Trainer, launch
|
14 |
from yolox.exp import get_exp
|
15 |
-
from yolox.utils import configure_nccl
|
16 |
|
17 |
|
18 |
def make_parser():
|
@@ -106,8 +106,8 @@ if __name__ == "__main__":
|
|
106 |
exp = get_exp(args.exp_file, args.name)
|
107 |
exp.merge(args.opts)
|
108 |
|
109 |
-
num_gpu =
|
110 |
-
assert num_gpu <=
|
111 |
|
112 |
dist_url = "auto" if args.dist_url is None else args.dist_url
|
113 |
launch(
|
|
|
12 |
|
13 |
from yolox.core import Trainer, launch
|
14 |
from yolox.exp import get_exp
|
15 |
+
from yolox.utils import configure_nccl
|
16 |
|
17 |
|
18 |
def make_parser():
|
|
|
106 |
exp = get_exp(args.exp_file, args.name)
|
107 |
exp.merge(args.opts)
|
108 |
|
109 |
+
num_gpu = torch.cuda.device_count() if args.devices is None else args.devices
|
110 |
+
assert num_gpu <= torch.cuda.device_count()
|
111 |
|
112 |
dist_url = "auto" if args.dist_url is None else args.dist_url
|
113 |
launch(
|
yolox/core/launch.py
CHANGED
@@ -55,17 +55,15 @@ def launch(
|
|
55 |
port = _find_free_port()
|
56 |
dist_url = f"tcp://127.0.0.1:{port}"
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
for p in processes:
|
68 |
-
p.join()
|
69 |
else:
|
70 |
main_func(*args)
|
71 |
|
|
|
55 |
port = _find_free_port()
|
56 |
dist_url = f"tcp://127.0.0.1:{port}"
|
57 |
|
58 |
+
mp.spawn(
|
59 |
+
_distributed_worker,
|
60 |
+
nprocs=num_gpus_per_machine,
|
61 |
+
args=(
|
62 |
+
main_func, world_size, num_gpus_per_machine,
|
63 |
+
machine_rank, backend, dist_url, args
|
64 |
+
),
|
65 |
+
daemon=False,
|
66 |
+
)
|
|
|
|
|
67 |
else:
|
68 |
main_func(*args)
|
69 |
|
yolox/data/datasets/mosaicdetection.py
CHANGED
@@ -220,4 +220,4 @@ class MosaicDetection(Dataset):
|
|
220 |
origin_img = origin_img.astype(np.float32)
|
221 |
origin_img = 0.5 * origin_img + 0.5 * padded_cropped_img.astype(np.float32)
|
222 |
|
223 |
-
return origin_img, origin_labels
|
|
|
220 |
origin_img = origin_img.astype(np.float32)
|
221 |
origin_img = 0.5 * origin_img + 0.5 * padded_cropped_img.astype(np.float32)
|
222 |
|
223 |
+
return origin_img.astype(np.uint8), origin_labels
|
yolox/utils/boxes.py
CHANGED
@@ -9,7 +9,7 @@ import torchvision
|
|
9 |
|
10 |
__all__ = [
|
11 |
"filter_box", "postprocess", "bboxes_iou", "matrix_iou",
|
12 |
-
"adjust_box_anns", "xyxy2xywh",
|
13 |
]
|
14 |
|
15 |
|
@@ -113,11 +113,3 @@ def xyxy2xywh(bboxes):
|
|
113 |
bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 0]
|
114 |
bboxes[:, 3] = bboxes[:, 3] - bboxes[:, 1]
|
115 |
return bboxes
|
116 |
-
|
117 |
-
|
118 |
-
def xyxy2cxcywh(bboxes):
|
119 |
-
bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 0]
|
120 |
-
bboxes[:, 3] = bboxes[:, 3] - bboxes[:, 1]
|
121 |
-
bboxes[:, 0] = bboxes[:, 0] + bboxes[:, 2] * 0.5
|
122 |
-
bboxes[:, 1] = bboxes[:, 1] + bboxes[:, 3] * 0.5
|
123 |
-
return bboxes
|
|
|
9 |
|
10 |
__all__ = [
|
11 |
"filter_box", "postprocess", "bboxes_iou", "matrix_iou",
|
12 |
+
"adjust_box_anns", "xyxy2xywh",
|
13 |
]
|
14 |
|
15 |
|
|
|
113 |
bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 0]
|
114 |
bboxes[:, 3] = bboxes[:, 3] - bboxes[:, 1]
|
115 |
return bboxes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yolox/utils/metric.py
CHANGED
@@ -13,19 +13,12 @@ import torch
|
|
13 |
__all__ = [
|
14 |
"AverageMeter",
|
15 |
"MeterBuffer",
|
16 |
-
"get_num_devices",
|
17 |
"get_total_and_free_memory_in_Mb",
|
18 |
"occupy_mem",
|
19 |
"gpu_mem_usage",
|
20 |
]
|
21 |
|
22 |
|
23 |
-
def get_num_devices():
|
24 |
-
devices_list_info = os.popen("nvidia-smi -L")
|
25 |
-
devices_list_info = devices_list_info.read().strip().split("\n")
|
26 |
-
return len(devices_list_info)
|
27 |
-
|
28 |
-
|
29 |
def get_total_and_free_memory_in_Mb(cuda_device):
|
30 |
devices_info_str = os.popen(
|
31 |
"nvidia-smi --query-gpu=memory.total,memory.used --format=csv,nounits,noheader"
|
|
|
13 |
__all__ = [
|
14 |
"AverageMeter",
|
15 |
"MeterBuffer",
|
|
|
16 |
"get_total_and_free_memory_in_Mb",
|
17 |
"occupy_mem",
|
18 |
"gpu_mem_usage",
|
19 |
]
|
20 |
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def get_total_and_free_memory_in_Mb(cuda_device):
|
23 |
devices_info_str = os.popen(
|
24 |
"nvidia-smi --query-gpu=memory.total,memory.used --format=csv,nounits,noheader"
|
yolox/utils/setup_env.py
CHANGED
@@ -48,5 +48,3 @@ def configure_module(ulimit_value=8192):
|
|
48 |
except Exception:
|
49 |
# cv2 version mismatch might rasie exceptions.
|
50 |
pass
|
51 |
-
|
52 |
-
os.environ["OMP_NUM_THREADS"] = str(1)
|
|
|
48 |
except Exception:
|
49 |
# cv2 version mismatch might rasie exceptions.
|
50 |
pass
|
|
|
|