Feng Wang commited on
Commit
261b519
·
1 Parent(s): 46c1362

feat(YOLOX): lint code and add a simple workflow (#400)

Browse files
.github/workflows/ci.yaml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This is a basic workflow to help you get started with Actions
2
+
3
+ name: CI
4
+
5
+ # Controls when the action will run. Triggers the workflow on push or pull request
6
+ # events but only for the master branch
7
+ on:
8
+ push:
9
+ pull_request:
10
+
11
+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
12
+ jobs:
13
+ # This workflow contains a single job called "build"
14
+ build:
15
+ # The type of runner that the job will run on
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ matrix:
19
+ python-version: [3.6, 3.7, 3.8]
20
+
21
+ # Steps represent a sequence of tasks that will be executed as part of the job
22
+ steps:
23
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24
+ - uses: actions/checkout@v2
25
+
26
+ - name: Set up Python ${{ matrix.python-version }}
27
+ uses: actions/setup-python@v1
28
+ with:
29
+ python-version: ${{ matrix.python-version }}
30
+
31
+ - name: Install dependencies
32
+ run: |
33
+ python -m pip install --upgrade pip
34
+ pip install -r requirements.txt
35
+ pip install isort==4.3.21
36
+ pip install flake8==3.8.3
37
+ # Runs a set of commands using the runners shell
38
+ - name: Format check
39
+ run: ./.github/workflows/format_check.sh
.github/workflows/format_check.sh ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash -e
2
+
3
+ set -e
4
+
5
+ export PYTHONPATH=$PWD:$PYTHONPATH
6
+
7
+ flake8 yolox || flake8_ret=$?
8
+ if [ "$flake8_ret" ]; then
9
+ exit $flake8_ret
10
+ fi
11
+ echo "All flake check passed!"
12
+ isort --check-only -rc yolox || isort_ret=$?
13
+ if [ "$isort_ret" ]; then
14
+ exit $isort_ret
15
+ fi
16
+ echo "All isort check passed!"
demo/MegEngine/python/build.py CHANGED
@@ -3,7 +3,6 @@
3
 
4
  import megengine as mge
5
  import megengine.module as M
6
- from megengine import jit
7
 
8
  from models.yolo_fpn import YOLOFPN
9
  from models.yolo_head import YOLOXHead
 
3
 
4
  import megengine as mge
5
  import megengine.module as M
 
6
 
7
  from models.yolo_fpn import YOLOFPN
8
  from models.yolo_head import YOLOXHead
demo/MegEngine/python/coco_classes.py DELETED
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding:utf-8 -*-
3
- # Copyright (c) Megvii, Inc. and its affiliates.
4
-
5
- COCO_CLASSES = (
6
- "person",
7
- "bicycle",
8
- "car",
9
- "motorcycle",
10
- "airplane",
11
- "bus",
12
- "train",
13
- "truck",
14
- "boat",
15
- "traffic light",
16
- "fire hydrant",
17
- "stop sign",
18
- "parking meter",
19
- "bench",
20
- "bird",
21
- "cat",
22
- "dog",
23
- "horse",
24
- "sheep",
25
- "cow",
26
- "elephant",
27
- "bear",
28
- "zebra",
29
- "giraffe",
30
- "backpack",
31
- "umbrella",
32
- "handbag",
33
- "tie",
34
- "suitcase",
35
- "frisbee",
36
- "skis",
37
- "snowboard",
38
- "sports ball",
39
- "kite",
40
- "baseball bat",
41
- "baseball glove",
42
- "skateboard",
43
- "surfboard",
44
- "tennis racket",
45
- "bottle",
46
- "wine glass",
47
- "cup",
48
- "fork",
49
- "knife",
50
- "spoon",
51
- "bowl",
52
- "banana",
53
- "apple",
54
- "sandwich",
55
- "orange",
56
- "broccoli",
57
- "carrot",
58
- "hot dog",
59
- "pizza",
60
- "donut",
61
- "cake",
62
- "chair",
63
- "couch",
64
- "potted plant",
65
- "bed",
66
- "dining table",
67
- "toilet",
68
- "tv",
69
- "laptop",
70
- "mouse",
71
- "remote",
72
- "keyboard",
73
- "cell phone",
74
- "microwave",
75
- "oven",
76
- "toaster",
77
- "sink",
78
- "refrigerator",
79
- "book",
80
- "clock",
81
- "vase",
82
- "scissors",
83
- "teddy bear",
84
- "hair drier",
85
- "toothbrush",
86
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
demo/MegEngine/python/demo.py CHANGED
@@ -11,9 +11,10 @@ import megengine as mge
11
  import megengine.functional as F
12
  from loguru import logger
13
 
14
- from coco_classes import COCO_CLASSES
15
- from process import postprocess, preprocess
16
- from visualize import vis
 
17
  from build import build_and_load
18
 
19
  IMAGE_EXT = [".jpg", ".jpeg", ".webp", ".bmp", ".png"]
@@ -51,6 +52,43 @@ def get_image_list(path):
51
  return image_names
52
 
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  class Predictor(object):
55
  def __init__(
56
  self,
@@ -168,7 +206,6 @@ def imageflow_demo(predictor, vis_folder, current_time, args):
168
 
169
 
170
  def main(args):
171
-
172
  file_name = os.path.join("./yolox_outputs", args.name)
173
  os.makedirs(file_name, exist_ok=True)
174
 
 
11
  import megengine.functional as F
12
  from loguru import logger
13
 
14
+ from yolox.data.datasets import COCO_CLASSES
15
+ from yolox.utils import vis
16
+ from yolox.data.data_augment import preproc as preprocess
17
+
18
  from build import build_and_load
19
 
20
  IMAGE_EXT = [".jpg", ".jpeg", ".webp", ".bmp", ".png"]
 
52
  return image_names
53
 
54
 
55
+ def postprocess(prediction, num_classes, conf_thre=0.7, nms_thre=0.45):
56
+ box_corner = F.zeros_like(prediction)
57
+ box_corner[:, :, 0] = prediction[:, :, 0] - prediction[:, :, 2] / 2
58
+ box_corner[:, :, 1] = prediction[:, :, 1] - prediction[:, :, 3] / 2
59
+ box_corner[:, :, 2] = prediction[:, :, 0] + prediction[:, :, 2] / 2
60
+ box_corner[:, :, 3] = prediction[:, :, 1] + prediction[:, :, 3] / 2
61
+ prediction[:, :, :4] = box_corner[:, :, :4]
62
+
63
+ output = [None for _ in range(len(prediction))]
64
+ for i, image_pred in enumerate(prediction):
65
+
66
+ # If none are remaining => process next image
67
+ if not image_pred.shape[0]:
68
+ continue
69
+ # Get score and class with highest confidence
70
+ class_conf = F.max(image_pred[:, 5: 5 + num_classes], 1, keepdims=True)
71
+ class_pred = F.argmax(image_pred[:, 5: 5 + num_classes], 1, keepdims=True)
72
+
73
+ class_conf_squeeze = F.squeeze(class_conf)
74
+ conf_mask = image_pred[:, 4] * class_conf_squeeze >= conf_thre
75
+ detections = F.concat((image_pred[:, :5], class_conf, class_pred), 1)
76
+ detections = detections[conf_mask]
77
+ if not detections.shape[0]:
78
+ continue
79
+
80
+ nms_out_index = F.vision.nms(
81
+ detections[:, :4], detections[:, 4] * detections[:, 5], nms_thre,
82
+ )
83
+ detections = detections[nms_out_index]
84
+ if output[i] is None:
85
+ output[i] = detections
86
+ else:
87
+ output[i] = F.concat((output[i], detections))
88
+
89
+ return output
90
+
91
+
92
  class Predictor(object):
93
  def __init__(
94
  self,
 
206
 
207
 
208
  def main(args):
 
209
  file_name = os.path.join("./yolox_outputs", args.name)
210
  os.makedirs(file_name, exist_ok=True)
211
 
demo/MegEngine/python/process.py DELETED
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding:utf-8 -*-
3
- # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
-
5
- import cv2
6
- import megengine.functional as F
7
- import numpy as np
8
-
9
- __all__ = [
10
- "preprocess",
11
- "postprocess",
12
- ]
13
-
14
-
15
- def preprocess(image, input_size, mean, std, swap=(2, 0, 1)):
16
- if len(image.shape) == 3:
17
- padded_img = np.ones((input_size[0], input_size[1], 3)) * 114.0
18
- else:
19
- padded_img = np.ones(input_size) * 114.0
20
- img = np.array(image)
21
- r = min(input_size[0] / img.shape[0], input_size[1] / img.shape[1])
22
- resized_img = cv2.resize(
23
- img,
24
- (int(img.shape[1] * r), int(img.shape[0] * r)),
25
- interpolation=cv2.INTER_LINEAR,
26
- ).astype(np.float32)
27
- padded_img[: int(img.shape[0] * r), : int(img.shape[1] * r)] = resized_img
28
- image = padded_img
29
-
30
- image = image.astype(np.float32)
31
- image = image[:, :, ::-1]
32
- image /= 255.0
33
- if mean is not None:
34
- image -= mean
35
- if std is not None:
36
- image /= std
37
- image = image.transpose(swap)
38
- image = np.ascontiguousarray(image, dtype=np.float32)
39
- return image, r
40
-
41
-
42
- def postprocess(prediction, num_classes, conf_thre=0.7, nms_thre=0.45):
43
- box_corner = F.zeros_like(prediction)
44
- box_corner[:, :, 0] = prediction[:, :, 0] - prediction[:, :, 2] / 2
45
- box_corner[:, :, 1] = prediction[:, :, 1] - prediction[:, :, 3] / 2
46
- box_corner[:, :, 2] = prediction[:, :, 0] + prediction[:, :, 2] / 2
47
- box_corner[:, :, 3] = prediction[:, :, 1] + prediction[:, :, 3] / 2
48
- prediction[:, :, :4] = box_corner[:, :, :4]
49
-
50
- output = [None for _ in range(len(prediction))]
51
- for i, image_pred in enumerate(prediction):
52
-
53
- # If none are remaining => process next image
54
- if not image_pred.shape[0]:
55
- continue
56
- # Get score and class with highest confidence
57
- class_conf = F.max(image_pred[:, 5 : 5 + num_classes], 1, keepdims=True)
58
- class_pred = F.argmax(image_pred[:, 5 : 5 + num_classes], 1, keepdims=True)
59
-
60
- class_conf_squeeze = F.squeeze(class_conf)
61
- conf_mask = image_pred[:, 4] * class_conf_squeeze >= conf_thre
62
- detections = F.concat((image_pred[:, :5], class_conf, class_pred), 1)
63
- detections = detections[conf_mask]
64
- if not detections.shape[0]:
65
- continue
66
-
67
- nms_out_index = F.vision.nms(
68
- detections[:, :4], detections[:, 4] * detections[:, 5], nms_thre,
69
- )
70
- detections = detections[nms_out_index]
71
- if output[i] is None:
72
- output[i] = detections
73
- else:
74
- output[i] = F.concat((output[i], detections))
75
-
76
- return output
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
demo/MegEngine/python/visualize.py DELETED
@@ -1,128 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding:utf-8 -*-
3
- # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
-
5
- import cv2
6
- import numpy as np
7
-
8
- __all__ = ["vis"]
9
-
10
-
11
- def vis(img, boxes, scores, cls_ids, conf=0.5, class_names=None):
12
-
13
- for i in range(len(boxes)):
14
- box = boxes[i]
15
- cls_id = int(cls_ids[i])
16
- score = scores[i]
17
- if score < conf:
18
- continue
19
- x0 = int(box[0])
20
- y0 = int(box[1])
21
- x1 = int(box[2])
22
- y1 = int(box[3])
23
-
24
- color = (_COLORS[cls_id] * 255).astype(np.uint8).tolist()
25
- text = '{}:{:.1f}%'.format(class_names[cls_id], score * 100)
26
- txt_color = (0, 0, 0) if np.mean(_COLORS[cls_id]) > 0.5 else (255, 255, 255)
27
- font = cv2.FONT_HERSHEY_SIMPLEX
28
-
29
- txt_size = cv2.getTextSize(text, font, 0.4, 1)[0]
30
- cv2.rectangle(img, (x0, y0), (x1, y1), color, 2)
31
-
32
- txt_bk_color = (_COLORS[cls_id] * 255 * 0.7).astype(np.uint8).tolist()
33
- cv2.rectangle(
34
- img,
35
- (x0, y0 + 1),
36
- (x0 + txt_size[0] + 1, y0 + int(1.5*txt_size[1])),
37
- txt_bk_color,
38
- -1
39
- )
40
- cv2.putText(img, text, (x0, y0 + txt_size[1]), font, 0.4, txt_color, thickness=1)
41
-
42
- return img
43
-
44
-
45
- _COLORS = np.array(
46
- [
47
- 0.000, 0.447, 0.741,
48
- 0.850, 0.325, 0.098,
49
- 0.929, 0.694, 0.125,
50
- 0.494, 0.184, 0.556,
51
- 0.466, 0.674, 0.188,
52
- 0.301, 0.745, 0.933,
53
- 0.635, 0.078, 0.184,
54
- 0.300, 0.300, 0.300,
55
- 0.600, 0.600, 0.600,
56
- 1.000, 0.000, 0.000,
57
- 1.000, 0.500, 0.000,
58
- 0.749, 0.749, 0.000,
59
- 0.000, 1.000, 0.000,
60
- 0.000, 0.000, 1.000,
61
- 0.667, 0.000, 1.000,
62
- 0.333, 0.333, 0.000,
63
- 0.333, 0.667, 0.000,
64
- 0.333, 1.000, 0.000,
65
- 0.667, 0.333, 0.000,
66
- 0.667, 0.667, 0.000,
67
- 0.667, 1.000, 0.000,
68
- 1.000, 0.333, 0.000,
69
- 1.000, 0.667, 0.000,
70
- 1.000, 1.000, 0.000,
71
- 0.000, 0.333, 0.500,
72
- 0.000, 0.667, 0.500,
73
- 0.000, 1.000, 0.500,
74
- 0.333, 0.000, 0.500,
75
- 0.333, 0.333, 0.500,
76
- 0.333, 0.667, 0.500,
77
- 0.333, 1.000, 0.500,
78
- 0.667, 0.000, 0.500,
79
- 0.667, 0.333, 0.500,
80
- 0.667, 0.667, 0.500,
81
- 0.667, 1.000, 0.500,
82
- 1.000, 0.000, 0.500,
83
- 1.000, 0.333, 0.500,
84
- 1.000, 0.667, 0.500,
85
- 1.000, 1.000, 0.500,
86
- 0.000, 0.333, 1.000,
87
- 0.000, 0.667, 1.000,
88
- 0.000, 1.000, 1.000,
89
- 0.333, 0.000, 1.000,
90
- 0.333, 0.333, 1.000,
91
- 0.333, 0.667, 1.000,
92
- 0.333, 1.000, 1.000,
93
- 0.667, 0.000, 1.000,
94
- 0.667, 0.333, 1.000,
95
- 0.667, 0.667, 1.000,
96
- 0.667, 1.000, 1.000,
97
- 1.000, 0.000, 1.000,
98
- 1.000, 0.333, 1.000,
99
- 1.000, 0.667, 1.000,
100
- 0.333, 0.000, 0.000,
101
- 0.500, 0.000, 0.000,
102
- 0.667, 0.000, 0.000,
103
- 0.833, 0.000, 0.000,
104
- 1.000, 0.000, 0.000,
105
- 0.000, 0.167, 0.000,
106
- 0.000, 0.333, 0.000,
107
- 0.000, 0.500, 0.000,
108
- 0.000, 0.667, 0.000,
109
- 0.000, 0.833, 0.000,
110
- 0.000, 1.000, 0.000,
111
- 0.000, 0.000, 0.167,
112
- 0.000, 0.000, 0.333,
113
- 0.000, 0.000, 0.500,
114
- 0.000, 0.000, 0.667,
115
- 0.000, 0.000, 0.833,
116
- 0.000, 0.000, 1.000,
117
- 0.000, 0.000, 0.000,
118
- 0.143, 0.143, 0.143,
119
- 0.286, 0.286, 0.286,
120
- 0.429, 0.429, 0.429,
121
- 0.571, 0.571, 0.571,
122
- 0.714, 0.714, 0.714,
123
- 0.857, 0.857, 0.857,
124
- 0.000, 0.447, 0.741,
125
- 0.314, 0.717, 0.741,
126
- 0.50, 0.5, 0
127
- ]
128
- ).astype(np.float32).reshape(-1, 3)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
exps/default/nano.py CHANGED
@@ -3,6 +3,7 @@
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
  import os
 
6
  import torch.nn as nn
7
 
8
  from yolox.exp import Exp as MyExp
 
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
  import os
6
+
7
  import torch.nn as nn
8
 
9
  from yolox.exp import Exp as MyExp
exps/default/yolov3.py CHANGED
@@ -3,6 +3,7 @@
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
  import os
 
6
  import torch
7
  import torch.nn as nn
8
 
 
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
  import os
6
+
7
  import torch
8
  import torch.nn as nn
9
 
exps/example/custom/nano.py CHANGED
@@ -3,6 +3,7 @@
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
  import os
 
6
  import torch.nn as nn
7
 
8
  from yolox.exp import Exp as MyExp
 
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
  import os
6
+
7
  import torch.nn as nn
8
 
9
  from yolox.exp import Exp as MyExp
exps/example/custom/yolox_s.py CHANGED
@@ -2,7 +2,6 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
  import os
5
- from pathlib import Path
6
 
7
  from yolox.exp import Exp as MyExp
8
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
  import os
 
5
 
6
  from yolox.exp import Exp as MyExp
7
 
exps/example/yolox_voc/yolox_voc_s.py CHANGED
@@ -1,12 +1,12 @@
1
  # encoding: utf-8
2
  import os
3
- import random
4
  import torch
5
- import torch.nn as nn
6
  import torch.distributed as dist
7
 
8
- from yolox.exp import Exp as MyExp
9
  from yolox.data import get_yolox_datadir
 
 
10
 
11
  class Exp(MyExp):
12
  def __init__(self):
 
1
  # encoding: utf-8
2
  import os
3
+
4
  import torch
 
5
  import torch.distributed as dist
6
 
 
7
  from yolox.data import get_yolox_datadir
8
+ from yolox.exp import Exp as MyExp
9
+
10
 
11
  class Exp(MyExp):
12
  def __init__(self):
setup.py CHANGED
@@ -9,7 +9,7 @@ import torch
9
  from torch.utils.cpp_extension import CppExtension
10
 
11
  torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
12
- assert torch_ver >= [1, 3], "Requires PyTorch >= 1.3"
13
 
14
 
15
  def get_extensions():
 
9
  from torch.utils.cpp_extension import CppExtension
10
 
11
  torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
12
+ assert torch_ver >= [1, 7], "Requires PyTorch >= 1.7"
13
 
14
 
15
  def get_extensions():
tools/demo.py CHANGED
@@ -2,6 +2,9 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  from loguru import logger
6
 
7
  import cv2
@@ -13,10 +16,6 @@ from yolox.data.datasets import COCO_CLASSES
13
  from yolox.exp import get_exp
14
  from yolox.utils import fuse_model, get_model_info, postprocess, vis
15
 
16
- import argparse
17
- import os
18
- import time
19
-
20
  IMAGE_EXT = [".jpg", ".jpeg", ".webp", ".bmp", ".png"]
21
 
22
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import argparse
6
+ import os
7
+ import time
8
  from loguru import logger
9
 
10
  import cv2
 
16
  from yolox.exp import get_exp
17
  from yolox.utils import fuse_model, get_model_info, postprocess, vis
18
 
 
 
 
 
19
  IMAGE_EXT = [".jpg", ".jpeg", ".webp", ".bmp", ".png"]
20
 
21
 
tools/eval.py CHANGED
@@ -2,6 +2,10 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
 
5
  from loguru import logger
6
 
7
  import torch
@@ -10,12 +14,7 @@ from torch.nn.parallel import DistributedDataParallel as DDP
10
 
11
  from yolox.core import launch
12
  from yolox.exp import get_exp
13
- from yolox.utils import configure_nccl, fuse_model, get_local_rank, get_model_info, setup_logger
14
-
15
- import argparse
16
- import os
17
- import random
18
- import warnings
19
 
20
 
21
  def make_parser():
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import argparse
6
+ import os
7
+ import random
8
+ import warnings
9
  from loguru import logger
10
 
11
  import torch
 
14
 
15
  from yolox.core import launch
16
  from yolox.exp import get_exp
17
+ from yolox.utils import fuse_model, get_model_info, setup_logger
 
 
 
 
 
18
 
19
 
20
  def make_parser():
tools/export_onnx.py CHANGED
@@ -2,6 +2,8 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
5
  from loguru import logger
6
 
7
  import torch
@@ -11,9 +13,6 @@ from yolox.exp import get_exp
11
  from yolox.models.network_blocks import SiLU
12
  from yolox.utils import replace_module
13
 
14
- import argparse
15
- import os
16
-
17
 
18
  def make_parser():
19
  parser = argparse.ArgumentParser("YOLOX onnx deploy")
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import argparse
6
+ import os
7
  from loguru import logger
8
 
9
  import torch
 
13
  from yolox.models.network_blocks import SiLU
14
  from yolox.utils import replace_module
15
 
 
 
 
16
 
17
  def make_parser():
18
  parser = argparse.ArgumentParser("YOLOX onnx deploy")
tools/train.py CHANGED
@@ -2,6 +2,9 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  from loguru import logger
6
 
7
  import torch
@@ -10,10 +13,6 @@ import torch.backends.cudnn as cudnn
10
  from yolox.core import Trainer, launch
11
  from yolox.exp import get_exp
12
 
13
- import argparse
14
- import random
15
- import warnings
16
-
17
 
18
  def make_parser():
19
  parser = argparse.ArgumentParser("YOLOX train parser")
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import argparse
6
+ import random
7
+ import warnings
8
  from loguru import logger
9
 
10
  import torch
 
13
  from yolox.core import Trainer, launch
14
  from yolox.exp import get_exp
15
 
 
 
 
 
16
 
17
  def make_parser():
18
  parser = argparse.ArgumentParser("YOLOX train parser")
tools/trt.py CHANGED
@@ -2,6 +2,9 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  from loguru import logger
6
 
7
  import tensorrt as trt
@@ -10,10 +13,6 @@ from torch2trt import torch2trt
10
 
11
  from yolox.exp import get_exp
12
 
13
- import argparse
14
- import os
15
- import shutil
16
-
17
 
18
  def make_parser():
19
  parser = argparse.ArgumentParser("YOLOX ncnn deploy")
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import argparse
6
+ import os
7
+ import shutil
8
  from loguru import logger
9
 
10
  import tensorrt as trt
 
13
 
14
  from yolox.exp import get_exp
15
 
 
 
 
 
16
 
17
  def make_parser():
18
  parser = argparse.ArgumentParser("YOLOX ncnn deploy")
yolox/core/launch.py CHANGED
@@ -5,19 +5,20 @@
5
  # Copyright (c) Facebook, Inc. and its affiliates.
6
  # Copyright (c) Megvii, Inc. and its affiliates.
7
 
 
 
 
 
8
  from loguru import logger
9
 
10
  import torch
11
  import torch.distributed as dist
12
- import torch.multiprocessing as mp
13
 
14
  import yolox.utils.dist as comm
15
  from yolox.utils import configure_nccl
16
 
17
- import os
18
- import subprocess
19
- import sys
20
- import time
21
 
22
  __all__ = ["launch"]
23
 
 
5
  # Copyright (c) Facebook, Inc. and its affiliates.
6
  # Copyright (c) Megvii, Inc. and its affiliates.
7
 
8
+ import os
9
+ import subprocess
10
+ import sys
11
+ import time
12
  from loguru import logger
13
 
14
  import torch
15
  import torch.distributed as dist
 
16
 
17
  import yolox.utils.dist as comm
18
  from yolox.utils import configure_nccl
19
 
20
+ # import torch.multiprocessing as mp
21
+
 
 
22
 
23
  __all__ = ["launch"]
24
 
yolox/core/trainer.py CHANGED
@@ -2,6 +2,9 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  from loguru import logger
6
 
7
  import apex
@@ -25,10 +28,6 @@ from yolox.utils import (
25
  synchronize
26
  )
27
 
28
- import datetime
29
- import os
30
- import time
31
-
32
 
33
  class Trainer:
34
  def __init__(self, exp, args):
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import datetime
6
+ import os
7
+ import time
8
  from loguru import logger
9
 
10
  import apex
 
28
  synchronize
29
  )
30
 
 
 
 
 
31
 
32
  class Trainer:
33
  def __init__(self, exp, args):
yolox/data/data_augment.py CHANGED
@@ -9,16 +9,14 @@ The data augmentation procedures were interpreted from @weiliu89's SSD paper
9
  http://arxiv.org/abs/1512.02325
10
  """
11
 
 
 
 
12
  import cv2
13
  import numpy as np
14
 
15
- import torch
16
-
17
  from yolox.utils import xyxy2cxcywh
18
 
19
- import math
20
- import random
21
-
22
 
23
  def augment_hsv(img, hgain=0.015, sgain=0.7, vgain=0.4):
24
  r = np.random.uniform(-1, 1, 3) * [hgain, sgain, vgain] + 1 # random gains
 
9
  http://arxiv.org/abs/1512.02325
10
  """
11
 
12
+ import math
13
+ import random
14
+
15
  import cv2
16
  import numpy as np
17
 
 
 
18
  from yolox.utils import xyxy2cxcywh
19
 
 
 
 
20
 
21
  def augment_hsv(img, hgain=0.015, sgain=0.7, vgain=0.4):
22
  r = np.random.uniform(-1, 1, 3) * [hgain, sgain, vgain] + 1 # random gains
yolox/data/data_prefetcher.py CHANGED
@@ -2,13 +2,13 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
5
  import torch
6
  import torch.distributed as dist
7
 
8
  from yolox.utils import synchronize
9
 
10
- import random
11
-
12
 
13
  class DataPrefetcher:
14
  """
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import random
6
+
7
  import torch
8
  import torch.distributed as dist
9
 
10
  from yolox.utils import synchronize
11
 
 
 
12
 
13
  class DataPrefetcher:
14
  """
yolox/data/dataloading.py CHANGED
@@ -2,13 +2,13 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  import torch
6
  from torch.utils.data.dataloader import DataLoader as torchDataLoader
7
  from torch.utils.data.dataloader import default_collate
8
 
9
- import os
10
- import random
11
-
12
  from .samplers import YoloBatchSampler
13
 
14
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import os
6
+ import random
7
+
8
  import torch
9
  from torch.utils.data.dataloader import DataLoader as torchDataLoader
10
  from torch.utils.data.dataloader import default_collate
11
 
 
 
 
12
  from .samplers import YoloBatchSampler
13
 
14
 
yolox/data/datasets/coco.py CHANGED
@@ -2,12 +2,12 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
5
  import cv2
6
  import numpy as np
7
  from pycocotools.coco import COCO
8
 
9
- import os
10
-
11
  from ..dataloading import get_yolox_datadir
12
  from .datasets_wrapper import Dataset
13
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import os
6
+
7
  import cv2
8
  import numpy as np
9
  from pycocotools.coco import COCO
10
 
 
 
11
  from ..dataloading import get_yolox_datadir
12
  from .datasets_wrapper import Dataset
13
 
yolox/data/datasets/datasets_wrapper.py CHANGED
@@ -2,12 +2,12 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
- from torch.utils.data.dataset import ConcatDataset as torchConcatDataset
6
- from torch.utils.data.dataset import Dataset as torchDataset
7
-
8
  import bisect
9
  from functools import wraps
10
 
 
 
 
11
 
12
  class ConcatDataset(torchConcatDataset):
13
  def __init__(self, datasets):
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  import bisect
6
  from functools import wraps
7
 
8
+ from torch.utils.data.dataset import ConcatDataset as torchConcatDataset
9
+ from torch.utils.data.dataset import Dataset as torchDataset
10
+
11
 
12
  class ConcatDataset(torchConcatDataset):
13
  def __init__(self, datasets):
yolox/data/datasets/mosaicdetection.py CHANGED
@@ -2,13 +2,13 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
5
  import cv2
6
  import numpy as np
7
 
8
  from yolox.utils import adjust_box_anns
9
 
10
- import random
11
-
12
  from ..data_augment import box_candidates, random_perspective
13
  from .datasets_wrapper import Dataset
14
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import random
6
+
7
  import cv2
8
  import numpy as np
9
 
10
  from yolox.utils import adjust_box_anns
11
 
 
 
12
  from ..data_augment import box_candidates, random_perspective
13
  from .datasets_wrapper import Dataset
14
 
yolox/data/datasets/voc.py CHANGED
@@ -6,16 +6,16 @@
6
  # Copyright (c) Ellis Brown, Max deGroot.
7
  # Copyright (c) Megvii, Inc. and its affiliates.
8
 
9
- import cv2
10
- import numpy as np
11
-
12
- from yolox.evaluators.voc_eval import voc_eval
13
-
14
  import os
15
  import os.path
16
  import pickle
17
  import xml.etree.ElementTree as ET
18
 
 
 
 
 
 
19
  from .datasets_wrapper import Dataset
20
  from .voc_classes import VOC_CLASSES
21
 
 
6
  # Copyright (c) Ellis Brown, Max deGroot.
7
  # Copyright (c) Megvii, Inc. and its affiliates.
8
 
 
 
 
 
 
9
  import os
10
  import os.path
11
  import pickle
12
  import xml.etree.ElementTree as ET
13
 
14
+ import cv2
15
+ import numpy as np
16
+
17
+ from yolox.evaluators.voc_eval import voc_eval
18
+
19
  from .datasets_wrapper import Dataset
20
  from .voc_classes import VOC_CLASSES
21
 
yolox/data/samplers.py CHANGED
@@ -2,14 +2,14 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
5
  import torch
6
  import torch.distributed as dist
7
  from torch.utils.data.sampler import BatchSampler as torchBatchSampler
8
  from torch.utils.data.sampler import Sampler
9
 
10
- import itertools
11
- from typing import Optional
12
-
13
 
14
  class YoloBatchSampler(torchBatchSampler):
15
  """
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import itertools
6
+ from typing import Optional
7
+
8
  import torch
9
  import torch.distributed as dist
10
  from torch.utils.data.sampler import BatchSampler as torchBatchSampler
11
  from torch.utils.data.sampler import Sampler
12
 
 
 
 
13
 
14
  class YoloBatchSampler(torchBatchSampler):
15
  """
yolox/evaluators/coco_evaluator.py CHANGED
@@ -2,6 +2,12 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
 
 
 
5
  from loguru import logger
6
  from tqdm import tqdm
7
 
@@ -16,13 +22,6 @@ from yolox.utils import (
16
  xyxy2xywh
17
  )
18
 
19
- import contextlib
20
- import io
21
- import itertools
22
- import json
23
- import tempfile
24
- import time
25
-
26
 
27
  class COCOEvaluator:
28
  """
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import contextlib
6
+ import io
7
+ import itertools
8
+ import json
9
+ import tempfile
10
+ import time
11
  from loguru import logger
12
  from tqdm import tqdm
13
 
 
22
  xyxy2xywh
23
  )
24
 
 
 
 
 
 
 
 
25
 
26
  class COCOEvaluator:
27
  """
yolox/evaluators/voc_eval.py CHANGED
@@ -5,12 +5,12 @@
5
  # Copyright (c) Bharath Hariharan.
6
  # Copyright (c) Megvii, Inc. and its affiliates.
7
 
8
- import numpy as np
9
-
10
  import os
11
  import pickle
12
  import xml.etree.ElementTree as ET
13
 
 
 
14
 
15
  def parse_rec(filename):
16
  """ Parse a PASCAL VOC xml file """
 
5
  # Copyright (c) Bharath Hariharan.
6
  # Copyright (c) Megvii, Inc. and its affiliates.
7
 
 
 
8
  import os
9
  import pickle
10
  import xml.etree.ElementTree as ET
11
 
12
+ import numpy as np
13
+
14
 
15
  def parse_rec(filename):
16
  """ Parse a PASCAL VOC xml file """
yolox/evaluators/voc_evaluator.py CHANGED
@@ -2,6 +2,10 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
 
 
 
 
5
  from loguru import logger
6
  from tqdm import tqdm
7
 
@@ -11,11 +15,6 @@ import torch
11
 
12
  from yolox.utils import gather, is_main_process, postprocess, synchronize, time_synchronized
13
 
14
- import sys
15
- import tempfile
16
- import time
17
- from collections import ChainMap
18
-
19
 
20
  class VOCEvaluator:
21
  """
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) Megvii, Inc. and its affiliates.
4
 
5
+ import sys
6
+ import tempfile
7
+ import time
8
+ from collections import ChainMap
9
  from loguru import logger
10
  from tqdm import tqdm
11
 
 
15
 
16
  from yolox.utils import gather, is_main_process, postprocess, synchronize, time_synchronized
17
 
 
 
 
 
 
18
 
19
  class VOCEvaluator:
20
  """
yolox/exp/base_exp.py CHANGED
@@ -2,16 +2,16 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
- import torch
6
- from torch.nn import Module
7
-
8
- from yolox.utils import LRScheduler
9
-
10
  import ast
11
  import pprint
12
  from abc import ABCMeta, abstractmethod
13
- from tabulate import tabulate
14
  from typing import Dict
 
 
 
 
 
 
15
 
16
 
17
  class BaseExp(metaclass=ABCMeta):
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
 
 
 
 
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
12
+ from torch.nn import Module
13
+
14
+ from yolox.utils import LRScheduler
15
 
16
 
17
  class BaseExp(metaclass=ABCMeta):
yolox/layers/fast_coco_eval_api.py CHANGED
@@ -5,6 +5,9 @@
5
  # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
6
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
7
 
 
 
 
8
  import numpy as np
9
  from pycocotools.cocoeval import COCOeval
10
 
@@ -12,9 +15,6 @@ from pycocotools.cocoeval import COCOeval
12
  # in YOLOX, env is already set in __init__.py.
13
  from yolox import _C
14
 
15
- import copy
16
- import time
17
-
18
 
19
  class COCOeval_opt(COCOeval):
20
  """
 
5
  # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
6
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
7
 
8
+ import copy
9
+ import time
10
+
11
  import numpy as np
12
  from pycocotools.cocoeval import COCOeval
13
 
 
15
  # in YOLOX, env is already set in __init__.py.
16
  from yolox import _C
17
 
 
 
 
18
 
19
  class COCOeval_opt(COCOeval):
20
  """
yolox/models/yolo_head.py CHANGED
@@ -2,6 +2,7 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
5
  from loguru import logger
6
 
7
  import torch
@@ -10,8 +11,6 @@ import torch.nn.functional as F
10
 
11
  from yolox.utils import bboxes_iou
12
 
13
- import math
14
-
15
  from .losses import IOUloss
16
  from .network_blocks import BaseConv, DWConv
17
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
+ import math
6
  from loguru import logger
7
 
8
  import torch
 
11
 
12
  from yolox.utils import bboxes_iou
13
 
 
 
14
  from .losses import IOUloss
15
  from .network_blocks import BaseConv, DWConv
16
 
yolox/utils/allreduce_norm.py CHANGED
@@ -2,13 +2,13 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
 
 
5
  import torch
6
  from torch import distributed as dist
7
  from torch import nn
8
 
9
- import pickle
10
- from collections import OrderedDict
11
-
12
  from .dist import _get_global_gloo_group, get_world_size
13
 
14
  ASYNC_NORM = (
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
+ import pickle
6
+ from collections import OrderedDict
7
+
8
  import torch
9
  from torch import distributed as dist
10
  from torch import nn
11
 
 
 
 
12
  from .dist import _get_global_gloo_group, get_world_size
13
 
14
  ASYNC_NORM = (
yolox/utils/boxes.py CHANGED
@@ -44,12 +44,9 @@ def postprocess(prediction, num_classes, conf_thre=0.7, nms_thre=0.45):
44
  if not image_pred.size(0):
45
  continue
46
  # Get score and class with highest confidence
47
- class_conf, class_pred = torch.max(
48
- image_pred[:, 5 : 5 + num_classes], 1, keepdim=True
49
- )
50
 
51
  conf_mask = (image_pred[:, 4] * class_conf.squeeze() >= conf_thre).squeeze()
52
- # _, conf_mask = torch.topk((image_pred[:, 4] * class_conf.squeeze()), 1000)
53
  # Detections ordered as (x1, y1, x2, y2, obj_conf, class_conf, class_pred)
54
  detections = torch.cat((image_pred[:, :5], class_conf, class_pred.float()), 1)
55
  detections = detections[conf_mask]
 
44
  if not image_pred.size(0):
45
  continue
46
  # Get score and class with highest confidence
47
+ class_conf, class_pred = torch.max(image_pred[:, 5: 5 + num_classes], 1, keepdim=True)
 
 
48
 
49
  conf_mask = (image_pred[:, 4] * class_conf.squeeze() >= conf_thre).squeeze()
 
50
  # Detections ordered as (x1, y1, x2, y2, obj_conf, class_conf, class_pred)
51
  detections = torch.cat((image_pred[:, :5], class_conf, class_pred.float()), 1)
52
  detections = detections[conf_mask]
yolox/utils/checkpoint.py CHANGED
@@ -1,13 +1,12 @@
1
  #!/usr/bin/env python3
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
 
 
4
  from loguru import logger
5
 
6
  import torch
7
 
8
- import os
9
- import shutil
10
-
11
 
12
  def load_ckpt(model, ckpt):
13
  model_state_dict = model.state_dict()
 
1
  #!/usr/bin/env python3
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
+ import os
5
+ import shutil
6
  from loguru import logger
7
 
8
  import torch
9
 
 
 
 
10
 
11
  def load_ckpt(model, ckpt):
12
  model_state_dict = model.state_dict()
yolox/utils/demo_utils.py CHANGED
@@ -2,10 +2,10 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
- import numpy as np
6
-
7
  import os
8
 
 
 
9
  __all__ = ["mkdir", "nms", "multiclass_nms", "demo_postprocess"]
10
 
11
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
 
5
  import os
6
 
7
+ import numpy as np
8
+
9
  __all__ = ["mkdir", "nms", "multiclass_nms", "demo_postprocess"]
10
 
11
 
yolox/utils/dist.py CHANGED
@@ -9,16 +9,16 @@ This file contains primitives for multi-gpu communication.
9
  This is useful when doing distributed training.
10
  """
11
 
12
- import numpy as np
13
-
14
- import torch
15
- from torch import distributed as dist
16
-
17
  import functools
18
  import logging
19
  import pickle
20
  import time
21
 
 
 
 
 
 
22
  __all__ = [
23
  "is_main_process",
24
  "synchronize",
 
9
  This is useful when doing distributed training.
10
  """
11
 
 
 
 
 
 
12
  import functools
13
  import logging
14
  import pickle
15
  import time
16
 
17
+ import numpy as np
18
+
19
+ import torch
20
+ from torch import distributed as dist
21
+
22
  __all__ = [
23
  "is_main_process",
24
  "synchronize",
yolox/utils/ema.py CHANGED
@@ -1,12 +1,12 @@
1
  #!/usr/bin/env python3
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
- import torch
5
- import torch.nn as nn
6
-
7
  import math
8
  from copy import deepcopy
9
 
 
 
 
10
 
11
  def is_parallel(model):
12
  """check if model is in parallel mode."""
 
1
  #!/usr/bin/env python3
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
 
 
 
4
  import math
5
  from copy import deepcopy
6
 
7
+ import torch
8
+ import torch.nn as nn
9
+
10
 
11
  def is_parallel(model):
12
  """check if model is in parallel mode."""
yolox/utils/logger.py CHANGED
@@ -2,11 +2,10 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
- from loguru import logger
6
-
7
  import inspect
8
  import os
9
  import sys
 
10
 
11
 
12
  def get_caller_name(depth=0):
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
 
5
  import inspect
6
  import os
7
  import sys
8
+ from loguru import logger
9
 
10
 
11
  def get_caller_name(depth=0):
yolox/utils/metric.py CHANGED
@@ -1,15 +1,15 @@
1
  #!/usr/bin/env python3
2
  # -*- coding: utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
- import numpy as np
5
-
6
- import torch
7
-
8
  import functools
9
  import os
10
  import time
11
  from collections import defaultdict, deque
12
 
 
 
 
 
13
  __all__ = [
14
  "AverageMeter",
15
  "MeterBuffer",
 
1
  #!/usr/bin/env python3
2
  # -*- coding: utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
 
 
 
 
4
  import functools
5
  import os
6
  import time
7
  from collections import defaultdict, deque
8
 
9
+ import numpy as np
10
+
11
+ import torch
12
+
13
  __all__ = [
14
  "AverageMeter",
15
  "MeterBuffer",
yolox/utils/model_utils.py CHANGED
@@ -2,12 +2,12 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
 
5
  import torch
6
  import torch.nn as nn
7
  from thop import profile
8
 
9
- from copy import deepcopy
10
-
11
  __all__ = [
12
  "fuse_conv_and_bn",
13
  "fuse_model",
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
+ from copy import deepcopy
6
+
7
  import torch
8
  import torch.nn as nn
9
  from thop import profile
10
 
 
 
11
  __all__ = [
12
  "fuse_conv_and_bn",
13
  "fuse_model",
yolox/utils/setup_env.py CHANGED
@@ -2,11 +2,11 @@
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
5
- import cv2
6
-
7
  import os
8
  import subprocess
9
 
 
 
10
  __all__ = ["configure_nccl", "configure_module"]
11
 
12
 
 
2
  # -*- coding:utf-8 -*-
3
  # Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
4
 
 
 
5
  import os
6
  import subprocess
7
 
8
+ import cv2
9
+
10
  __all__ = ["configure_nccl", "configure_module"]
11
 
12