Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
Models
提交
0023ce55
M
Models
项目概览
MegEngine 天元
/
Models
通知
6
Star
3
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0023ce55
编写于
7月 07, 2020
作者:
W
Wang Feng
提交者:
GitHub
7月 07, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(detection): support time and isort (#42)
上级
848ebfa2
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
50 addition
and
17 deletion
+50
-17
.isort.cfg
.isort.cfg
+13
-0
official/vision/detection/layers/basic/functional.py
official/vision/detection/layers/basic/functional.py
+2
-2
official/vision/detection/layers/basic/norm.py
official/vision/detection/layers/basic/norm.py
+1
-1
official/vision/detection/layers/det/anchor.py
official/vision/detection/layers/det/anchor.py
+2
-2
official/vision/detection/layers/det/box_utils.py
official/vision/detection/layers/det/box_utils.py
+0
-1
official/vision/detection/layers/det/loss.py
official/vision/detection/layers/det/loss.py
+0
-1
official/vision/detection/layers/det/pooler.py
official/vision/detection/layers/det/pooler.py
+1
-0
official/vision/detection/layers/det/retinanet.py
official/vision/detection/layers/det/retinanet.py
+0
-1
official/vision/detection/layers/det/rpn.py
official/vision/detection/layers/det/rpn.py
+2
-1
official/vision/detection/models/faster_rcnn_fpn.py
official/vision/detection/models/faster_rcnn_fpn.py
+1
-0
official/vision/detection/models/retinanet.py
official/vision/detection/models/retinanet.py
+2
-1
official/vision/detection/tools/gpu_nms.py
official/vision/detection/tools/gpu_nms.py
+1
-0
official/vision/detection/tools/inference.py
official/vision/detection/tools/inference.py
+2
-1
official/vision/detection/tools/test.py
official/vision/detection/tools/test.py
+3
-2
official/vision/detection/tools/train.py
official/vision/detection/tools/train.py
+20
-4
未找到文件。
.isort.cfg
0 → 100644
浏览文件 @
0023ce55
[isort]
line_length = 100
multi_line_output = 3
balanced_wrapping = True
# skip = tools/test_net.py, tools/train_net.py
known_standard_library = setuptools
known_myself = official
known_data_processing = cv2,numpy,scipy,PIL,matplotlib
known_datasets = pycocotools
known_deeplearning = megengine
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,data_processing,datasets,deeplearning,myself,LOCALFOLDER
no_lines_before=STDLIB,THIRDPARTY,datasets
default_section = FIRSTPARTY
official/vision/detection/layers/basic/functional.py
浏览文件 @
0023ce55
...
@@ -6,10 +6,10 @@
...
@@ -6,10 +6,10 @@
# Unless required by applicable law or agreed to in writing,
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
megengine
as
mge
import
megengine.functional
as
F
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
import
megengine.functional
as
F
from
megengine.core
import
Tensor
from
megengine.core
import
Tensor
...
...
official/vision/detection/layers/basic/norm.py
浏览文件 @
0023ce55
...
@@ -24,9 +24,9 @@
...
@@ -24,9 +24,9 @@
# This file has been modified by Megvii ("Megvii Modifications").
# This file has been modified by Megvii ("Megvii Modifications").
# All Megvii Modifications are Copyright (C) 2014-2020 Megvii Inc. All rights reserved.
# All Megvii Modifications are Copyright (C) 2014-2020 Megvii Inc. All rights reserved.
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------
import
megengine.module
as
M
import
numpy
as
np
import
numpy
as
np
import
megengine.module
as
M
from
megengine.core
import
Buffer
from
megengine.core
import
Buffer
...
...
official/vision/detection/layers/det/anchor.py
浏览文件 @
0023ce55
...
@@ -8,10 +8,10 @@
...
@@ -8,10 +8,10 @@
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
from
abc
import
ABCMeta
,
abstractmethod
from
abc
import
ABCMeta
,
abstractmethod
import
megengine.functional
as
F
import
numpy
as
np
import
numpy
as
np
from
megengine.core
import
tensor
,
Tensor
import
megengine.functional
as
F
from
megengine.core
import
Tensor
,
tensor
class
BaseAnchorGenerator
(
metaclass
=
ABCMeta
):
class
BaseAnchorGenerator
(
metaclass
=
ABCMeta
):
...
...
official/vision/detection/layers/det/box_utils.py
浏览文件 @
0023ce55
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
from
abc
import
ABCMeta
,
abstractmethod
from
abc
import
ABCMeta
,
abstractmethod
import
megengine.functional
as
F
import
megengine.functional
as
F
from
megengine.core
import
Tensor
from
megengine.core
import
Tensor
...
...
official/vision/detection/layers/det/loss.py
浏览文件 @
0023ce55
...
@@ -7,7 +7,6 @@
...
@@ -7,7 +7,6 @@
# software distributed under the License is distributed on an
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
megengine.functional
as
F
import
megengine.functional
as
F
from
megengine.core
import
Tensor
from
megengine.core
import
Tensor
...
...
official/vision/detection/layers/det/pooler.py
浏览文件 @
0023ce55
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
import
math
import
math
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
import
megengine
as
mge
import
megengine.functional
as
F
import
megengine.functional
as
F
...
...
official/vision/detection/layers/det/retinanet.py
浏览文件 @
0023ce55
...
@@ -10,7 +10,6 @@ import math
...
@@ -10,7 +10,6 @@ import math
from
typing
import
List
from
typing
import
List
import
megengine.module
as
M
import
megengine.module
as
M
from
megengine.core
import
Tensor
from
megengine.core
import
Tensor
from
official.vision.detection.layers
import
basic
from
official.vision.detection.layers
import
basic
...
...
official/vision/detection/layers/det/rpn.py
浏览文件 @
0023ce55
...
@@ -7,9 +7,10 @@
...
@@ -7,9 +7,10 @@
# software distributed under the License is distributed on an
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
megengine
as
mge
import
megengine
as
mge
import
megengine.random
as
rand
import
megengine.functional
as
F
import
megengine.functional
as
F
import
megengine.module
as
M
import
megengine.module
as
M
import
megengine.random
as
rand
from
official.vision.detection
import
layers
from
official.vision.detection
import
layers
from
official.vision.detection.tools.gpu_nms
import
batched_nms
from
official.vision.detection.tools.gpu_nms
import
batched_nms
...
...
official/vision/detection/models/faster_rcnn_fpn.py
浏览文件 @
0023ce55
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
# software distributed under the License is distributed on an
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
import
megengine
as
mge
import
megengine.functional
as
F
import
megengine.functional
as
F
import
megengine.module
as
M
import
megengine.module
as
M
...
...
official/vision/detection/models/retinanet.py
浏览文件 @
0023ce55
...
@@ -6,10 +6,11 @@
...
@@ -6,10 +6,11 @@
# Unless required by applicable law or agreed to in writing,
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
numpy
as
np
import
megengine
as
mge
import
megengine
as
mge
import
megengine.functional
as
F
import
megengine.functional
as
F
import
megengine.module
as
M
import
megengine.module
as
M
import
numpy
as
np
from
official.vision.classification.resnet.model
import
resnet50
from
official.vision.classification.resnet.model
import
resnet50
from
official.vision.detection
import
layers
from
official.vision.detection
import
layers
...
...
official/vision/detection/tools/gpu_nms.py
浏览文件 @
0023ce55
...
@@ -5,6 +5,7 @@ import os
...
@@ -5,6 +5,7 @@ import os
import
struct
import
struct
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
import
megengine
as
mge
import
megengine.functional
as
F
import
megengine.functional
as
F
from
megengine._internal.craniotome
import
CraniotomeBase
from
megengine._internal.craniotome
import
CraniotomeBase
...
...
official/vision/detection/tools/inference.py
浏览文件 @
0023ce55
...
@@ -12,8 +12,9 @@ import os
...
@@ -12,8 +12,9 @@ import os
import
sys
import
sys
import
cv2
import
cv2
import
megengine
as
mge
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
from
megengine
import
jit
from
megengine
import
jit
from
megengine.data.dataset
import
COCO
from
megengine.data.dataset
import
COCO
...
...
official/vision/detection/tools/test.py
浏览文件 @
0023ce55
...
@@ -13,13 +13,14 @@ import os
...
@@ -13,13 +13,14 @@ import os
import
random
import
random
import
sys
import
sys
from
multiprocessing
import
Process
,
Queue
from
multiprocessing
import
Process
,
Queue
from
tqdm
import
tqdm
import
cv2
import
cv2
import
megengine
as
mge
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
from
megengine
import
jit
from
megengine
import
jit
from
megengine.data
import
DataLoader
,
SequentialSampler
from
megengine.data
import
DataLoader
,
SequentialSampler
from
tqdm
import
tqdm
from
official.vision.detection.tools.data_mapper
import
data_mapper
from
official.vision.detection.tools.data_mapper
import
data_mapper
from
official.vision.detection.tools.nms
import
py_cpu_nms
from
official.vision.detection.tools.nms
import
py_cpu_nms
...
...
official/vision/detection/tools/train.py
浏览文件 @
0023ce55
...
@@ -14,16 +14,18 @@ import importlib
...
@@ -14,16 +14,18 @@ import importlib
import
multiprocessing
as
mp
import
multiprocessing
as
mp
import
os
import
os
import
sys
import
sys
import
time
from
collections
import
defaultdict
from
collections
import
defaultdict
from
tabulate
import
tabulate
import
megengine
as
mge
import
numpy
as
np
import
numpy
as
np
import
megengine
as
mge
from
megengine
import
distributed
as
dist
from
megengine
import
distributed
as
dist
from
megengine
import
jit
from
megengine
import
jit
from
megengine
import
optimizer
as
optim
from
megengine
import
optimizer
as
optim
from
megengine.data
import
Collator
,
DataLoader
,
Infinite
,
RandomSampler
from
megengine.data
import
Collator
,
DataLoader
,
Infinite
,
RandomSampler
from
megengine.data
import
transform
as
T
from
megengine.data
import
transform
as
T
from
tabulate
import
tabulate
from
official.vision.detection.tools.data_mapper
import
data_mapper
from
official.vision.detection.tools.data_mapper
import
data_mapper
...
@@ -81,7 +83,8 @@ def worker(rank, world_size, args):
...
@@ -81,7 +83,8 @@ def worker(rank, world_size, args):
weights
=
mge
.
load
(
args
.
weight_file
)
weights
=
mge
.
load
(
args
.
weight_file
)
model
.
backbone
.
bottom_up
.
load_state_dict
(
weights
)
model
.
backbone
.
bottom_up
.
load_state_dict
(
weights
)
logger
.
info
(
"Prepare dataset"
)
if
rank
==
0
:
logger
.
info
(
"Prepare dataset"
)
loader
=
build_dataloader
(
model
.
batch_size
,
args
.
dataset_dir
,
model
.
cfg
)
loader
=
build_dataloader
(
model
.
batch_size
,
args
.
dataset_dir
,
model
.
cfg
)
train_loader
=
iter
(
loader
[
"train"
])
train_loader
=
iter
(
loader
[
"train"
])
...
@@ -155,21 +158,32 @@ def train_one_epoch(
...
@@ -155,21 +158,32 @@ def train_one_epoch(
return
losses
return
losses
meter
=
AverageMeter
(
record_len
=
model
.
cfg
.
num_losses
)
meter
=
AverageMeter
(
record_len
=
model
.
cfg
.
num_losses
)
time_meter
=
AverageMeter
(
record_len
=
2
)
log_interval
=
model
.
cfg
.
log_interval
log_interval
=
model
.
cfg
.
log_interval
for
step
in
range
(
tot_steps
):
for
step
in
range
(
tot_steps
):
adjust_learning_rate
(
opt
,
epoch_id
,
step
,
model
,
world_size
)
adjust_learning_rate
(
opt
,
epoch_id
,
step
,
model
,
world_size
)
data_tik
=
time
.
time
()
mini_batch
=
next
(
data_queue
)
mini_batch
=
next
(
data_queue
)
data_tok
=
time
.
time
()
model
.
inputs
[
"image"
].
set_value
(
mini_batch
[
"data"
])
model
.
inputs
[
"image"
].
set_value
(
mini_batch
[
"data"
])
model
.
inputs
[
"gt_boxes"
].
set_value
(
mini_batch
[
"gt_boxes"
])
model
.
inputs
[
"gt_boxes"
].
set_value
(
mini_batch
[
"gt_boxes"
])
model
.
inputs
[
"im_info"
].
set_value
(
mini_batch
[
"im_info"
])
model
.
inputs
[
"im_info"
].
set_value
(
mini_batch
[
"im_info"
])
tik
=
time
.
time
()
opt
.
zero_grad
()
opt
.
zero_grad
()
loss_list
=
propagate
()
loss_list
=
propagate
()
opt
.
step
()
opt
.
step
()
tok
=
time
.
time
()
time_meter
.
update
([
tok
-
tik
,
data_tok
-
data_tik
])
if
rank
==
0
:
if
rank
==
0
:
info_str
=
"e%d, %d/%d, lr:%f, "
loss_str
=
", "
.
join
([
"{}:%f"
.
format
(
loss
)
for
loss
in
model
.
cfg
.
losses_keys
])
loss_str
=
", "
.
join
([
"{}:%f"
.
format
(
loss
)
for
loss
in
model
.
cfg
.
losses_keys
])
log_info_str
=
"e%d, %d/%d, lr:%f, "
+
loss_str
time_str
=
", train_time:%.3fs, data_time:%.3fs"
log_info_str
=
info_str
+
loss_str
+
time_str
meter
.
update
([
loss
.
numpy
()
for
loss
in
loss_list
])
meter
.
update
([
loss
.
numpy
()
for
loss
in
loss_list
])
if
step
%
log_interval
==
0
:
if
step
%
log_interval
==
0
:
average_loss
=
meter
.
average
()
average_loss
=
meter
.
average
()
...
@@ -180,8 +194,10 @@ def train_one_epoch(
...
@@ -180,8 +194,10 @@ def train_one_epoch(
tot_steps
,
tot_steps
,
opt
.
param_groups
[
0
][
"lr"
],
opt
.
param_groups
[
0
][
"lr"
],
*
average_loss
,
*
average_loss
,
*
time_meter
.
average
()
)
)
meter
.
reset
()
meter
.
reset
()
time_meter
.
reset
()
def
make_parser
():
def
make_parser
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录