Spaces:
Runtime error
Runtime error
Annas
commited on
Commit
·
7f7b702
1
Parent(s):
4c44327
init
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitignore +1 -0
- app.py +14 -0
- detection/.DS_Store +0 -0
- detection/LICENSE.md +674 -0
- detection/Pipfile +28 -0
- detection/Pipfile.lock +985 -0
- README.md → detection/README.md +4 -4
- detection/app.py +190 -0
- detection/cfg/.DS_Store +0 -0
- detection/cfg/baseline/r50-csp.yaml +49 -0
- detection/cfg/baseline/x50-csp.yaml +49 -0
- detection/cfg/baseline/yolor-csp-x.yaml +52 -0
- detection/cfg/baseline/yolor-csp.yaml +52 -0
- detection/cfg/baseline/yolor-d6.yaml +63 -0
- detection/cfg/baseline/yolor-e6.yaml +63 -0
- detection/cfg/baseline/yolor-p6.yaml +63 -0
- detection/cfg/baseline/yolor-w6.yaml +63 -0
- detection/cfg/baseline/yolov3-spp.yaml +51 -0
- detection/cfg/baseline/yolov3.yaml +51 -0
- detection/cfg/baseline/yolov4-csp.yaml +52 -0
- detection/cfg/deploy/yolov7-d6.yaml +202 -0
- detection/cfg/deploy/yolov7-e6.yaml +180 -0
- detection/cfg/deploy/yolov7-e6e.yaml +301 -0
- detection/cfg/deploy/yolov7-tiny-silu.yaml +112 -0
- detection/cfg/deploy/yolov7-tiny.yaml +112 -0
- detection/cfg/deploy/yolov7-w6.yaml +158 -0
- detection/cfg/deploy/yolov7.yaml +140 -0
- detection/cfg/deploy/yolov7x.yaml +156 -0
- detection/cfg/training/yolov7-d6.yaml +207 -0
- detection/cfg/training/yolov7-e6.yaml +185 -0
- detection/cfg/training/yolov7-e6e.yaml +306 -0
- detection/cfg/training/yolov7-tiny.yaml +112 -0
- detection/cfg/training/yolov7-w6.yaml +163 -0
- detection/cfg/training/yolov7.yaml +140 -0
- detection/cfg/training/yolov7x.yaml +156 -0
- detection/data/coco.yaml +23 -0
- detection/data/hyp.scratch.custom.yaml +31 -0
- detection/data/hyp.scratch.p5.yaml +31 -0
- detection/data/hyp.scratch.p6.yaml +31 -0
- detection/data/hyp.scratch.tiny.yaml +31 -0
- detection/detect.py +195 -0
- detection/export.py +205 -0
- detection/hubconf.py +97 -0
- detection/models/__init__.py +1 -0
- detection/models/common.py +2019 -0
- detection/models/experimental.py +262 -0
- detection/models/yolo.py +843 -0
- detection/requirements.txt +39 -0
- detection/scripts/get_coco.sh +22 -0
- detection/test.py +347 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.DS_Store
|
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from detection import app
|
| 3 |
+
|
| 4 |
+
def recognize(img_arr):
|
| 5 |
+
return app.detect(img_arr)
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
demo = gr.Interface(fn=recognize,
|
| 9 |
+
inputs=[gr.Image(type="pil")],
|
| 10 |
+
outputs=[gr.Image(type='pil'), 'json'],
|
| 11 |
+
description='BIB Race Number Recognition')
|
| 12 |
+
demo.launch()
|
| 13 |
+
|
| 14 |
+
|
detection/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
detection/LICENSE.md
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 3, 29 June 2007
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
| 5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 6 |
+
of this license document, but changing it is not allowed.
|
| 7 |
+
|
| 8 |
+
Preamble
|
| 9 |
+
|
| 10 |
+
The GNU General Public License is a free, copyleft license for
|
| 11 |
+
software and other kinds of works.
|
| 12 |
+
|
| 13 |
+
The licenses for most software and other practical works are designed
|
| 14 |
+
to take away your freedom to share and change the works. By contrast,
|
| 15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
| 16 |
+
share and change all versions of a program--to make sure it remains free
|
| 17 |
+
software for all its users. We, the Free Software Foundation, use the
|
| 18 |
+
GNU General Public License for most of our software; it applies also to
|
| 19 |
+
any other work released this way by its authors. You can apply it to
|
| 20 |
+
your programs, too.
|
| 21 |
+
|
| 22 |
+
When we speak of free software, we are referring to freedom, not
|
| 23 |
+
price. Our General Public Licenses are designed to make sure that you
|
| 24 |
+
have the freedom to distribute copies of free software (and charge for
|
| 25 |
+
them if you wish), that you receive source code or can get it if you
|
| 26 |
+
want it, that you can change the software or use pieces of it in new
|
| 27 |
+
free programs, and that you know you can do these things.
|
| 28 |
+
|
| 29 |
+
To protect your rights, we need to prevent others from denying you
|
| 30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
| 31 |
+
certain responsibilities if you distribute copies of the software, or if
|
| 32 |
+
you modify it: responsibilities to respect the freedom of others.
|
| 33 |
+
|
| 34 |
+
For example, if you distribute copies of such a program, whether
|
| 35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
| 36 |
+
freedoms that you received. You must make sure that they, too, receive
|
| 37 |
+
or can get the source code. And you must show them these terms so they
|
| 38 |
+
know their rights.
|
| 39 |
+
|
| 40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
| 41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
| 42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
| 43 |
+
|
| 44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
| 45 |
+
that there is no warranty for this free software. For both users' and
|
| 46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
| 47 |
+
changed, so that their problems will not be attributed erroneously to
|
| 48 |
+
authors of previous versions.
|
| 49 |
+
|
| 50 |
+
Some devices are designed to deny users access to install or run
|
| 51 |
+
modified versions of the software inside them, although the manufacturer
|
| 52 |
+
can do so. This is fundamentally incompatible with the aim of
|
| 53 |
+
protecting users' freedom to change the software. The systematic
|
| 54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
| 55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
| 56 |
+
have designed this version of the GPL to prohibit the practice for those
|
| 57 |
+
products. If such problems arise substantially in other domains, we
|
| 58 |
+
stand ready to extend this provision to those domains in future versions
|
| 59 |
+
of the GPL, as needed to protect the freedom of users.
|
| 60 |
+
|
| 61 |
+
Finally, every program is threatened constantly by software patents.
|
| 62 |
+
States should not allow patents to restrict development and use of
|
| 63 |
+
software on general-purpose computers, but in those that do, we wish to
|
| 64 |
+
avoid the special danger that patents applied to a free program could
|
| 65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
| 66 |
+
patents cannot be used to render the program non-free.
|
| 67 |
+
|
| 68 |
+
The precise terms and conditions for copying, distribution and
|
| 69 |
+
modification follow.
|
| 70 |
+
|
| 71 |
+
TERMS AND CONDITIONS
|
| 72 |
+
|
| 73 |
+
0. Definitions.
|
| 74 |
+
|
| 75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
| 76 |
+
|
| 77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
| 78 |
+
works, such as semiconductor masks.
|
| 79 |
+
|
| 80 |
+
"The Program" refers to any copyrightable work licensed under this
|
| 81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
| 82 |
+
"recipients" may be individuals or organizations.
|
| 83 |
+
|
| 84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
| 85 |
+
in a fashion requiring copyright permission, other than the making of an
|
| 86 |
+
exact copy. The resulting work is called a "modified version" of the
|
| 87 |
+
earlier work or a work "based on" the earlier work.
|
| 88 |
+
|
| 89 |
+
A "covered work" means either the unmodified Program or a work based
|
| 90 |
+
on the Program.
|
| 91 |
+
|
| 92 |
+
To "propagate" a work means to do anything with it that, without
|
| 93 |
+
permission, would make you directly or secondarily liable for
|
| 94 |
+
infringement under applicable copyright law, except executing it on a
|
| 95 |
+
computer or modifying a private copy. Propagation includes copying,
|
| 96 |
+
distribution (with or without modification), making available to the
|
| 97 |
+
public, and in some countries other activities as well.
|
| 98 |
+
|
| 99 |
+
To "convey" a work means any kind of propagation that enables other
|
| 100 |
+
parties to make or receive copies. Mere interaction with a user through
|
| 101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
| 102 |
+
|
| 103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
| 104 |
+
to the extent that it includes a convenient and prominently visible
|
| 105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
| 106 |
+
tells the user that there is no warranty for the work (except to the
|
| 107 |
+
extent that warranties are provided), that licensees may convey the
|
| 108 |
+
work under this License, and how to view a copy of this License. If
|
| 109 |
+
the interface presents a list of user commands or options, such as a
|
| 110 |
+
menu, a prominent item in the list meets this criterion.
|
| 111 |
+
|
| 112 |
+
1. Source Code.
|
| 113 |
+
|
| 114 |
+
The "source code" for a work means the preferred form of the work
|
| 115 |
+
for making modifications to it. "Object code" means any non-source
|
| 116 |
+
form of a work.
|
| 117 |
+
|
| 118 |
+
A "Standard Interface" means an interface that either is an official
|
| 119 |
+
standard defined by a recognized standards body, or, in the case of
|
| 120 |
+
interfaces specified for a particular programming language, one that
|
| 121 |
+
is widely used among developers working in that language.
|
| 122 |
+
|
| 123 |
+
The "System Libraries" of an executable work include anything, other
|
| 124 |
+
than the work as a whole, that (a) is included in the normal form of
|
| 125 |
+
packaging a Major Component, but which is not part of that Major
|
| 126 |
+
Component, and (b) serves only to enable use of the work with that
|
| 127 |
+
Major Component, or to implement a Standard Interface for which an
|
| 128 |
+
implementation is available to the public in source code form. A
|
| 129 |
+
"Major Component", in this context, means a major essential component
|
| 130 |
+
(kernel, window system, and so on) of the specific operating system
|
| 131 |
+
(if any) on which the executable work runs, or a compiler used to
|
| 132 |
+
produce the work, or an object code interpreter used to run it.
|
| 133 |
+
|
| 134 |
+
The "Corresponding Source" for a work in object code form means all
|
| 135 |
+
the source code needed to generate, install, and (for an executable
|
| 136 |
+
work) run the object code and to modify the work, including scripts to
|
| 137 |
+
control those activities. However, it does not include the work's
|
| 138 |
+
System Libraries, or general-purpose tools or generally available free
|
| 139 |
+
programs which are used unmodified in performing those activities but
|
| 140 |
+
which are not part of the work. For example, Corresponding Source
|
| 141 |
+
includes interface definition files associated with source files for
|
| 142 |
+
the work, and the source code for shared libraries and dynamically
|
| 143 |
+
linked subprograms that the work is specifically designed to require,
|
| 144 |
+
such as by intimate data communication or control flow between those
|
| 145 |
+
subprograms and other parts of the work.
|
| 146 |
+
|
| 147 |
+
The Corresponding Source need not include anything that users
|
| 148 |
+
can regenerate automatically from other parts of the Corresponding
|
| 149 |
+
Source.
|
| 150 |
+
|
| 151 |
+
The Corresponding Source for a work in source code form is that
|
| 152 |
+
same work.
|
| 153 |
+
|
| 154 |
+
2. Basic Permissions.
|
| 155 |
+
|
| 156 |
+
All rights granted under this License are granted for the term of
|
| 157 |
+
copyright on the Program, and are irrevocable provided the stated
|
| 158 |
+
conditions are met. This License explicitly affirms your unlimited
|
| 159 |
+
permission to run the unmodified Program. The output from running a
|
| 160 |
+
covered work is covered by this License only if the output, given its
|
| 161 |
+
content, constitutes a covered work. This License acknowledges your
|
| 162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
| 163 |
+
|
| 164 |
+
You may make, run and propagate covered works that you do not
|
| 165 |
+
convey, without conditions so long as your license otherwise remains
|
| 166 |
+
in force. You may convey covered works to others for the sole purpose
|
| 167 |
+
of having them make modifications exclusively for you, or provide you
|
| 168 |
+
with facilities for running those works, provided that you comply with
|
| 169 |
+
the terms of this License in conveying all material for which you do
|
| 170 |
+
not control copyright. Those thus making or running the covered works
|
| 171 |
+
for you must do so exclusively on your behalf, under your direction
|
| 172 |
+
and control, on terms that prohibit them from making any copies of
|
| 173 |
+
your copyrighted material outside their relationship with you.
|
| 174 |
+
|
| 175 |
+
Conveying under any other circumstances is permitted solely under
|
| 176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
| 177 |
+
makes it unnecessary.
|
| 178 |
+
|
| 179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
| 180 |
+
|
| 181 |
+
No covered work shall be deemed part of an effective technological
|
| 182 |
+
measure under any applicable law fulfilling obligations under article
|
| 183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
| 184 |
+
similar laws prohibiting or restricting circumvention of such
|
| 185 |
+
measures.
|
| 186 |
+
|
| 187 |
+
When you convey a covered work, you waive any legal power to forbid
|
| 188 |
+
circumvention of technological measures to the extent such circumvention
|
| 189 |
+
is effected by exercising rights under this License with respect to
|
| 190 |
+
the covered work, and you disclaim any intention to limit operation or
|
| 191 |
+
modification of the work as a means of enforcing, against the work's
|
| 192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
| 193 |
+
technological measures.
|
| 194 |
+
|
| 195 |
+
4. Conveying Verbatim Copies.
|
| 196 |
+
|
| 197 |
+
You may convey verbatim copies of the Program's source code as you
|
| 198 |
+
receive it, in any medium, provided that you conspicuously and
|
| 199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
| 200 |
+
keep intact all notices stating that this License and any
|
| 201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
| 202 |
+
keep intact all notices of the absence of any warranty; and give all
|
| 203 |
+
recipients a copy of this License along with the Program.
|
| 204 |
+
|
| 205 |
+
You may charge any price or no price for each copy that you convey,
|
| 206 |
+
and you may offer support or warranty protection for a fee.
|
| 207 |
+
|
| 208 |
+
5. Conveying Modified Source Versions.
|
| 209 |
+
|
| 210 |
+
You may convey a work based on the Program, or the modifications to
|
| 211 |
+
produce it from the Program, in the form of source code under the
|
| 212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
| 213 |
+
|
| 214 |
+
a) The work must carry prominent notices stating that you modified
|
| 215 |
+
it, and giving a relevant date.
|
| 216 |
+
|
| 217 |
+
b) The work must carry prominent notices stating that it is
|
| 218 |
+
released under this License and any conditions added under section
|
| 219 |
+
7. This requirement modifies the requirement in section 4 to
|
| 220 |
+
"keep intact all notices".
|
| 221 |
+
|
| 222 |
+
c) You must license the entire work, as a whole, under this
|
| 223 |
+
License to anyone who comes into possession of a copy. This
|
| 224 |
+
License will therefore apply, along with any applicable section 7
|
| 225 |
+
additional terms, to the whole of the work, and all its parts,
|
| 226 |
+
regardless of how they are packaged. This License gives no
|
| 227 |
+
permission to license the work in any other way, but it does not
|
| 228 |
+
invalidate such permission if you have separately received it.
|
| 229 |
+
|
| 230 |
+
d) If the work has interactive user interfaces, each must display
|
| 231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
| 232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
| 233 |
+
work need not make them do so.
|
| 234 |
+
|
| 235 |
+
A compilation of a covered work with other separate and independent
|
| 236 |
+
works, which are not by their nature extensions of the covered work,
|
| 237 |
+
and which are not combined with it such as to form a larger program,
|
| 238 |
+
in or on a volume of a storage or distribution medium, is called an
|
| 239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
| 240 |
+
used to limit the access or legal rights of the compilation's users
|
| 241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
| 242 |
+
in an aggregate does not cause this License to apply to the other
|
| 243 |
+
parts of the aggregate.
|
| 244 |
+
|
| 245 |
+
6. Conveying Non-Source Forms.
|
| 246 |
+
|
| 247 |
+
You may convey a covered work in object code form under the terms
|
| 248 |
+
of sections 4 and 5, provided that you also convey the
|
| 249 |
+
machine-readable Corresponding Source under the terms of this License,
|
| 250 |
+
in one of these ways:
|
| 251 |
+
|
| 252 |
+
a) Convey the object code in, or embodied in, a physical product
|
| 253 |
+
(including a physical distribution medium), accompanied by the
|
| 254 |
+
Corresponding Source fixed on a durable physical medium
|
| 255 |
+
customarily used for software interchange.
|
| 256 |
+
|
| 257 |
+
b) Convey the object code in, or embodied in, a physical product
|
| 258 |
+
(including a physical distribution medium), accompanied by a
|
| 259 |
+
written offer, valid for at least three years and valid for as
|
| 260 |
+
long as you offer spare parts or customer support for that product
|
| 261 |
+
model, to give anyone who possesses the object code either (1) a
|
| 262 |
+
copy of the Corresponding Source for all the software in the
|
| 263 |
+
product that is covered by this License, on a durable physical
|
| 264 |
+
medium customarily used for software interchange, for a price no
|
| 265 |
+
more than your reasonable cost of physically performing this
|
| 266 |
+
conveying of source, or (2) access to copy the
|
| 267 |
+
Corresponding Source from a network server at no charge.
|
| 268 |
+
|
| 269 |
+
c) Convey individual copies of the object code with a copy of the
|
| 270 |
+
written offer to provide the Corresponding Source. This
|
| 271 |
+
alternative is allowed only occasionally and noncommercially, and
|
| 272 |
+
only if you received the object code with such an offer, in accord
|
| 273 |
+
with subsection 6b.
|
| 274 |
+
|
| 275 |
+
d) Convey the object code by offering access from a designated
|
| 276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
| 277 |
+
Corresponding Source in the same way through the same place at no
|
| 278 |
+
further charge. You need not require recipients to copy the
|
| 279 |
+
Corresponding Source along with the object code. If the place to
|
| 280 |
+
copy the object code is a network server, the Corresponding Source
|
| 281 |
+
may be on a different server (operated by you or a third party)
|
| 282 |
+
that supports equivalent copying facilities, provided you maintain
|
| 283 |
+
clear directions next to the object code saying where to find the
|
| 284 |
+
Corresponding Source. Regardless of what server hosts the
|
| 285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
| 286 |
+
available for as long as needed to satisfy these requirements.
|
| 287 |
+
|
| 288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
| 289 |
+
you inform other peers where the object code and Corresponding
|
| 290 |
+
Source of the work are being offered to the general public at no
|
| 291 |
+
charge under subsection 6d.
|
| 292 |
+
|
| 293 |
+
A separable portion of the object code, whose source code is excluded
|
| 294 |
+
from the Corresponding Source as a System Library, need not be
|
| 295 |
+
included in conveying the object code work.
|
| 296 |
+
|
| 297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
| 298 |
+
tangible personal property which is normally used for personal, family,
|
| 299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
| 300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
| 301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
| 302 |
+
product received by a particular user, "normally used" refers to a
|
| 303 |
+
typical or common use of that class of product, regardless of the status
|
| 304 |
+
of the particular user or of the way in which the particular user
|
| 305 |
+
actually uses, or expects or is expected to use, the product. A product
|
| 306 |
+
is a consumer product regardless of whether the product has substantial
|
| 307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
| 308 |
+
the only significant mode of use of the product.
|
| 309 |
+
|
| 310 |
+
"Installation Information" for a User Product means any methods,
|
| 311 |
+
procedures, authorization keys, or other information required to install
|
| 312 |
+
and execute modified versions of a covered work in that User Product from
|
| 313 |
+
a modified version of its Corresponding Source. The information must
|
| 314 |
+
suffice to ensure that the continued functioning of the modified object
|
| 315 |
+
code is in no case prevented or interfered with solely because
|
| 316 |
+
modification has been made.
|
| 317 |
+
|
| 318 |
+
If you convey an object code work under this section in, or with, or
|
| 319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
| 320 |
+
part of a transaction in which the right of possession and use of the
|
| 321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
| 322 |
+
fixed term (regardless of how the transaction is characterized), the
|
| 323 |
+
Corresponding Source conveyed under this section must be accompanied
|
| 324 |
+
by the Installation Information. But this requirement does not apply
|
| 325 |
+
if neither you nor any third party retains the ability to install
|
| 326 |
+
modified object code on the User Product (for example, the work has
|
| 327 |
+
been installed in ROM).
|
| 328 |
+
|
| 329 |
+
The requirement to provide Installation Information does not include a
|
| 330 |
+
requirement to continue to provide support service, warranty, or updates
|
| 331 |
+
for a work that has been modified or installed by the recipient, or for
|
| 332 |
+
the User Product in which it has been modified or installed. Access to a
|
| 333 |
+
network may be denied when the modification itself materially and
|
| 334 |
+
adversely affects the operation of the network or violates the rules and
|
| 335 |
+
protocols for communication across the network.
|
| 336 |
+
|
| 337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
| 338 |
+
in accord with this section must be in a format that is publicly
|
| 339 |
+
documented (and with an implementation available to the public in
|
| 340 |
+
source code form), and must require no special password or key for
|
| 341 |
+
unpacking, reading or copying.
|
| 342 |
+
|
| 343 |
+
7. Additional Terms.
|
| 344 |
+
|
| 345 |
+
"Additional permissions" are terms that supplement the terms of this
|
| 346 |
+
License by making exceptions from one or more of its conditions.
|
| 347 |
+
Additional permissions that are applicable to the entire Program shall
|
| 348 |
+
be treated as though they were included in this License, to the extent
|
| 349 |
+
that they are valid under applicable law. If additional permissions
|
| 350 |
+
apply only to part of the Program, that part may be used separately
|
| 351 |
+
under those permissions, but the entire Program remains governed by
|
| 352 |
+
this License without regard to the additional permissions.
|
| 353 |
+
|
| 354 |
+
When you convey a copy of a covered work, you may at your option
|
| 355 |
+
remove any additional permissions from that copy, or from any part of
|
| 356 |
+
it. (Additional permissions may be written to require their own
|
| 357 |
+
removal in certain cases when you modify the work.) You may place
|
| 358 |
+
additional permissions on material, added by you to a covered work,
|
| 359 |
+
for which you have or can give appropriate copyright permission.
|
| 360 |
+
|
| 361 |
+
Notwithstanding any other provision of this License, for material you
|
| 362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
| 363 |
+
that material) supplement the terms of this License with terms:
|
| 364 |
+
|
| 365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
| 366 |
+
terms of sections 15 and 16 of this License; or
|
| 367 |
+
|
| 368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
| 369 |
+
author attributions in that material or in the Appropriate Legal
|
| 370 |
+
Notices displayed by works containing it; or
|
| 371 |
+
|
| 372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
| 373 |
+
requiring that modified versions of such material be marked in
|
| 374 |
+
reasonable ways as different from the original version; or
|
| 375 |
+
|
| 376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
| 377 |
+
authors of the material; or
|
| 378 |
+
|
| 379 |
+
e) Declining to grant rights under trademark law for use of some
|
| 380 |
+
trade names, trademarks, or service marks; or
|
| 381 |
+
|
| 382 |
+
f) Requiring indemnification of licensors and authors of that
|
| 383 |
+
material by anyone who conveys the material (or modified versions of
|
| 384 |
+
it) with contractual assumptions of liability to the recipient, for
|
| 385 |
+
any liability that these contractual assumptions directly impose on
|
| 386 |
+
those licensors and authors.
|
| 387 |
+
|
| 388 |
+
All other non-permissive additional terms are considered "further
|
| 389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
| 390 |
+
received it, or any part of it, contains a notice stating that it is
|
| 391 |
+
governed by this License along with a term that is a further
|
| 392 |
+
restriction, you may remove that term. If a license document contains
|
| 393 |
+
a further restriction but permits relicensing or conveying under this
|
| 394 |
+
License, you may add to a covered work material governed by the terms
|
| 395 |
+
of that license document, provided that the further restriction does
|
| 396 |
+
not survive such relicensing or conveying.
|
| 397 |
+
|
| 398 |
+
If you add terms to a covered work in accord with this section, you
|
| 399 |
+
must place, in the relevant source files, a statement of the
|
| 400 |
+
additional terms that apply to those files, or a notice indicating
|
| 401 |
+
where to find the applicable terms.
|
| 402 |
+
|
| 403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
| 404 |
+
form of a separately written license, or stated as exceptions;
|
| 405 |
+
the above requirements apply either way.
|
| 406 |
+
|
| 407 |
+
8. Termination.
|
| 408 |
+
|
| 409 |
+
You may not propagate or modify a covered work except as expressly
|
| 410 |
+
provided under this License. Any attempt otherwise to propagate or
|
| 411 |
+
modify it is void, and will automatically terminate your rights under
|
| 412 |
+
this License (including any patent licenses granted under the third
|
| 413 |
+
paragraph of section 11).
|
| 414 |
+
|
| 415 |
+
However, if you cease all violation of this License, then your
|
| 416 |
+
license from a particular copyright holder is reinstated (a)
|
| 417 |
+
provisionally, unless and until the copyright holder explicitly and
|
| 418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
| 419 |
+
holder fails to notify you of the violation by some reasonable means
|
| 420 |
+
prior to 60 days after the cessation.
|
| 421 |
+
|
| 422 |
+
Moreover, your license from a particular copyright holder is
|
| 423 |
+
reinstated permanently if the copyright holder notifies you of the
|
| 424 |
+
violation by some reasonable means, this is the first time you have
|
| 425 |
+
received notice of violation of this License (for any work) from that
|
| 426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
| 427 |
+
your receipt of the notice.
|
| 428 |
+
|
| 429 |
+
Termination of your rights under this section does not terminate the
|
| 430 |
+
licenses of parties who have received copies or rights from you under
|
| 431 |
+
this License. If your rights have been terminated and not permanently
|
| 432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
| 433 |
+
material under section 10.
|
| 434 |
+
|
| 435 |
+
9. Acceptance Not Required for Having Copies.
|
| 436 |
+
|
| 437 |
+
You are not required to accept this License in order to receive or
|
| 438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
| 439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
| 440 |
+
to receive a copy likewise does not require acceptance. However,
|
| 441 |
+
nothing other than this License grants you permission to propagate or
|
| 442 |
+
modify any covered work. These actions infringe copyright if you do
|
| 443 |
+
not accept this License. Therefore, by modifying or propagating a
|
| 444 |
+
covered work, you indicate your acceptance of this License to do so.
|
| 445 |
+
|
| 446 |
+
10. Automatic Licensing of Downstream Recipients.
|
| 447 |
+
|
| 448 |
+
Each time you convey a covered work, the recipient automatically
|
| 449 |
+
receives a license from the original licensors, to run, modify and
|
| 450 |
+
propagate that work, subject to this License. You are not responsible
|
| 451 |
+
for enforcing compliance by third parties with this License.
|
| 452 |
+
|
| 453 |
+
An "entity transaction" is a transaction transferring control of an
|
| 454 |
+
organization, or substantially all assets of one, or subdividing an
|
| 455 |
+
organization, or merging organizations. If propagation of a covered
|
| 456 |
+
work results from an entity transaction, each party to that
|
| 457 |
+
transaction who receives a copy of the work also receives whatever
|
| 458 |
+
licenses to the work the party's predecessor in interest had or could
|
| 459 |
+
give under the previous paragraph, plus a right to possession of the
|
| 460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
| 461 |
+
the predecessor has it or can get it with reasonable efforts.
|
| 462 |
+
|
| 463 |
+
You may not impose any further restrictions on the exercise of the
|
| 464 |
+
rights granted or affirmed under this License. For example, you may
|
| 465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
| 466 |
+
rights granted under this License, and you may not initiate litigation
|
| 467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
| 468 |
+
any patent claim is infringed by making, using, selling, offering for
|
| 469 |
+
sale, or importing the Program or any portion of it.
|
| 470 |
+
|
| 471 |
+
11. Patents.
|
| 472 |
+
|
| 473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
| 474 |
+
License of the Program or a work on which the Program is based. The
|
| 475 |
+
work thus licensed is called the contributor's "contributor version".
|
| 476 |
+
|
| 477 |
+
A contributor's "essential patent claims" are all patent claims
|
| 478 |
+
owned or controlled by the contributor, whether already acquired or
|
| 479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
| 480 |
+
by this License, of making, using, or selling its contributor version,
|
| 481 |
+
but do not include claims that would be infringed only as a
|
| 482 |
+
consequence of further modification of the contributor version. For
|
| 483 |
+
purposes of this definition, "control" includes the right to grant
|
| 484 |
+
patent sublicenses in a manner consistent with the requirements of
|
| 485 |
+
this License.
|
| 486 |
+
|
| 487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
| 488 |
+
patent license under the contributor's essential patent claims, to
|
| 489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
| 490 |
+
propagate the contents of its contributor version.
|
| 491 |
+
|
| 492 |
+
In the following three paragraphs, a "patent license" is any express
|
| 493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
| 494 |
+
(such as an express permission to practice a patent or covenant not to
|
| 495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
| 496 |
+
party means to make such an agreement or commitment not to enforce a
|
| 497 |
+
patent against the party.
|
| 498 |
+
|
| 499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
| 500 |
+
and the Corresponding Source of the work is not available for anyone
|
| 501 |
+
to copy, free of charge and under the terms of this License, through a
|
| 502 |
+
publicly available network server or other readily accessible means,
|
| 503 |
+
then you must either (1) cause the Corresponding Source to be so
|
| 504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
| 505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
| 506 |
+
consistent with the requirements of this License, to extend the patent
|
| 507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
| 508 |
+
actual knowledge that, but for the patent license, your conveying the
|
| 509 |
+
covered work in a country, or your recipient's use of the covered work
|
| 510 |
+
in a country, would infringe one or more identifiable patents in that
|
| 511 |
+
country that you have reason to believe are valid.
|
| 512 |
+
|
| 513 |
+
If, pursuant to or in connection with a single transaction or
|
| 514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
| 515 |
+
covered work, and grant a patent license to some of the parties
|
| 516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
| 517 |
+
or convey a specific copy of the covered work, then the patent license
|
| 518 |
+
you grant is automatically extended to all recipients of the covered
|
| 519 |
+
work and works based on it.
|
| 520 |
+
|
| 521 |
+
A patent license is "discriminatory" if it does not include within
|
| 522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
| 523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
| 524 |
+
specifically granted under this License. You may not convey a covered
|
| 525 |
+
work if you are a party to an arrangement with a third party that is
|
| 526 |
+
in the business of distributing software, under which you make payment
|
| 527 |
+
to the third party based on the extent of your activity of conveying
|
| 528 |
+
the work, and under which the third party grants, to any of the
|
| 529 |
+
parties who would receive the covered work from you, a discriminatory
|
| 530 |
+
patent license (a) in connection with copies of the covered work
|
| 531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
| 532 |
+
for and in connection with specific products or compilations that
|
| 533 |
+
contain the covered work, unless you entered into that arrangement,
|
| 534 |
+
or that patent license was granted, prior to 28 March 2007.
|
| 535 |
+
|
| 536 |
+
Nothing in this License shall be construed as excluding or limiting
|
| 537 |
+
any implied license or other defenses to infringement that may
|
| 538 |
+
otherwise be available to you under applicable patent law.
|
| 539 |
+
|
| 540 |
+
12. No Surrender of Others' Freedom.
|
| 541 |
+
|
| 542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
| 543 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
| 545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
| 546 |
+
License and any other pertinent obligations, then as a consequence you may
|
| 547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
| 548 |
+
to collect a royalty for further conveying from those to whom you convey
|
| 549 |
+
the Program, the only way you could satisfy both those terms and this
|
| 550 |
+
License would be to refrain entirely from conveying the Program.
|
| 551 |
+
|
| 552 |
+
13. Use with the GNU Affero General Public License.
|
| 553 |
+
|
| 554 |
+
Notwithstanding any other provision of this License, you have
|
| 555 |
+
permission to link or combine any covered work with a work licensed
|
| 556 |
+
under version 3 of the GNU Affero General Public License into a single
|
| 557 |
+
combined work, and to convey the resulting work. The terms of this
|
| 558 |
+
License will continue to apply to the part which is the covered work,
|
| 559 |
+
but the special requirements of the GNU Affero General Public License,
|
| 560 |
+
section 13, concerning interaction through a network will apply to the
|
| 561 |
+
combination as such.
|
| 562 |
+
|
| 563 |
+
14. Revised Versions of this License.
|
| 564 |
+
|
| 565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
| 566 |
+
the GNU General Public License from time to time. Such new versions will
|
| 567 |
+
be similar in spirit to the present version, but may differ in detail to
|
| 568 |
+
address new problems or concerns.
|
| 569 |
+
|
| 570 |
+
Each version is given a distinguishing version number. If the
|
| 571 |
+
Program specifies that a certain numbered version of the GNU General
|
| 572 |
+
Public License "or any later version" applies to it, you have the
|
| 573 |
+
option of following the terms and conditions either of that numbered
|
| 574 |
+
version or of any later version published by the Free Software
|
| 575 |
+
Foundation. If the Program does not specify a version number of the
|
| 576 |
+
GNU General Public License, you may choose any version ever published
|
| 577 |
+
by the Free Software Foundation.
|
| 578 |
+
|
| 579 |
+
If the Program specifies that a proxy can decide which future
|
| 580 |
+
versions of the GNU General Public License can be used, that proxy's
|
| 581 |
+
public statement of acceptance of a version permanently authorizes you
|
| 582 |
+
to choose that version for the Program.
|
| 583 |
+
|
| 584 |
+
Later license versions may give you additional or different
|
| 585 |
+
permissions. However, no additional obligations are imposed on any
|
| 586 |
+
author or copyright holder as a result of your choosing to follow a
|
| 587 |
+
later version.
|
| 588 |
+
|
| 589 |
+
15. Disclaimer of Warranty.
|
| 590 |
+
|
| 591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
| 592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
| 593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
| 594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
| 595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
| 597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
| 598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 599 |
+
|
| 600 |
+
16. Limitation of Liability.
|
| 601 |
+
|
| 602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
| 603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
| 604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
| 605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
| 606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
| 607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
| 608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
| 609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
| 610 |
+
SUCH DAMAGES.
|
| 611 |
+
|
| 612 |
+
17. Interpretation of Sections 15 and 16.
|
| 613 |
+
|
| 614 |
+
If the disclaimer of warranty and limitation of liability provided
|
| 615 |
+
above cannot be given local legal effect according to their terms,
|
| 616 |
+
reviewing courts shall apply local law that most closely approximates
|
| 617 |
+
an absolute waiver of all civil liability in connection with the
|
| 618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
| 619 |
+
copy of the Program in return for a fee.
|
| 620 |
+
|
| 621 |
+
END OF TERMS AND CONDITIONS
|
| 622 |
+
|
| 623 |
+
How to Apply These Terms to Your New Programs
|
| 624 |
+
|
| 625 |
+
If you develop a new program, and you want it to be of the greatest
|
| 626 |
+
possible use to the public, the best way to achieve this is to make it
|
| 627 |
+
free software which everyone can redistribute and change under these terms.
|
| 628 |
+
|
| 629 |
+
To do so, attach the following notices to the program. It is safest
|
| 630 |
+
to attach them to the start of each source file to most effectively
|
| 631 |
+
state the exclusion of warranty; and each file should have at least
|
| 632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
| 633 |
+
|
| 634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
| 635 |
+
Copyright (C) <year> <name of author>
|
| 636 |
+
|
| 637 |
+
This program is free software: you can redistribute it and/or modify
|
| 638 |
+
it under the terms of the GNU General Public License as published by
|
| 639 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 640 |
+
(at your option) any later version.
|
| 641 |
+
|
| 642 |
+
This program is distributed in the hope that it will be useful,
|
| 643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 645 |
+
GNU General Public License for more details.
|
| 646 |
+
|
| 647 |
+
You should have received a copy of the GNU General Public License
|
| 648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 649 |
+
|
| 650 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 651 |
+
|
| 652 |
+
If the program does terminal interaction, make it output a short
|
| 653 |
+
notice like this when it starts in an interactive mode:
|
| 654 |
+
|
| 655 |
+
<program> Copyright (C) <year> <name of author>
|
| 656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
| 657 |
+
This is free software, and you are welcome to redistribute it
|
| 658 |
+
under certain conditions; type `show c' for details.
|
| 659 |
+
|
| 660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
| 661 |
+
parts of the General Public License. Of course, your program's commands
|
| 662 |
+
might be different; for a GUI interface, you would use an "about box".
|
| 663 |
+
|
| 664 |
+
You should also get your employer (if you work as a programmer) or school,
|
| 665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
| 666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
| 667 |
+
<https://www.gnu.org/licenses/>.
|
| 668 |
+
|
| 669 |
+
The GNU General Public License does not permit incorporating your program
|
| 670 |
+
into proprietary programs. If your program is a subroutine library, you
|
| 671 |
+
may consider it more useful to permit linking proprietary applications with
|
| 672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
| 673 |
+
Public License instead of this License. But first, please read
|
| 674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
detection/Pipfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[[source]]
|
| 2 |
+
url = "https://pypi.org/simple"
|
| 3 |
+
verify_ssl = true
|
| 4 |
+
name = "pypi"
|
| 5 |
+
|
| 6 |
+
[packages]
|
| 7 |
+
matplotlib = ">=3.2.2"
|
| 8 |
+
numpy = ">=1.18.5"
|
| 9 |
+
opencv-python = ">=4.1.1"
|
| 10 |
+
pillow = ">=7.1.2"
|
| 11 |
+
pyyaml = ">=5.3.1"
|
| 12 |
+
requests = ">=2.23.0"
|
| 13 |
+
scipy = ">=1.4.1"
|
| 14 |
+
torch = "!=1.12.0,>=1.7.0"
|
| 15 |
+
torchvision = "!=0.13.0,>=0.8.1"
|
| 16 |
+
tqdm = ">=4.41.0"
|
| 17 |
+
protobuf = "<4.21.3"
|
| 18 |
+
tensorboard = ">=2.4.1"
|
| 19 |
+
pandas = ">=1.1.4"
|
| 20 |
+
seaborn = ">=0.11.0"
|
| 21 |
+
ipython = "*"
|
| 22 |
+
psutil = "*"
|
| 23 |
+
thop = "*"
|
| 24 |
+
|
| 25 |
+
[dev-packages]
|
| 26 |
+
|
| 27 |
+
[requires]
|
| 28 |
+
python_version = "3.8"
|
detection/Pipfile.lock
ADDED
|
@@ -0,0 +1,985 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_meta": {
|
| 3 |
+
"hash": {
|
| 4 |
+
"sha256": "b6a2a48d059fdf02a0718549d2efc2db71db123b7c0ddfd73200667a5c8d31bc"
|
| 5 |
+
},
|
| 6 |
+
"pipfile-spec": 6,
|
| 7 |
+
"requires": {
|
| 8 |
+
"python_version": "3.8"
|
| 9 |
+
},
|
| 10 |
+
"sources": [
|
| 11 |
+
{
|
| 12 |
+
"name": "pypi",
|
| 13 |
+
"url": "https://pypi.org/simple",
|
| 14 |
+
"verify_ssl": true
|
| 15 |
+
}
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
"default": {
|
| 19 |
+
"absl-py": {
|
| 20 |
+
"hashes": [
|
| 21 |
+
"sha256:5d15f85b8cc859c6245bc9886ba664460ed96a6fee895416caa37d669ee74a9a",
|
| 22 |
+
"sha256:f568809938c49abbda89826223c992b630afd23c638160ad7840cfe347710d97"
|
| 23 |
+
],
|
| 24 |
+
"markers": "python_version >= '3.6'",
|
| 25 |
+
"version": "==1.2.0"
|
| 26 |
+
},
|
| 27 |
+
"appnope": {
|
| 28 |
+
"hashes": [
|
| 29 |
+
"sha256:02bd91c4de869fbb1e1c50aafc4098827a7a54ab2f39d9dcba6c9547ed920e24",
|
| 30 |
+
"sha256:265a455292d0bd8a72453494fa24df5a11eb18373a60c7c0430889f22548605e"
|
| 31 |
+
],
|
| 32 |
+
"markers": "sys_platform == 'darwin'",
|
| 33 |
+
"version": "==0.1.3"
|
| 34 |
+
},
|
| 35 |
+
"asttokens": {
|
| 36 |
+
"hashes": [
|
| 37 |
+
"sha256:c61e16246ecfb2cde2958406b4c8ebc043c9e6d73aaa83c941673b35e5d3a76b",
|
| 38 |
+
"sha256:e3305297c744ae53ffa032c45dc347286165e4ffce6875dc662b205db0623d86"
|
| 39 |
+
],
|
| 40 |
+
"version": "==2.0.8"
|
| 41 |
+
},
|
| 42 |
+
"backcall": {
|
| 43 |
+
"hashes": [
|
| 44 |
+
"sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e",
|
| 45 |
+
"sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"
|
| 46 |
+
],
|
| 47 |
+
"version": "==0.2.0"
|
| 48 |
+
},
|
| 49 |
+
"cachetools": {
|
| 50 |
+
"hashes": [
|
| 51 |
+
"sha256:6a94c6402995a99c3970cc7e4884bb60b4a8639938157eeed436098bf9831757",
|
| 52 |
+
"sha256:f9f17d2aec496a9aa6b76f53e3b614c965223c061982d434d160f930c698a9db"
|
| 53 |
+
],
|
| 54 |
+
"markers": "python_version ~= '3.7'",
|
| 55 |
+
"version": "==5.2.0"
|
| 56 |
+
},
|
| 57 |
+
"certifi": {
|
| 58 |
+
"hashes": [
|
| 59 |
+
"sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d",
|
| 60 |
+
"sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"
|
| 61 |
+
],
|
| 62 |
+
"markers": "python_version >= '3.6'",
|
| 63 |
+
"version": "==2022.6.15"
|
| 64 |
+
},
|
| 65 |
+
"charset-normalizer": {
|
| 66 |
+
"hashes": [
|
| 67 |
+
"sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
|
| 68 |
+
"sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
|
| 69 |
+
],
|
| 70 |
+
"markers": "python_version >= '3.6'",
|
| 71 |
+
"version": "==2.1.1"
|
| 72 |
+
},
|
| 73 |
+
"cycler": {
|
| 74 |
+
"hashes": [
|
| 75 |
+
"sha256:3a27e95f763a428a739d2add979fa7494c912a32c17c4c38c4d5f082cad165a3",
|
| 76 |
+
"sha256:9c87405839a19696e837b3b818fed3f5f69f16f1eec1a1ad77e043dcea9c772f"
|
| 77 |
+
],
|
| 78 |
+
"markers": "python_version >= '3.6'",
|
| 79 |
+
"version": "==0.11.0"
|
| 80 |
+
},
|
| 81 |
+
"decorator": {
|
| 82 |
+
"hashes": [
|
| 83 |
+
"sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330",
|
| 84 |
+
"sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"
|
| 85 |
+
],
|
| 86 |
+
"markers": "python_version >= '3.5'",
|
| 87 |
+
"version": "==5.1.1"
|
| 88 |
+
},
|
| 89 |
+
"executing": {
|
| 90 |
+
"hashes": [
|
| 91 |
+
"sha256:9c745f80cda11eb22b62cbecf21156491a794eb56ab06f9d286a44e62822b24e",
|
| 92 |
+
"sha256:d1cd87c2e371e9966261410c5b3769d6df2f9e4a79a83eebd2662dd3388f9833"
|
| 93 |
+
],
|
| 94 |
+
"version": "==0.10.0"
|
| 95 |
+
},
|
| 96 |
+
"fonttools": {
|
| 97 |
+
"hashes": [
|
| 98 |
+
"sha256:4606e1a88ee1f6699d182fea9511bd9a8a915d913eab4584e5226da1180fcce7",
|
| 99 |
+
"sha256:fff6b752e326c15756c819fe2fe7ceab69f96a1dbcfe8911d0941cdb49905007"
|
| 100 |
+
],
|
| 101 |
+
"markers": "python_version >= '3.7'",
|
| 102 |
+
"version": "==4.37.1"
|
| 103 |
+
},
|
| 104 |
+
"google-auth": {
|
| 105 |
+
"hashes": [
|
| 106 |
+
"sha256:be62acaae38d0049c21ca90f27a23847245c9f161ff54ede13af2cb6afecbac9",
|
| 107 |
+
"sha256:ed65ecf9f681832298e29328e1ef0a3676e3732b2e56f41532d45f70a22de0fb"
|
| 108 |
+
],
|
| 109 |
+
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
|
| 110 |
+
"version": "==2.11.0"
|
| 111 |
+
},
|
| 112 |
+
"google-auth-oauthlib": {
|
| 113 |
+
"hashes": [
|
| 114 |
+
"sha256:3f2a6e802eebbb6fb736a370fbf3b055edcb6b52878bf2f26330b5e041316c73",
|
| 115 |
+
"sha256:a90a072f6993f2c327067bf65270046384cda5a8ecb20b94ea9a687f1f233a7a"
|
| 116 |
+
],
|
| 117 |
+
"markers": "python_version >= '3.6'",
|
| 118 |
+
"version": "==0.4.6"
|
| 119 |
+
},
|
| 120 |
+
"grpcio": {
|
| 121 |
+
"hashes": [
|
| 122 |
+
"sha256:0425b5577be202d0a4024536bbccb1b052c47e0766096e6c3a5789ddfd5f400d",
|
| 123 |
+
"sha256:06c0739dff9e723bca28ec22301f3711d85c2e652d1c8ae938aa0f7ad632ef9a",
|
| 124 |
+
"sha256:08307dc5a6ac4da03146d6c00f62319e0665b01c6ffe805cfcaa955c17253f9c",
|
| 125 |
+
"sha256:090dfa19f41efcbe760ae59b34da4304d4be9a59960c9682b7eab7e0b6748a79",
|
| 126 |
+
"sha256:0a24b50810aae90c74bbd901c3f175b9645802d2fbf03eadaf418ddee4c26668",
|
| 127 |
+
"sha256:0cd44d78f302ff67f11a8c49b786c7ccbed2cfef6f4fd7bb0c3dc9255415f8f7",
|
| 128 |
+
"sha256:0d8a7f3eb6f290189f48223a5f4464c99619a9de34200ce80d5092fb268323d2",
|
| 129 |
+
"sha256:14d2bc74218986e5edf5527e870b0969d63601911994ebf0dce96288548cf0ef",
|
| 130 |
+
"sha256:1bb9afa85e797a646bfcd785309e869e80a375c959b11a17c9680abebacc0cb0",
|
| 131 |
+
"sha256:1ec63bbd09586e5cda1bdc832ae6975d2526d04433a764a1cc866caa399e50d4",
|
| 132 |
+
"sha256:2061dbe41e43b0a5e1fd423e8a7fb3a0cf11d69ce22d0fac21f1a8c704640b12",
|
| 133 |
+
"sha256:324e363bad4d89a8ec7124013371f268d43afd0ac0fdeec1b21c1a101eb7dafb",
|
| 134 |
+
"sha256:35dfd981b03a3ec842671d1694fe437ee9f7b9e6a02792157a2793b0eba4f478",
|
| 135 |
+
"sha256:43857d06b2473b640467467f8f553319b5e819e54be14c86324dad83a0547818",
|
| 136 |
+
"sha256:4706c78b0c183dca815bbb4ef3e8dd2136ccc8d1699f62c585e75e211ad388f6",
|
| 137 |
+
"sha256:4d9ad7122f60157454f74a850d1337ba135146cef6fb7956d78c7194d52db0fe",
|
| 138 |
+
"sha256:544da3458d1d249bb8aed5504adf3e194a931e212017934bf7bfa774dad37fb3",
|
| 139 |
+
"sha256:55782a31ec539f15b34ee56f19131fe1430f38a4be022eb30c85e0b0dcf57f11",
|
| 140 |
+
"sha256:55cd8b13c5ef22003889f599b8f2930836c6f71cd7cf3fc0196633813dc4f928",
|
| 141 |
+
"sha256:5dbba95fab9b35957b4977b8904fc1fa56b302f9051eff4d7716ebb0c087f801",
|
| 142 |
+
"sha256:5f57b9b61c22537623a5577bf5f2f970dc4e50fac5391090114c6eb3ab5a129f",
|
| 143 |
+
"sha256:64e097dd08bb408afeeaee9a56f75311c9ca5b27b8b0278279dc8eef85fa1051",
|
| 144 |
+
"sha256:664a270d3eac68183ad049665b0f4d0262ec387d5c08c0108dbcfe5b351a8b4d",
|
| 145 |
+
"sha256:668350ea02af018ca945bd629754d47126b366d981ab88e0369b53bc781ffb14",
|
| 146 |
+
"sha256:67cd275a651532d28620eef677b97164a5438c5afcfd44b15e8992afa9eb598c",
|
| 147 |
+
"sha256:68b5e47fcca8481f36ef444842801928e60e30a5b3852c9f4a95f2582d10dcb2",
|
| 148 |
+
"sha256:7191ffc8bcf8a630c547287ab103e1fdf72b2e0c119e634d8a36055c1d988ad0",
|
| 149 |
+
"sha256:815089435d0f113719eabf105832e4c4fa1726b39ae3fb2ca7861752b0f70570",
|
| 150 |
+
"sha256:8dbef03853a0dbe457417c5469cb0f9d5bf47401b49d50c7dad3c495663b699b",
|
| 151 |
+
"sha256:91cd292373e85a52c897fa5b4768c895e20a7dc3423449c64f0f96388dd1812e",
|
| 152 |
+
"sha256:9298d6f2a81f132f72a7e79cbc90a511fffacc75045c2b10050bb87b86c8353d",
|
| 153 |
+
"sha256:96cff5a2081db82fb710db6a19dd8f904bdebb927727aaf4d9c427984b79a4c1",
|
| 154 |
+
"sha256:9e63e0619a5627edb7a5eb3e9568b9f97e604856ba228cc1d8a9f83ce3d0466e",
|
| 155 |
+
"sha256:a278d02272214ec33f046864a24b5f5aab7f60f855de38c525e5b4ef61ec5b48",
|
| 156 |
+
"sha256:a6b2432ac2353c80a56d9015dfc5c4af60245c719628d4193ecd75ddf9cd248c",
|
| 157 |
+
"sha256:b821403907e865e8377af3eee62f0cb233ea2369ba0fcdce9505ca5bfaf4eeb3",
|
| 158 |
+
"sha256:b88bec3f94a16411a1e0336eb69f335f58229e45d4082b12d8e554cedea97586",
|
| 159 |
+
"sha256:bfdb8af4801d1c31a18d54b37f4e49bb268d1f485ecf47f70e78d56e04ff37a7",
|
| 160 |
+
"sha256:c79996ae64dc4d8730782dff0d1daacc8ce7d4c2ba9cef83b6f469f73c0655ce",
|
| 161 |
+
"sha256:cc34d182c4fd64b6ff8304a606b95e814e4f8ed4b245b6d6cc9607690e3ef201",
|
| 162 |
+
"sha256:d0d481ff55ea6cc49dab2c8276597bd4f1a84a8745fedb4bc23e12e9fb9d0e45",
|
| 163 |
+
"sha256:e9723784cf264697024778dcf4b7542c851fe14b14681d6268fb984a53f76df1",
|
| 164 |
+
"sha256:f4508e8abd67ebcccd0fbde6e2b1917ba5d153f3f20c1de385abd8722545e05f",
|
| 165 |
+
"sha256:f515782b168a4ec6ea241add845ccfebe187fc7b09adf892b3ad9e2592c60af1",
|
| 166 |
+
"sha256:f89de64d9eb3478b188859214752db50c91a749479011abd99e248550371375f",
|
| 167 |
+
"sha256:fcd5d932842df503eb0bf60f9cc35e6fe732b51f499e78b45234e0be41b0018d"
|
| 168 |
+
],
|
| 169 |
+
"markers": "python_version >= '3.6'",
|
| 170 |
+
"version": "==1.47.0"
|
| 171 |
+
},
|
| 172 |
+
"idna": {
|
| 173 |
+
"hashes": [
|
| 174 |
+
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
|
| 175 |
+
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
|
| 176 |
+
],
|
| 177 |
+
"markers": "python_version >= '3.5'",
|
| 178 |
+
"version": "==3.3"
|
| 179 |
+
},
|
| 180 |
+
"importlib-metadata": {
|
| 181 |
+
"hashes": [
|
| 182 |
+
"sha256:637245b8bab2b6502fcbc752cc4b7a6f6243bb02b31c5c26156ad103d3d45670",
|
| 183 |
+
"sha256:7401a975809ea1fdc658c3aa4f78cc2195a0e019c5cbc4c06122884e9ae80c23"
|
| 184 |
+
],
|
| 185 |
+
"markers": "python_version < '3.10'",
|
| 186 |
+
"version": "==4.12.0"
|
| 187 |
+
},
|
| 188 |
+
"ipython": {
|
| 189 |
+
"hashes": [
|
| 190 |
+
"sha256:7ca74052a38fa25fe9bedf52da0be7d3fdd2fb027c3b778ea78dfe8c212937d1",
|
| 191 |
+
"sha256:f2db3a10254241d9b447232cec8b424847f338d9d36f9a577a6192c332a46abd"
|
| 192 |
+
],
|
| 193 |
+
"index": "pypi",
|
| 194 |
+
"version": "==8.4.0"
|
| 195 |
+
},
|
| 196 |
+
"jedi": {
|
| 197 |
+
"hashes": [
|
| 198 |
+
"sha256:637c9635fcf47945ceb91cd7f320234a7be540ded6f3e99a50cb6febdfd1ba8d",
|
| 199 |
+
"sha256:74137626a64a99c8eb6ae5832d99b3bdd7d29a3850fe2aa80a4126b2a7d949ab"
|
| 200 |
+
],
|
| 201 |
+
"markers": "python_version >= '3.6'",
|
| 202 |
+
"version": "==0.18.1"
|
| 203 |
+
},
|
| 204 |
+
"kiwisolver": {
|
| 205 |
+
"hashes": [
|
| 206 |
+
"sha256:02f79693ec433cb4b5f51694e8477ae83b3205768a6fb48ffba60549080e295b",
|
| 207 |
+
"sha256:03baab2d6b4a54ddbb43bba1a3a2d1627e82d205c5cf8f4c924dc49284b87166",
|
| 208 |
+
"sha256:1041feb4cda8708ce73bb4dcb9ce1ccf49d553bf87c3954bdfa46f0c3f77252c",
|
| 209 |
+
"sha256:10ee06759482c78bdb864f4109886dff7b8a56529bc1609d4f1112b93fe6423c",
|
| 210 |
+
"sha256:1d1573129aa0fd901076e2bfb4275a35f5b7aa60fbfb984499d661ec950320b0",
|
| 211 |
+
"sha256:283dffbf061a4ec60391d51e6155e372a1f7a4f5b15d59c8505339454f8989e4",
|
| 212 |
+
"sha256:28bc5b299f48150b5f822ce68624e445040595a4ac3d59251703779836eceff9",
|
| 213 |
+
"sha256:2a66fdfb34e05b705620dd567f5a03f239a088d5a3f321e7b6ac3239d22aa286",
|
| 214 |
+
"sha256:2e307eb9bd99801f82789b44bb45e9f541961831c7311521b13a6c85afc09767",
|
| 215 |
+
"sha256:2e407cb4bd5a13984a6c2c0fe1845e4e41e96f183e5e5cd4d77a857d9693494c",
|
| 216 |
+
"sha256:2f5e60fabb7343a836360c4f0919b8cd0d6dbf08ad2ca6b9cf90bf0c76a3c4f6",
|
| 217 |
+
"sha256:36dafec3d6d6088d34e2de6b85f9d8e2324eb734162fba59d2ba9ed7a2043d5b",
|
| 218 |
+
"sha256:3fe20f63c9ecee44560d0e7f116b3a747a5d7203376abeea292ab3152334d004",
|
| 219 |
+
"sha256:41dae968a94b1ef1897cb322b39360a0812661dba7c682aa45098eb8e193dbdf",
|
| 220 |
+
"sha256:4bd472dbe5e136f96a4b18f295d159d7f26fd399136f5b17b08c4e5f498cd494",
|
| 221 |
+
"sha256:4ea39b0ccc4f5d803e3337dd46bcce60b702be4d86fd0b3d7531ef10fd99a1ac",
|
| 222 |
+
"sha256:5853eb494c71e267912275e5586fe281444eb5e722de4e131cddf9d442615626",
|
| 223 |
+
"sha256:5bce61af018b0cb2055e0e72e7d65290d822d3feee430b7b8203d8a855e78766",
|
| 224 |
+
"sha256:6295ecd49304dcf3bfbfa45d9a081c96509e95f4b9d0eb7ee4ec0530c4a96514",
|
| 225 |
+
"sha256:62ac9cc684da4cf1778d07a89bf5f81b35834cb96ca523d3a7fb32509380cbf6",
|
| 226 |
+
"sha256:70e7c2e7b750585569564e2e5ca9845acfaa5da56ac46df68414f29fea97be9f",
|
| 227 |
+
"sha256:7577c1987baa3adc4b3c62c33bd1118c3ef5c8ddef36f0f2c950ae0b199e100d",
|
| 228 |
+
"sha256:75facbe9606748f43428fc91a43edb46c7ff68889b91fa31f53b58894503a191",
|
| 229 |
+
"sha256:787518a6789009c159453da4d6b683f468ef7a65bbde796bcea803ccf191058d",
|
| 230 |
+
"sha256:78d6601aed50c74e0ef02f4204da1816147a6d3fbdc8b3872d263338a9052c51",
|
| 231 |
+
"sha256:7c43e1e1206cd421cd92e6b3280d4385d41d7166b3ed577ac20444b6995a445f",
|
| 232 |
+
"sha256:81e38381b782cc7e1e46c4e14cd997ee6040768101aefc8fa3c24a4cc58e98f8",
|
| 233 |
+
"sha256:841293b17ad704d70c578f1f0013c890e219952169ce8a24ebc063eecf775454",
|
| 234 |
+
"sha256:872b8ca05c40d309ed13eb2e582cab0c5a05e81e987ab9c521bf05ad1d5cf5cb",
|
| 235 |
+
"sha256:877272cf6b4b7e94c9614f9b10140e198d2186363728ed0f701c6eee1baec1da",
|
| 236 |
+
"sha256:8c808594c88a025d4e322d5bb549282c93c8e1ba71b790f539567932722d7bd8",
|
| 237 |
+
"sha256:8ed58b8acf29798b036d347791141767ccf65eee7f26bde03a71c944449e53de",
|
| 238 |
+
"sha256:91672bacaa030f92fc2f43b620d7b337fd9a5af28b0d6ed3f77afc43c4a64b5a",
|
| 239 |
+
"sha256:968f44fdbf6dd757d12920d63b566eeb4d5b395fd2d00d29d7ef00a00582aac9",
|
| 240 |
+
"sha256:9f85003f5dfa867e86d53fac6f7e6f30c045673fa27b603c397753bebadc3008",
|
| 241 |
+
"sha256:a553dadda40fef6bfa1456dc4be49b113aa92c2a9a9e8711e955618cd69622e3",
|
| 242 |
+
"sha256:a68b62a02953b9841730db7797422f983935aeefceb1679f0fc85cbfbd311c32",
|
| 243 |
+
"sha256:abbe9fa13da955feb8202e215c4018f4bb57469b1b78c7a4c5c7b93001699938",
|
| 244 |
+
"sha256:ad881edc7ccb9d65b0224f4e4d05a1e85cf62d73aab798943df6d48ab0cd79a1",
|
| 245 |
+
"sha256:b1792d939ec70abe76f5054d3f36ed5656021dcad1322d1cc996d4e54165cef9",
|
| 246 |
+
"sha256:b428ef021242344340460fa4c9185d0b1f66fbdbfecc6c63eff4b7c29fad429d",
|
| 247 |
+
"sha256:b533558eae785e33e8c148a8d9921692a9fe5aa516efbdff8606e7d87b9d5824",
|
| 248 |
+
"sha256:ba59c92039ec0a66103b1d5fe588fa546373587a7d68f5c96f743c3396afc04b",
|
| 249 |
+
"sha256:bc8d3bd6c72b2dd9decf16ce70e20abcb3274ba01b4e1c96031e0c4067d1e7cd",
|
| 250 |
+
"sha256:bc9db8a3efb3e403e4ecc6cd9489ea2bac94244f80c78e27c31dcc00d2790ac2",
|
| 251 |
+
"sha256:bf7d9fce9bcc4752ca4a1b80aabd38f6d19009ea5cbda0e0856983cf6d0023f5",
|
| 252 |
+
"sha256:c2dbb44c3f7e6c4d3487b31037b1bdbf424d97687c1747ce4ff2895795c9bf69",
|
| 253 |
+
"sha256:c79ebe8f3676a4c6630fd3f777f3cfecf9289666c84e775a67d1d358578dc2e3",
|
| 254 |
+
"sha256:c97528e64cb9ebeff9701e7938653a9951922f2a38bd847787d4a8e498cc83ae",
|
| 255 |
+
"sha256:d0611a0a2a518464c05ddd5a3a1a0e856ccc10e67079bb17f265ad19ab3c7597",
|
| 256 |
+
"sha256:d06adcfa62a4431d404c31216f0f8ac97397d799cd53800e9d3efc2fbb3cf14e",
|
| 257 |
+
"sha256:d41997519fcba4a1e46eb4a2fe31bc12f0ff957b2b81bac28db24744f333e955",
|
| 258 |
+
"sha256:d5b61785a9ce44e5a4b880272baa7cf6c8f48a5180c3e81c59553ba0cb0821ca",
|
| 259 |
+
"sha256:da152d8cdcab0e56e4f45eb08b9aea6455845ec83172092f09b0e077ece2cf7a",
|
| 260 |
+
"sha256:da7e547706e69e45d95e116e6939488d62174e033b763ab1496b4c29b76fabea",
|
| 261 |
+
"sha256:db5283d90da4174865d520e7366801a93777201e91e79bacbac6e6927cbceede",
|
| 262 |
+
"sha256:db608a6757adabb32f1cfe6066e39b3706d8c3aa69bbc353a5b61edad36a5cb4",
|
| 263 |
+
"sha256:e0ea21f66820452a3f5d1655f8704a60d66ba1191359b96541eaf457710a5fc6",
|
| 264 |
+
"sha256:e7da3fec7408813a7cebc9e4ec55afed2d0fd65c4754bc376bf03498d4e92686",
|
| 265 |
+
"sha256:e92a513161077b53447160b9bd8f522edfbed4bd9759e4c18ab05d7ef7e49408",
|
| 266 |
+
"sha256:ecb1fa0db7bf4cff9dac752abb19505a233c7f16684c5826d1f11ebd9472b871",
|
| 267 |
+
"sha256:efda5fc8cc1c61e4f639b8067d118e742b812c930f708e6667a5ce0d13499e29",
|
| 268 |
+
"sha256:f0a1dbdb5ecbef0d34eb77e56fcb3e95bbd7e50835d9782a45df81cc46949750",
|
| 269 |
+
"sha256:f0a71d85ecdd570ded8ac3d1c0f480842f49a40beb423bb8014539a9f32a5897",
|
| 270 |
+
"sha256:f4f270de01dd3e129a72efad823da90cc4d6aafb64c410c9033aba70db9f1ff0",
|
| 271 |
+
"sha256:f6cb459eea32a4e2cf18ba5fcece2dbdf496384413bc1bae15583f19e567f3b2",
|
| 272 |
+
"sha256:f8ad8285b01b0d4695102546b342b493b3ccc6781fc28c8c6a1bb63e95d22f09",
|
| 273 |
+
"sha256:f9f39e2f049db33a908319cf46624a569b36983c7c78318e9726a4cb8923b26c"
|
| 274 |
+
],
|
| 275 |
+
"markers": "python_version >= '3.7'",
|
| 276 |
+
"version": "==1.4.4"
|
| 277 |
+
},
|
| 278 |
+
"markdown": {
|
| 279 |
+
"hashes": [
|
| 280 |
+
"sha256:08fb8465cffd03d10b9dd34a5c3fea908e20391a2a90b88d66362cb05beed186",
|
| 281 |
+
"sha256:3b809086bb6efad416156e00a0da66fe47618a5d6918dd688f53f40c8e4cfeff"
|
| 282 |
+
],
|
| 283 |
+
"markers": "python_version >= '3.7'",
|
| 284 |
+
"version": "==3.4.1"
|
| 285 |
+
},
|
| 286 |
+
"markupsafe": {
|
| 287 |
+
"hashes": [
|
| 288 |
+
"sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003",
|
| 289 |
+
"sha256:089cf3dbf0cd6c100f02945abeb18484bd1ee57a079aefd52cffd17fba910b88",
|
| 290 |
+
"sha256:10c1bfff05d95783da83491be968e8fe789263689c02724e0c691933c52994f5",
|
| 291 |
+
"sha256:33b74d289bd2f5e527beadcaa3f401e0df0a89927c1559c8566c066fa4248ab7",
|
| 292 |
+
"sha256:3799351e2336dc91ea70b034983ee71cf2f9533cdff7c14c90ea126bfd95d65a",
|
| 293 |
+
"sha256:3ce11ee3f23f79dbd06fb3d63e2f6af7b12db1d46932fe7bd8afa259a5996603",
|
| 294 |
+
"sha256:421be9fbf0ffe9ffd7a378aafebbf6f4602d564d34be190fc19a193232fd12b1",
|
| 295 |
+
"sha256:43093fb83d8343aac0b1baa75516da6092f58f41200907ef92448ecab8825135",
|
| 296 |
+
"sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247",
|
| 297 |
+
"sha256:4a33dea2b688b3190ee12bd7cfa29d39c9ed176bda40bfa11099a3ce5d3a7ac6",
|
| 298 |
+
"sha256:4b9fe39a2ccc108a4accc2676e77da025ce383c108593d65cc909add5c3bd601",
|
| 299 |
+
"sha256:56442863ed2b06d19c37f94d999035e15ee982988920e12a5b4ba29b62ad1f77",
|
| 300 |
+
"sha256:671cd1187ed5e62818414afe79ed29da836dde67166a9fac6d435873c44fdd02",
|
| 301 |
+
"sha256:694deca8d702d5db21ec83983ce0bb4b26a578e71fbdbd4fdcd387daa90e4d5e",
|
| 302 |
+
"sha256:6a074d34ee7a5ce3effbc526b7083ec9731bb3cbf921bbe1d3005d4d2bdb3a63",
|
| 303 |
+
"sha256:6d0072fea50feec76a4c418096652f2c3238eaa014b2f94aeb1d56a66b41403f",
|
| 304 |
+
"sha256:6fbf47b5d3728c6aea2abb0589b5d30459e369baa772e0f37a0320185e87c980",
|
| 305 |
+
"sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b",
|
| 306 |
+
"sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812",
|
| 307 |
+
"sha256:8dc1c72a69aa7e082593c4a203dcf94ddb74bb5c8a731e4e1eb68d031e8498ff",
|
| 308 |
+
"sha256:8e3dcf21f367459434c18e71b2a9532d96547aef8a871872a5bd69a715c15f96",
|
| 309 |
+
"sha256:8e576a51ad59e4bfaac456023a78f6b5e6e7651dcd383bcc3e18d06f9b55d6d1",
|
| 310 |
+
"sha256:96e37a3dc86e80bf81758c152fe66dbf60ed5eca3d26305edf01892257049925",
|
| 311 |
+
"sha256:97a68e6ada378df82bc9f16b800ab77cbf4b2fada0081794318520138c088e4a",
|
| 312 |
+
"sha256:99a2a507ed3ac881b975a2976d59f38c19386d128e7a9a18b7df6fff1fd4c1d6",
|
| 313 |
+
"sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e",
|
| 314 |
+
"sha256:b09bf97215625a311f669476f44b8b318b075847b49316d3e28c08e41a7a573f",
|
| 315 |
+
"sha256:b7bd98b796e2b6553da7225aeb61f447f80a1ca64f41d83612e6139ca5213aa4",
|
| 316 |
+
"sha256:b87db4360013327109564f0e591bd2a3b318547bcef31b468a92ee504d07ae4f",
|
| 317 |
+
"sha256:bcb3ed405ed3222f9904899563d6fc492ff75cce56cba05e32eff40e6acbeaa3",
|
| 318 |
+
"sha256:d4306c36ca495956b6d568d276ac11fdd9c30a36f1b6eb928070dc5360b22e1c",
|
| 319 |
+
"sha256:d5ee4f386140395a2c818d149221149c54849dfcfcb9f1debfe07a8b8bd63f9a",
|
| 320 |
+
"sha256:dda30ba7e87fbbb7eab1ec9f58678558fd9a6b8b853530e176eabd064da81417",
|
| 321 |
+
"sha256:e04e26803c9c3851c931eac40c695602c6295b8d432cbe78609649ad9bd2da8a",
|
| 322 |
+
"sha256:e1c0b87e09fa55a220f058d1d49d3fb8df88fbfab58558f1198e08c1e1de842a",
|
| 323 |
+
"sha256:e72591e9ecd94d7feb70c1cbd7be7b3ebea3f548870aa91e2732960fa4d57a37",
|
| 324 |
+
"sha256:e8c843bbcda3a2f1e3c2ab25913c80a3c5376cd00c6e8c4a86a89a28c8dc5452",
|
| 325 |
+
"sha256:efc1913fd2ca4f334418481c7e595c00aad186563bbc1ec76067848c7ca0a933",
|
| 326 |
+
"sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a",
|
| 327 |
+
"sha256:fc7b548b17d238737688817ab67deebb30e8073c95749d55538ed473130ec0c7"
|
| 328 |
+
],
|
| 329 |
+
"markers": "python_version >= '3.7'",
|
| 330 |
+
"version": "==2.1.1"
|
| 331 |
+
},
|
| 332 |
+
"matplotlib": {
|
| 333 |
+
"hashes": [
|
| 334 |
+
"sha256:0bcdfcb0f976e1bac6721d7d457c17be23cf7501f977b6a38f9d38a3762841f7",
|
| 335 |
+
"sha256:1e64ac9be9da6bfff0a732e62116484b93b02a0b4d4b19934fb4f8e7ad26ad6a",
|
| 336 |
+
"sha256:22227c976ad4dc8c5a5057540421f0d8708c6560744ad2ad638d48e2984e1dbc",
|
| 337 |
+
"sha256:2886cc009f40e2984c083687251821f305d811d38e3df8ded414265e4583f0c5",
|
| 338 |
+
"sha256:2e6d184ebe291b9e8f7e78bbab7987d269c38ea3e062eace1fe7d898042ef804",
|
| 339 |
+
"sha256:3211ba82b9f1518d346f6309df137b50c3dc4421b4ed4815d1d7eadc617f45a1",
|
| 340 |
+
"sha256:339cac48b80ddbc8bfd05daae0a3a73414651a8596904c2a881cfd1edb65f26c",
|
| 341 |
+
"sha256:35a8ad4dddebd51f94c5d24bec689ec0ec66173bf614374a1244c6241c1595e0",
|
| 342 |
+
"sha256:3b4fa56159dc3c7f9250df88f653f085068bcd32dcd38e479bba58909254af7f",
|
| 343 |
+
"sha256:43e9d3fa077bf0cc95ded13d331d2156f9973dce17c6f0c8b49ccd57af94dbd9",
|
| 344 |
+
"sha256:57f1b4e69f438a99bb64d7f2c340db1b096b41ebaa515cf61ea72624279220ce",
|
| 345 |
+
"sha256:5c096363b206a3caf43773abebdbb5a23ea13faef71d701b21a9c27fdcef72f4",
|
| 346 |
+
"sha256:6bb93a0492d68461bd458eba878f52fdc8ac7bdb6c4acdfe43dba684787838c2",
|
| 347 |
+
"sha256:6ea6aef5c4338e58d8d376068e28f80a24f54e69f09479d1c90b7172bad9f25b",
|
| 348 |
+
"sha256:6fe807e8a22620b4cd95cfbc795ba310dc80151d43b037257250faf0bfcd82bc",
|
| 349 |
+
"sha256:73dd93dc35c85dece610cca8358003bf0760d7986f70b223e2306b4ea6d1406b",
|
| 350 |
+
"sha256:839d47b8ead7ad9669aaacdbc03f29656dc21f0d41a6fea2d473d856c39c8b1c",
|
| 351 |
+
"sha256:874df7505ba820e0400e7091199decf3ff1fde0583652120c50cd60d5820ca9a",
|
| 352 |
+
"sha256:879c7e5fce4939c6aa04581dfe08d57eb6102a71f2e202e3314d5fbc072fd5a0",
|
| 353 |
+
"sha256:94ff86af56a3869a4ae26a9637a849effd7643858a1a04dd5ee50e9ab75069a7",
|
| 354 |
+
"sha256:99482b83ebf4eb6d5fc6813d7aacdefdd480f0d9c0b52dcf9f1cc3b2c4b3361a",
|
| 355 |
+
"sha256:9ab29589cef03bc88acfa3a1490359000c18186fc30374d8aa77d33cc4a51a4a",
|
| 356 |
+
"sha256:9befa5954cdbc085e37d974ff6053da269474177921dd61facdad8023c4aeb51",
|
| 357 |
+
"sha256:a206a1b762b39398efea838f528b3a6d60cdb26fe9d58b48265787e29cd1d693",
|
| 358 |
+
"sha256:ab8d26f07fe64f6f6736d635cce7bfd7f625320490ed5bfc347f2cdb4fae0e56",
|
| 359 |
+
"sha256:b28de401d928890187c589036857a270a032961411934bdac4cf12dde3d43094",
|
| 360 |
+
"sha256:b428076a55fb1c084c76cb93e68006f27d247169f056412607c5c88828d08f88",
|
| 361 |
+
"sha256:bf618a825deb6205f015df6dfe6167a5d9b351203b03fab82043ae1d30f16511",
|
| 362 |
+
"sha256:c995f7d9568f18b5db131ab124c64e51b6820a92d10246d4f2b3f3a66698a15b",
|
| 363 |
+
"sha256:cd45a6f3e93a780185f70f05cf2a383daed13c3489233faad83e81720f7ede24",
|
| 364 |
+
"sha256:d2484b350bf3d32cae43f85dcfc89b3ed7bd2bcd781ef351f93eb6fb2cc483f9",
|
| 365 |
+
"sha256:d62880e1f60e5a30a2a8484432bcb3a5056969dc97258d7326ad465feb7ae069",
|
| 366 |
+
"sha256:dacddf5bfcec60e3f26ec5c0ae3d0274853a258b6c3fc5ef2f06a8eb23e042be",
|
| 367 |
+
"sha256:f3840c280ebc87a48488a46f760ea1c0c0c83fcf7abbe2e6baf99d033fd35fd8",
|
| 368 |
+
"sha256:f814504e459c68118bf2246a530ed953ebd18213dc20e3da524174d84ed010b2"
|
| 369 |
+
],
|
| 370 |
+
"index": "pypi",
|
| 371 |
+
"version": "==3.5.3"
|
| 372 |
+
},
|
| 373 |
+
"matplotlib-inline": {
|
| 374 |
+
"hashes": [
|
| 375 |
+
"sha256:f1f41aab5328aa5aaea9b16d083b128102f8712542f819fe7e6a420ff581b311",
|
| 376 |
+
"sha256:f887e5f10ba98e8d2b150ddcf4702c1e5f8b3a20005eb0f74bfdbd360ee6f304"
|
| 377 |
+
],
|
| 378 |
+
"markers": "python_version >= '3.5'",
|
| 379 |
+
"version": "==0.1.6"
|
| 380 |
+
},
|
| 381 |
+
"numpy": {
|
| 382 |
+
"hashes": [
|
| 383 |
+
"sha256:17e5226674f6ea79e14e3b91bfbc153fdf3ac13f5cc54ee7bc8fdbe820a32da0",
|
| 384 |
+
"sha256:2bd879d3ca4b6f39b7770829f73278b7c5e248c91d538aab1e506c628353e47f",
|
| 385 |
+
"sha256:4f41f5bf20d9a521f8cab3a34557cd77b6f205ab2116651f12959714494268b0",
|
| 386 |
+
"sha256:5593f67e66dea4e237f5af998d31a43e447786b2154ba1ad833676c788f37cde",
|
| 387 |
+
"sha256:5e28cd64624dc2354a349152599e55308eb6ca95a13ce6a7d5679ebff2962913",
|
| 388 |
+
"sha256:633679a472934b1c20a12ed0c9a6c9eb167fbb4cb89031939bfd03dd9dbc62b8",
|
| 389 |
+
"sha256:806970e69106556d1dd200e26647e9bee5e2b3f1814f9da104a943e8d548ca38",
|
| 390 |
+
"sha256:806cc25d5c43e240db709875e947076b2826f47c2c340a5a2f36da5bb10c58d6",
|
| 391 |
+
"sha256:8247f01c4721479e482cc2f9f7d973f3f47810cbc8c65e38fd1bbd3141cc9842",
|
| 392 |
+
"sha256:8ebf7e194b89bc66b78475bd3624d92980fca4e5bb86dda08d677d786fefc414",
|
| 393 |
+
"sha256:8ecb818231afe5f0f568c81f12ce50f2b828ff2b27487520d85eb44c71313b9e",
|
| 394 |
+
"sha256:8f9d84a24889ebb4c641a9b99e54adb8cab50972f0166a3abc14c3b93163f074",
|
| 395 |
+
"sha256:909c56c4d4341ec8315291a105169d8aae732cfb4c250fbc375a1efb7a844f8f",
|
| 396 |
+
"sha256:9b83d48e464f393d46e8dd8171687394d39bc5abfe2978896b77dc2604e8635d",
|
| 397 |
+
"sha256:ac987b35df8c2a2eab495ee206658117e9ce867acf3ccb376a19e83070e69418",
|
| 398 |
+
"sha256:b78d00e48261fbbd04aa0d7427cf78d18401ee0abd89c7559bbf422e5b1c7d01",
|
| 399 |
+
"sha256:b8b97a8a87cadcd3f94659b4ef6ec056261fa1e1c3317f4193ac231d4df70215",
|
| 400 |
+
"sha256:bd5b7ccae24e3d8501ee5563e82febc1771e73bd268eef82a1e8d2b4d556ae66",
|
| 401 |
+
"sha256:bdc02c0235b261925102b1bd586579b7158e9d0d07ecb61148a1799214a4afd5",
|
| 402 |
+
"sha256:be6b350dfbc7f708d9d853663772a9310783ea58f6035eec649fb9c4371b5389",
|
| 403 |
+
"sha256:c403c81bb8ffb1c993d0165a11493fd4bf1353d258f6997b3ee288b0a48fce77",
|
| 404 |
+
"sha256:cf8c6aed12a935abf2e290860af8e77b26a042eb7f2582ff83dc7ed5f963340c",
|
| 405 |
+
"sha256:d98addfd3c8728ee8b2c49126f3c44c703e2b005d4a95998e2167af176a9e722",
|
| 406 |
+
"sha256:dc76bca1ca98f4b122114435f83f1fcf3c0fe48e4e6f660e07996abf2f53903c",
|
| 407 |
+
"sha256:dec198619b7dbd6db58603cd256e092bcadef22a796f778bf87f8592b468441d",
|
| 408 |
+
"sha256:df28dda02c9328e122661f399f7655cdcbcf22ea42daa3650a26bce08a187450",
|
| 409 |
+
"sha256:e603ca1fb47b913942f3e660a15e55a9ebca906857edfea476ae5f0fe9b457d5",
|
| 410 |
+
"sha256:ecfdd68d334a6b97472ed032b5b37a30d8217c097acfff15e8452c710e775524"
|
| 411 |
+
],
|
| 412 |
+
"index": "pypi",
|
| 413 |
+
"version": "==1.23.2"
|
| 414 |
+
},
|
| 415 |
+
"oauthlib": {
|
| 416 |
+
"hashes": [
|
| 417 |
+
"sha256:23a8208d75b902797ea29fd31fa80a15ed9dc2c6c16fe73f5d346f83f6fa27a2",
|
| 418 |
+
"sha256:6db33440354787f9b7f3a6dbd4febf5d0f93758354060e802f6c06cb493022fe"
|
| 419 |
+
],
|
| 420 |
+
"markers": "python_version >= '3.6'",
|
| 421 |
+
"version": "==3.2.0"
|
| 422 |
+
},
|
| 423 |
+
"opencv-python": {
|
| 424 |
+
"hashes": [
|
| 425 |
+
"sha256:0dc82a3d8630c099d2f3ac1b1aabee164e8188db54a786abb7a4e27eba309440",
|
| 426 |
+
"sha256:5af8ba35a4fcb8913ffb86e92403e9a656a4bff4a645d196987468f0f8947875",
|
| 427 |
+
"sha256:6e32af22e3202748bd233ed8f538741876191863882eba44e332d1a34993165b",
|
| 428 |
+
"sha256:c5bfae41ad4031e66bb10ec4a0a2ffd3e514d092652781e8b1ac98d1b59f1158",
|
| 429 |
+
"sha256:dbdc84a9b4ea2cbae33861652d25093944b9959279200b7ae0badd32439f74de",
|
| 430 |
+
"sha256:e6e448b62afc95c5b58f97e87ef84699e6607fe5c58730a03301c52496005cae",
|
| 431 |
+
"sha256:f482e78de6e7b0b060ff994ffd859bddc3f7f382bb2019ef157b0ea8ca8712f5"
|
| 432 |
+
],
|
| 433 |
+
"index": "pypi",
|
| 434 |
+
"version": "==4.6.0.66"
|
| 435 |
+
},
|
| 436 |
+
"packaging": {
|
| 437 |
+
"hashes": [
|
| 438 |
+
"sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb",
|
| 439 |
+
"sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"
|
| 440 |
+
],
|
| 441 |
+
"markers": "python_version >= '3.6'",
|
| 442 |
+
"version": "==21.3"
|
| 443 |
+
},
|
| 444 |
+
"pandas": {
|
| 445 |
+
"hashes": [
|
| 446 |
+
"sha256:07238a58d7cbc8a004855ade7b75bbd22c0db4b0ffccc721556bab8a095515f6",
|
| 447 |
+
"sha256:0daf876dba6c622154b2e6741f29e87161f844e64f84801554f879d27ba63c0d",
|
| 448 |
+
"sha256:16ad23db55efcc93fa878f7837267973b61ea85d244fc5ff0ccbcfa5638706c5",
|
| 449 |
+
"sha256:1d9382f72a4f0e93909feece6fef5500e838ce1c355a581b3d8f259839f2ea76",
|
| 450 |
+
"sha256:24ea75f47bbd5574675dae21d51779a4948715416413b30614c1e8b480909f81",
|
| 451 |
+
"sha256:2893e923472a5e090c2d5e8db83e8f907364ec048572084c7d10ef93546be6d1",
|
| 452 |
+
"sha256:2ff7788468e75917574f080cd4681b27e1a7bf36461fe968b49a87b5a54d007c",
|
| 453 |
+
"sha256:41fc406e374590a3d492325b889a2686b31e7a7780bec83db2512988550dadbf",
|
| 454 |
+
"sha256:48350592665ea3cbcd07efc8c12ff12d89be09cd47231c7925e3b8afada9d50d",
|
| 455 |
+
"sha256:605d572126eb4ab2eadf5c59d5d69f0608df2bf7bcad5c5880a47a20a0699e3e",
|
| 456 |
+
"sha256:6dfbf16b1ea4f4d0ee11084d9c026340514d1d30270eaa82a9f1297b6c8ecbf0",
|
| 457 |
+
"sha256:6f803320c9da732cc79210d7e8cc5c8019aad512589c910c66529eb1b1818230",
|
| 458 |
+
"sha256:721a3dd2f06ef942f83a819c0f3f6a648b2830b191a72bbe9451bcd49c3bd42e",
|
| 459 |
+
"sha256:755679c49460bd0d2f837ab99f0a26948e68fa0718b7e42afbabd074d945bf84",
|
| 460 |
+
"sha256:78b00429161ccb0da252229bcda8010b445c4bf924e721265bec5a6e96a92e92",
|
| 461 |
+
"sha256:958a0588149190c22cdebbc0797e01972950c927a11a900fe6c2296f207b1d6f",
|
| 462 |
+
"sha256:a3924692160e3d847e18702bb048dc38e0e13411d2b503fecb1adf0fcf950ba4",
|
| 463 |
+
"sha256:d51674ed8e2551ef7773820ef5dab9322be0828629f2cbf8d1fc31a0c4fed640",
|
| 464 |
+
"sha256:d5ebc990bd34f4ac3c73a2724c2dcc9ee7bf1ce6cf08e87bb25c6ad33507e318",
|
| 465 |
+
"sha256:d6c0106415ff1a10c326c49bc5dd9ea8b9897a6ca0c8688eb9c30ddec49535ef",
|
| 466 |
+
"sha256:e48fbb64165cda451c06a0f9e4c7a16b534fcabd32546d531b3c240ce2844112"
|
| 467 |
+
],
|
| 468 |
+
"index": "pypi",
|
| 469 |
+
"version": "==1.4.3"
|
| 470 |
+
},
|
| 471 |
+
"parso": {
|
| 472 |
+
"hashes": [
|
| 473 |
+
"sha256:8c07be290bb59f03588915921e29e8a50002acaf2cdc5fa0e0114f91709fafa0",
|
| 474 |
+
"sha256:c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75"
|
| 475 |
+
],
|
| 476 |
+
"markers": "python_version >= '3.6'",
|
| 477 |
+
"version": "==0.8.3"
|
| 478 |
+
},
|
| 479 |
+
"pexpect": {
|
| 480 |
+
"hashes": [
|
| 481 |
+
"sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937",
|
| 482 |
+
"sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c"
|
| 483 |
+
],
|
| 484 |
+
"markers": "sys_platform != 'win32'",
|
| 485 |
+
"version": "==4.8.0"
|
| 486 |
+
},
|
| 487 |
+
"pickleshare": {
|
| 488 |
+
"hashes": [
|
| 489 |
+
"sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca",
|
| 490 |
+
"sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56"
|
| 491 |
+
],
|
| 492 |
+
"version": "==0.7.5"
|
| 493 |
+
},
|
| 494 |
+
"pillow": {
|
| 495 |
+
"hashes": [
|
| 496 |
+
"sha256:0030fdbd926fb85844b8b92e2f9449ba89607231d3dd597a21ae72dc7fe26927",
|
| 497 |
+
"sha256:030e3460861488e249731c3e7ab59b07c7853838ff3b8e16aac9561bb345da14",
|
| 498 |
+
"sha256:0ed2c4ef2451de908c90436d6e8092e13a43992f1860275b4d8082667fbb2ffc",
|
| 499 |
+
"sha256:136659638f61a251e8ed3b331fc6ccd124590eeff539de57c5f80ef3a9594e58",
|
| 500 |
+
"sha256:13b725463f32df1bfeacbf3dd197fb358ae8ebcd8c5548faa75126ea425ccb60",
|
| 501 |
+
"sha256:1536ad017a9f789430fb6b8be8bf99d2f214c76502becc196c6f2d9a75b01b76",
|
| 502 |
+
"sha256:15928f824870535c85dbf949c09d6ae7d3d6ac2d6efec80f3227f73eefba741c",
|
| 503 |
+
"sha256:17d4cafe22f050b46d983b71c707162d63d796a1235cdf8b9d7a112e97b15bac",
|
| 504 |
+
"sha256:1802f34298f5ba11d55e5bb09c31997dc0c6aed919658dfdf0198a2fe75d5490",
|
| 505 |
+
"sha256:1cc1d2451e8a3b4bfdb9caf745b58e6c7a77d2e469159b0d527a4554d73694d1",
|
| 506 |
+
"sha256:1fd6f5e3c0e4697fa7eb45b6e93996299f3feee73a3175fa451f49a74d092b9f",
|
| 507 |
+
"sha256:254164c57bab4b459f14c64e93df11eff5ded575192c294a0c49270f22c5d93d",
|
| 508 |
+
"sha256:2ad0d4df0f5ef2247e27fc790d5c9b5a0af8ade9ba340db4a73bb1a4a3e5fb4f",
|
| 509 |
+
"sha256:2c58b24e3a63efd22554c676d81b0e57f80e0a7d3a5874a7e14ce90ec40d3069",
|
| 510 |
+
"sha256:2d33a11f601213dcd5718109c09a52c2a1c893e7461f0be2d6febc2879ec2402",
|
| 511 |
+
"sha256:337a74fd2f291c607d220c793a8135273c4c2ab001b03e601c36766005f36885",
|
| 512 |
+
"sha256:37ff6b522a26d0538b753f0b4e8e164fdada12db6c6f00f62145d732d8a3152e",
|
| 513 |
+
"sha256:3d1f14f5f691f55e1b47f824ca4fdcb4b19b4323fe43cc7bb105988cad7496be",
|
| 514 |
+
"sha256:408673ed75594933714482501fe97e055a42996087eeca7e5d06e33218d05aa8",
|
| 515 |
+
"sha256:4134d3f1ba5f15027ff5c04296f13328fecd46921424084516bdb1b2548e66ff",
|
| 516 |
+
"sha256:4ad2f835e0ad81d1689f1b7e3fbac7b01bb8777d5a985c8962bedee0cc6d43da",
|
| 517 |
+
"sha256:50dff9cc21826d2977ef2d2a205504034e3a4563ca6f5db739b0d1026658e004",
|
| 518 |
+
"sha256:510cef4a3f401c246cfd8227b300828715dd055463cdca6176c2e4036df8bd4f",
|
| 519 |
+
"sha256:5aed7dde98403cd91d86a1115c78d8145c83078e864c1de1064f52e6feb61b20",
|
| 520 |
+
"sha256:69bd1a15d7ba3694631e00df8de65a8cb031911ca11f44929c97fe05eb9b6c1d",
|
| 521 |
+
"sha256:6bf088c1ce160f50ea40764f825ec9b72ed9da25346216b91361eef8ad1b8f8c",
|
| 522 |
+
"sha256:6e8c66f70fb539301e064f6478d7453e820d8a2c631da948a23384865cd95544",
|
| 523 |
+
"sha256:727dd1389bc5cb9827cbd1f9d40d2c2a1a0c9b32dd2261db522d22a604a6eec9",
|
| 524 |
+
"sha256:74a04183e6e64930b667d321524e3c5361094bb4af9083db5c301db64cd341f3",
|
| 525 |
+
"sha256:75e636fd3e0fb872693f23ccb8a5ff2cd578801251f3a4f6854c6a5d437d3c04",
|
| 526 |
+
"sha256:7761afe0126d046974a01e030ae7529ed0ca6a196de3ec6937c11df0df1bc91c",
|
| 527 |
+
"sha256:7888310f6214f19ab2b6df90f3f06afa3df7ef7355fc025e78a3044737fab1f5",
|
| 528 |
+
"sha256:7b0554af24df2bf96618dac71ddada02420f946be943b181108cac55a7a2dcd4",
|
| 529 |
+
"sha256:7c7b502bc34f6e32ba022b4a209638f9e097d7a9098104ae420eb8186217ebbb",
|
| 530 |
+
"sha256:808add66ea764ed97d44dda1ac4f2cfec4c1867d9efb16a33d158be79f32b8a4",
|
| 531 |
+
"sha256:831e648102c82f152e14c1a0938689dbb22480c548c8d4b8b248b3e50967b88c",
|
| 532 |
+
"sha256:93689632949aff41199090eff5474f3990b6823404e45d66a5d44304e9cdc467",
|
| 533 |
+
"sha256:96b5e6874431df16aee0c1ba237574cb6dff1dcb173798faa6a9d8b399a05d0e",
|
| 534 |
+
"sha256:9a54614049a18a2d6fe156e68e188da02a046a4a93cf24f373bffd977e943421",
|
| 535 |
+
"sha256:a138441e95562b3c078746a22f8fca8ff1c22c014f856278bdbdd89ca36cff1b",
|
| 536 |
+
"sha256:a647c0d4478b995c5e54615a2e5360ccedd2f85e70ab57fbe817ca613d5e63b8",
|
| 537 |
+
"sha256:a9c9bc489f8ab30906d7a85afac4b4944a572a7432e00698a7239f44a44e6efb",
|
| 538 |
+
"sha256:ad2277b185ebce47a63f4dc6302e30f05762b688f8dc3de55dbae4651872cdf3",
|
| 539 |
+
"sha256:b6d5e92df2b77665e07ddb2e4dbd6d644b78e4c0d2e9272a852627cdba0d75cf",
|
| 540 |
+
"sha256:bc431b065722a5ad1dfb4df354fb9333b7a582a5ee39a90e6ffff688d72f27a1",
|
| 541 |
+
"sha256:bdd0de2d64688ecae88dd8935012c4a72681e5df632af903a1dca8c5e7aa871a",
|
| 542 |
+
"sha256:c79698d4cd9318d9481d89a77e2d3fcaeff5486be641e60a4b49f3d2ecca4e28",
|
| 543 |
+
"sha256:cb6259196a589123d755380b65127ddc60f4c64b21fc3bb46ce3a6ea663659b0",
|
| 544 |
+
"sha256:d5b87da55a08acb586bad5c3aa3b86505f559b84f39035b233d5bf844b0834b1",
|
| 545 |
+
"sha256:dcd7b9c7139dc8258d164b55696ecd16c04607f1cc33ba7af86613881ffe4ac8",
|
| 546 |
+
"sha256:dfe4c1fedfde4e2fbc009d5ad420647f7730d719786388b7de0999bf32c0d9fd",
|
| 547 |
+
"sha256:ea98f633d45f7e815db648fd7ff0f19e328302ac36427343e4432c84432e7ff4",
|
| 548 |
+
"sha256:ec52c351b35ca269cb1f8069d610fc45c5bd38c3e91f9ab4cbbf0aebc136d9c8",
|
| 549 |
+
"sha256:eef7592281f7c174d3d6cbfbb7ee5984a671fcd77e3fc78e973d492e9bf0eb3f",
|
| 550 |
+
"sha256:f07f1f00e22b231dd3d9b9208692042e29792d6bd4f6639415d2f23158a80013",
|
| 551 |
+
"sha256:f3fac744f9b540148fa7715a435d2283b71f68bfb6d4aae24482a890aed18b59",
|
| 552 |
+
"sha256:fa768eff5f9f958270b081bb33581b4b569faabf8774726b283edb06617101dc",
|
| 553 |
+
"sha256:fac2d65901fb0fdf20363fbd345c01958a742f2dc62a8dd4495af66e3ff502a4"
|
| 554 |
+
],
|
| 555 |
+
"index": "pypi",
|
| 556 |
+
"version": "==9.2.0"
|
| 557 |
+
},
|
| 558 |
+
"prompt-toolkit": {
|
| 559 |
+
"hashes": [
|
| 560 |
+
"sha256:859b283c50bde45f5f97829f77a4674d1c1fcd88539364f1b28a37805cfd89c0",
|
| 561 |
+
"sha256:d8916d3f62a7b67ab353a952ce4ced6a1d2587dfe9ef8ebc30dd7c386751f289"
|
| 562 |
+
],
|
| 563 |
+
"markers": "python_full_version >= '3.6.2'",
|
| 564 |
+
"version": "==3.0.30"
|
| 565 |
+
},
|
| 566 |
+
"protobuf": {
|
| 567 |
+
"hashes": [
|
| 568 |
+
"sha256:072fbc78d705d3edc7ccac58a62c4c8e0cec856987da7df8aca86e647be4e35c",
|
| 569 |
+
"sha256:09297b7972da685ce269ec52af761743714996b4381c085205914c41fcab59fb",
|
| 570 |
+
"sha256:16f519de1313f1b7139ad70772e7db515b1420d208cb16c6d7858ea989fc64a9",
|
| 571 |
+
"sha256:1c91ef4110fdd2c590effb5dca8fdbdcb3bf563eece99287019c4204f53d81a4",
|
| 572 |
+
"sha256:3112b58aac3bac9c8be2b60a9daf6b558ca3f7681c130dcdd788ade7c9ffbdca",
|
| 573 |
+
"sha256:36cecbabbda242915529b8ff364f2263cd4de7c46bbe361418b5ed859677ba58",
|
| 574 |
+
"sha256:4276cdec4447bd5015453e41bdc0c0c1234eda08420b7c9a18b8d647add51e4b",
|
| 575 |
+
"sha256:435bb78b37fc386f9275a7035fe4fb1364484e38980d0dd91bc834a02c5ec909",
|
| 576 |
+
"sha256:48ed3877fa43e22bcacc852ca76d4775741f9709dd9575881a373bd3e85e54b2",
|
| 577 |
+
"sha256:54a1473077f3b616779ce31f477351a45b4fef8c9fd7892d6d87e287a38df368",
|
| 578 |
+
"sha256:69da7d39e39942bd52848438462674c463e23963a1fdaa84d88df7fbd7e749b2",
|
| 579 |
+
"sha256:6cbc312be5e71869d9d5ea25147cdf652a6781cf4d906497ca7690b7b9b5df13",
|
| 580 |
+
"sha256:7bb03bc2873a2842e5ebb4801f5c7ff1bfbdf426f85d0172f7644fcda0671ae0",
|
| 581 |
+
"sha256:7ca7da9c339ca8890d66958f5462beabd611eca6c958691a8fe6eccbd1eb0c6e",
|
| 582 |
+
"sha256:835a9c949dc193953c319603b2961c5c8f4327957fe23d914ca80d982665e8ee",
|
| 583 |
+
"sha256:84123274d982b9e248a143dadd1b9815049f4477dc783bf84efe6250eb4b836a",
|
| 584 |
+
"sha256:8961c3a78ebfcd000920c9060a262f082f29838682b1f7201889300c1fbe0616",
|
| 585 |
+
"sha256:96bd766831596d6014ca88d86dc8fe0fb2e428c0b02432fd9db3943202bf8c5e",
|
| 586 |
+
"sha256:9df0c10adf3e83015ced42a9a7bd64e13d06c4cf45c340d2c63020ea04499d0a",
|
| 587 |
+
"sha256:b38057450a0c566cbd04890a40edf916db890f2818e8682221611d78dc32ae26",
|
| 588 |
+
"sha256:bd95d1dfb9c4f4563e6093a9aa19d9c186bf98fa54da5252531cc0d3a07977e7",
|
| 589 |
+
"sha256:c1068287025f8ea025103e37d62ffd63fec8e9e636246b89c341aeda8a67c934",
|
| 590 |
+
"sha256:c438268eebb8cf039552897d78f402d734a404f1360592fef55297285f7f953f",
|
| 591 |
+
"sha256:cdc076c03381f5c1d9bb1abdcc5503d9ca8b53cf0a9d31a9f6754ec9e6c8af0f",
|
| 592 |
+
"sha256:f358aa33e03b7a84e0d91270a4d4d8f5df6921abe99a377828839e8ed0c04e07",
|
| 593 |
+
"sha256:f51d5a9f137f7a2cec2d326a74b6e3fc79d635d69ffe1b036d39fc7d75430d37"
|
| 594 |
+
],
|
| 595 |
+
"index": "pypi",
|
| 596 |
+
"version": "==3.19.4"
|
| 597 |
+
},
|
| 598 |
+
"psutil": {
|
| 599 |
+
"hashes": [
|
| 600 |
+
"sha256:068935df39055bf27a29824b95c801c7a5130f118b806eee663cad28dca97685",
|
| 601 |
+
"sha256:0904727e0b0a038830b019551cf3204dd48ef5c6868adc776e06e93d615fc5fc",
|
| 602 |
+
"sha256:0f15a19a05f39a09327345bc279c1ba4a8cfb0172cc0d3c7f7d16c813b2e7d36",
|
| 603 |
+
"sha256:19f36c16012ba9cfc742604df189f2f28d2720e23ff7d1e81602dbe066be9fd1",
|
| 604 |
+
"sha256:20b27771b077dcaa0de1de3ad52d22538fe101f9946d6dc7869e6f694f079329",
|
| 605 |
+
"sha256:28976df6c64ddd6320d281128817f32c29b539a52bdae5e192537bc338a9ec81",
|
| 606 |
+
"sha256:29a442e25fab1f4d05e2655bb1b8ab6887981838d22effa2396d584b740194de",
|
| 607 |
+
"sha256:3054e923204b8e9c23a55b23b6df73a8089ae1d075cb0bf711d3e9da1724ded4",
|
| 608 |
+
"sha256:32c52611756096ae91f5d1499fe6c53b86f4a9ada147ee42db4991ba1520e574",
|
| 609 |
+
"sha256:3a76ad658641172d9c6e593de6fe248ddde825b5866464c3b2ee26c35da9d237",
|
| 610 |
+
"sha256:44d1826150d49ffd62035785a9e2c56afcea66e55b43b8b630d7706276e87f22",
|
| 611 |
+
"sha256:4b6750a73a9c4a4e689490ccb862d53c7b976a2a35c4e1846d049dcc3f17d83b",
|
| 612 |
+
"sha256:56960b9e8edcca1456f8c86a196f0c3d8e3e361320071c93378d41445ffd28b0",
|
| 613 |
+
"sha256:57f1819b5d9e95cdfb0c881a8a5b7d542ed0b7c522d575706a80bedc848c8954",
|
| 614 |
+
"sha256:58678bbadae12e0db55186dc58f2888839228ac9f41cc7848853539b70490021",
|
| 615 |
+
"sha256:645bd4f7bb5b8633803e0b6746ff1628724668681a434482546887d22c7a9537",
|
| 616 |
+
"sha256:799759d809c31aab5fe4579e50addf84565e71c1dc9f1c31258f159ff70d3f87",
|
| 617 |
+
"sha256:79c9108d9aa7fa6fba6e668b61b82facc067a6b81517cab34d07a84aa89f3df0",
|
| 618 |
+
"sha256:91c7ff2a40c373d0cc9121d54bc5f31c4fa09c346528e6a08d1845bce5771ffc",
|
| 619 |
+
"sha256:9272167b5f5fbfe16945be3db475b3ce8d792386907e673a209da686176552af",
|
| 620 |
+
"sha256:944c4b4b82dc4a1b805329c980f270f170fdc9945464223f2ec8e57563139cf4",
|
| 621 |
+
"sha256:a6a11e48cb93a5fa606306493f439b4aa7c56cb03fc9ace7f6bfa21aaf07c453",
|
| 622 |
+
"sha256:a8746bfe4e8f659528c5c7e9af5090c5a7d252f32b2e859c584ef7d8efb1e689",
|
| 623 |
+
"sha256:abd9246e4cdd5b554a2ddd97c157e292ac11ef3e7af25ac56b08b455c829dca8",
|
| 624 |
+
"sha256:b14ee12da9338f5e5b3a3ef7ca58b3cba30f5b66f7662159762932e6d0b8f680",
|
| 625 |
+
"sha256:b88f75005586131276634027f4219d06e0561292be8bd6bc7f2f00bdabd63c4e",
|
| 626 |
+
"sha256:c7be9d7f5b0d206f0bbc3794b8e16fb7dbc53ec9e40bbe8787c6f2d38efcf6c9",
|
| 627 |
+
"sha256:d2d006286fbcb60f0b391741f520862e9b69f4019b4d738a2a45728c7e952f1b",
|
| 628 |
+
"sha256:db417f0865f90bdc07fa30e1aadc69b6f4cad7f86324b02aa842034efe8d8c4d",
|
| 629 |
+
"sha256:e7e10454cb1ab62cc6ce776e1c135a64045a11ec4c6d254d3f7689c16eb3efd2",
|
| 630 |
+
"sha256:f65f9a46d984b8cd9b3750c2bdb419b2996895b005aefa6cbaba9a143b1ce2c5",
|
| 631 |
+
"sha256:fea896b54f3a4ae6f790ac1d017101252c93f6fe075d0e7571543510f11d2676"
|
| 632 |
+
],
|
| 633 |
+
"index": "pypi",
|
| 634 |
+
"version": "==5.9.1"
|
| 635 |
+
},
|
| 636 |
+
"ptyprocess": {
|
| 637 |
+
"hashes": [
|
| 638 |
+
"sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35",
|
| 639 |
+
"sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"
|
| 640 |
+
],
|
| 641 |
+
"version": "==0.7.0"
|
| 642 |
+
},
|
| 643 |
+
"pure-eval": {
|
| 644 |
+
"hashes": [
|
| 645 |
+
"sha256:01eaab343580944bc56080ebe0a674b39ec44a945e6d09ba7db3cb8cec289350",
|
| 646 |
+
"sha256:2b45320af6dfaa1750f543d714b6d1c520a1688dec6fd24d339063ce0aaa9ac3"
|
| 647 |
+
],
|
| 648 |
+
"version": "==0.2.2"
|
| 649 |
+
},
|
| 650 |
+
"pyasn1": {
|
| 651 |
+
"hashes": [
|
| 652 |
+
"sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359",
|
| 653 |
+
"sha256:03840c999ba71680a131cfaee6fab142e1ed9bbd9c693e285cc6aca0d555e576",
|
| 654 |
+
"sha256:0458773cfe65b153891ac249bcf1b5f8f320b7c2ce462151f8fa74de8934becf",
|
| 655 |
+
"sha256:08c3c53b75eaa48d71cf8c710312316392ed40899cb34710d092e96745a358b7",
|
| 656 |
+
"sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d",
|
| 657 |
+
"sha256:5c9414dcfede6e441f7e8f81b43b34e834731003427e5b09e4e00e3172a10f00",
|
| 658 |
+
"sha256:6e7545f1a61025a4e58bb336952c5061697da694db1cae97b116e9c46abcf7c8",
|
| 659 |
+
"sha256:78fa6da68ed2727915c4767bb386ab32cdba863caa7dbe473eaae45f9959da86",
|
| 660 |
+
"sha256:7ab8a544af125fb704feadb008c99a88805126fb525280b2270bb25cc1d78a12",
|
| 661 |
+
"sha256:99fcc3c8d804d1bc6d9a099921e39d827026409a58f2a720dcdb89374ea0c776",
|
| 662 |
+
"sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba",
|
| 663 |
+
"sha256:e89bf84b5437b532b0803ba5c9a5e054d21fec423a89952a74f87fa2c9b7bce2",
|
| 664 |
+
"sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3"
|
| 665 |
+
],
|
| 666 |
+
"version": "==0.4.8"
|
| 667 |
+
},
|
| 668 |
+
"pyasn1-modules": {
|
| 669 |
+
"hashes": [
|
| 670 |
+
"sha256:0845a5582f6a02bb3e1bde9ecfc4bfcae6ec3210dd270522fee602365430c3f8",
|
| 671 |
+
"sha256:0fe1b68d1e486a1ed5473f1302bd991c1611d319bba158e98b106ff86e1d7199",
|
| 672 |
+
"sha256:15b7c67fabc7fc240d87fb9aabf999cf82311a6d6fb2c70d00d3d0604878c811",
|
| 673 |
+
"sha256:426edb7a5e8879f1ec54a1864f16b882c2837bfd06eee62f2c982315ee2473ed",
|
| 674 |
+
"sha256:65cebbaffc913f4fe9e4808735c95ea22d7a7775646ab690518c056784bc21b4",
|
| 675 |
+
"sha256:905f84c712230b2c592c19470d3ca8d552de726050d1d1716282a1f6146be65e",
|
| 676 |
+
"sha256:a50b808ffeb97cb3601dd25981f6b016cbb3d31fbf57a8b8a87428e6158d0c74",
|
| 677 |
+
"sha256:a99324196732f53093a84c4369c996713eb8c89d360a496b599fb1a9c47fc3eb",
|
| 678 |
+
"sha256:b80486a6c77252ea3a3e9b1e360bc9cf28eaac41263d173c032581ad2f20fe45",
|
| 679 |
+
"sha256:c29a5e5cc7a3f05926aff34e097e84f8589cd790ce0ed41b67aed6857b26aafd",
|
| 680 |
+
"sha256:cbac4bc38d117f2a49aeedec4407d23e8866ea4ac27ff2cf7fb3e5b570df19e0",
|
| 681 |
+
"sha256:f39edd8c4ecaa4556e989147ebf219227e2cd2e8a43c7e7fcb1f1c18c5fd6a3d",
|
| 682 |
+
"sha256:fe0644d9ab041506b62782e92b06b8c68cca799e1a9636ec398675459e031405"
|
| 683 |
+
],
|
| 684 |
+
"version": "==0.2.8"
|
| 685 |
+
},
|
| 686 |
+
"pygments": {
|
| 687 |
+
"hashes": [
|
| 688 |
+
"sha256:56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1",
|
| 689 |
+
"sha256:f643f331ab57ba3c9d89212ee4a2dabc6e94f117cf4eefde99a0574720d14c42"
|
| 690 |
+
],
|
| 691 |
+
"markers": "python_version >= '3.6'",
|
| 692 |
+
"version": "==2.13.0"
|
| 693 |
+
},
|
| 694 |
+
"pyparsing": {
|
| 695 |
+
"hashes": [
|
| 696 |
+
"sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb",
|
| 697 |
+
"sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"
|
| 698 |
+
],
|
| 699 |
+
"markers": "python_full_version >= '3.6.8'",
|
| 700 |
+
"version": "==3.0.9"
|
| 701 |
+
},
|
| 702 |
+
"python-dateutil": {
|
| 703 |
+
"hashes": [
|
| 704 |
+
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
|
| 705 |
+
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
|
| 706 |
+
],
|
| 707 |
+
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
| 708 |
+
"version": "==2.8.2"
|
| 709 |
+
},
|
| 710 |
+
"pytz": {
|
| 711 |
+
"hashes": [
|
| 712 |
+
"sha256:220f481bdafa09c3955dfbdddb7b57780e9a94f5127e35456a48589b9e0c0197",
|
| 713 |
+
"sha256:cea221417204f2d1a2aa03ddae3e867921971d0d76f14d87abb4414415bbdcf5"
|
| 714 |
+
],
|
| 715 |
+
"version": "==2022.2.1"
|
| 716 |
+
},
|
| 717 |
+
"pyyaml": {
|
| 718 |
+
"hashes": [
|
| 719 |
+
"sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293",
|
| 720 |
+
"sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b",
|
| 721 |
+
"sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57",
|
| 722 |
+
"sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b",
|
| 723 |
+
"sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4",
|
| 724 |
+
"sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07",
|
| 725 |
+
"sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba",
|
| 726 |
+
"sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9",
|
| 727 |
+
"sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287",
|
| 728 |
+
"sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513",
|
| 729 |
+
"sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0",
|
| 730 |
+
"sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0",
|
| 731 |
+
"sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92",
|
| 732 |
+
"sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f",
|
| 733 |
+
"sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2",
|
| 734 |
+
"sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc",
|
| 735 |
+
"sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c",
|
| 736 |
+
"sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86",
|
| 737 |
+
"sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4",
|
| 738 |
+
"sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c",
|
| 739 |
+
"sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34",
|
| 740 |
+
"sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b",
|
| 741 |
+
"sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c",
|
| 742 |
+
"sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb",
|
| 743 |
+
"sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737",
|
| 744 |
+
"sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3",
|
| 745 |
+
"sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d",
|
| 746 |
+
"sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53",
|
| 747 |
+
"sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78",
|
| 748 |
+
"sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803",
|
| 749 |
+
"sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a",
|
| 750 |
+
"sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",
|
| 751 |
+
"sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"
|
| 752 |
+
],
|
| 753 |
+
"index": "pypi",
|
| 754 |
+
"version": "==6.0"
|
| 755 |
+
},
|
| 756 |
+
"requests": {
|
| 757 |
+
"hashes": [
|
| 758 |
+
"sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983",
|
| 759 |
+
"sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"
|
| 760 |
+
],
|
| 761 |
+
"index": "pypi",
|
| 762 |
+
"version": "==2.28.1"
|
| 763 |
+
},
|
| 764 |
+
"requests-oauthlib": {
|
| 765 |
+
"hashes": [
|
| 766 |
+
"sha256:2577c501a2fb8d05a304c09d090d6e47c306fef15809d102b327cf8364bddab5",
|
| 767 |
+
"sha256:75beac4a47881eeb94d5ea5d6ad31ef88856affe2332b9aafb52c6452ccf0d7a"
|
| 768 |
+
],
|
| 769 |
+
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
| 770 |
+
"version": "==1.3.1"
|
| 771 |
+
},
|
| 772 |
+
"rsa": {
|
| 773 |
+
"hashes": [
|
| 774 |
+
"sha256:90260d9058e514786967344d0ef75fa8727eed8a7d2e43ce9f4bcf1b536174f7",
|
| 775 |
+
"sha256:e38464a49c6c85d7f1351b0126661487a7e0a14a50f1675ec50eb34d4f20ef21"
|
| 776 |
+
],
|
| 777 |
+
"markers": "python_version >= '3.6'",
|
| 778 |
+
"version": "==4.9"
|
| 779 |
+
},
|
| 780 |
+
"scipy": {
|
| 781 |
+
"hashes": [
|
| 782 |
+
"sha256:0419485dbcd0ed78c0d5bf234c5dd63e86065b39b4d669e45810d42199d49521",
|
| 783 |
+
"sha256:09412eb7fb60b8f00b328037fd814d25d261066ebc43a1e339cdce4f7502877e",
|
| 784 |
+
"sha256:26d28c468900e6d5fdb37d2812ab46db0ccd22c63baa095057871faa3a498bc9",
|
| 785 |
+
"sha256:34441dfbee5b002f9e15285014fd56e5e3372493c3e64ae297bae2c4b9659f5a",
|
| 786 |
+
"sha256:39ab9240cd215a9349c85ab908dda6d732f7d3b4b192fa05780812495536acc4",
|
| 787 |
+
"sha256:3bc1ab68b9a096f368ba06c3a5e1d1d50957a86665fc929c4332d21355e7e8f4",
|
| 788 |
+
"sha256:3c6f5d1d4b9a5e4fe5e14f26ffc9444fc59473bbf8d45dc4a9a15283b7063a72",
|
| 789 |
+
"sha256:47d1a95bd9d37302afcfe1b84c8011377c4f81e33649c5a5785db9ab827a6ade",
|
| 790 |
+
"sha256:71487c503e036740635f18324f62a11f283a632ace9d35933b2b0a04fd898c98",
|
| 791 |
+
"sha256:7a412c476a91b080e456229e413792bbb5d6202865dae963d1e6e28c2bb58691",
|
| 792 |
+
"sha256:825951b88f56765aeb6e5e38ac9d7d47407cfaaeb008d40aa1b45a2d7ea2731e",
|
| 793 |
+
"sha256:8cc81ac25659fec73599ccc52c989670e5ccd8974cf34bacd7b54a8d809aff1a",
|
| 794 |
+
"sha256:8d3faa40ac16c6357aaf7ea50394ea6f1e8e99d75e927a51102b1943b311b4d9",
|
| 795 |
+
"sha256:90c805f30c46cf60f1e76e947574f02954d25e3bb1e97aa8a07bc53aa31cf7d1",
|
| 796 |
+
"sha256:96d7cf7b25c9f23c59a766385f6370dab0659741699ecc7a451f9b94604938ce",
|
| 797 |
+
"sha256:b97b479f39c7e4aaf807efd0424dec74bbb379108f7d22cf09323086afcd312c",
|
| 798 |
+
"sha256:bc4e2c77d4cd015d739e75e74ebbafed59ba8497a7ed0fd400231ed7683497c4",
|
| 799 |
+
"sha256:c61b4a91a702e8e04aeb0bfc40460e1f17a640977c04dda8757efb0199c75332",
|
| 800 |
+
"sha256:d79da472015d0120ba9b357b28a99146cd6c17b9609403164b1a8ed149b4dfc8",
|
| 801 |
+
"sha256:e8fe305d9d67a81255e06203454729405706907dccbdfcc330b7b3482a6c371d",
|
| 802 |
+
"sha256:eb954f5aca4d26f468bbebcdc5448348eb287f7bea536c6306f62ea062f63d9a",
|
| 803 |
+
"sha256:f7c39f7dbb57cce00c108d06d731f3b0e2a4d3a95c66d96bce697684876ce4d4",
|
| 804 |
+
"sha256:f950a04b33e17b38ff561d5a0951caf3f5b47caa841edd772ffb7959f20a6af0"
|
| 805 |
+
],
|
| 806 |
+
"index": "pypi",
|
| 807 |
+
"version": "==1.9.1"
|
| 808 |
+
},
|
| 809 |
+
"seaborn": {
|
| 810 |
+
"hashes": [
|
| 811 |
+
"sha256:85a6baa9b55f81a0623abddc4a26b334653ff4c6b18c418361de19dbba0ef283",
|
| 812 |
+
"sha256:cf45e9286d40826864be0e3c066f98536982baf701a7caa386511792d61ff4f6"
|
| 813 |
+
],
|
| 814 |
+
"index": "pypi",
|
| 815 |
+
"version": "==0.11.2"
|
| 816 |
+
},
|
| 817 |
+
"setuptools": {
|
| 818 |
+
"hashes": [
|
| 819 |
+
"sha256:2e24e0bec025f035a2e72cdd1961119f557d78ad331bb00ff82efb2ab8da8e82",
|
| 820 |
+
"sha256:7732871f4f7fa58fb6bdcaeadb0161b2bd046c85905dbaa066bdcbcc81953b57"
|
| 821 |
+
],
|
| 822 |
+
"markers": "python_version >= '3.7'",
|
| 823 |
+
"version": "==65.3.0"
|
| 824 |
+
},
|
| 825 |
+
"six": {
|
| 826 |
+
"hashes": [
|
| 827 |
+
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
|
| 828 |
+
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
|
| 829 |
+
],
|
| 830 |
+
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
| 831 |
+
"version": "==1.16.0"
|
| 832 |
+
},
|
| 833 |
+
"stack-data": {
|
| 834 |
+
"hashes": [
|
| 835 |
+
"sha256:66d2ebd3d7f29047612ead465b6cae5371006a71f45037c7e2507d01367bce3b",
|
| 836 |
+
"sha256:715c8855fbf5c43587b141e46cc9d9339cc0d1f8d6e0f98ed0d01c6cb974e29f"
|
| 837 |
+
],
|
| 838 |
+
"version": "==0.5.0"
|
| 839 |
+
},
|
| 840 |
+
"tensorboard": {
|
| 841 |
+
"hashes": [
|
| 842 |
+
"sha256:76c91a5e8959cd2208cc32cb17a0cb002badabb66a06ac2af02a7810f49a59e3"
|
| 843 |
+
],
|
| 844 |
+
"index": "pypi",
|
| 845 |
+
"version": "==2.10.0"
|
| 846 |
+
},
|
| 847 |
+
"tensorboard-data-server": {
|
| 848 |
+
"hashes": [
|
| 849 |
+
"sha256:809fe9887682d35c1f7d1f54f0f40f98bb1f771b14265b453ca051e2ce58fca7",
|
| 850 |
+
"sha256:d8237580755e58eff68d1f3abefb5b1e39ae5c8b127cc40920f9c4fb33f4b98a",
|
| 851 |
+
"sha256:fa8cef9be4fcae2f2363c88176638baf2da19c5ec90addb49b1cde05c95c88ee"
|
| 852 |
+
],
|
| 853 |
+
"markers": "python_version >= '3.6'",
|
| 854 |
+
"version": "==0.6.1"
|
| 855 |
+
},
|
| 856 |
+
"tensorboard-plugin-wit": {
|
| 857 |
+
"hashes": [
|
| 858 |
+
"sha256:ff26bdd583d155aa951ee3b152b3d0cffae8005dc697f72b44a8e8c2a77a8cbe"
|
| 859 |
+
],
|
| 860 |
+
"version": "==1.8.1"
|
| 861 |
+
},
|
| 862 |
+
"thop": {
|
| 863 |
+
"hashes": [
|
| 864 |
+
"sha256:13517320470e751ba56b59788c902f189640e83b9f0a46f5736c9a928dd4e280"
|
| 865 |
+
],
|
| 866 |
+
"index": "pypi",
|
| 867 |
+
"version": "==0.1.1.post2207130030"
|
| 868 |
+
},
|
| 869 |
+
"torch": {
|
| 870 |
+
"hashes": [
|
| 871 |
+
"sha256:03e31c37711db2cd201e02de5826de875529e45a55631d317aadce2f1ed45aa8",
|
| 872 |
+
"sha256:0b44601ec56f7dd44ad8afc00846051162ef9c26a8579dda0a02194327f2d55e",
|
| 873 |
+
"sha256:42e115dab26f60c29e298559dbec88444175528b729ae994ec4c65d56fe267dd",
|
| 874 |
+
"sha256:42f639501928caabb9d1d55ddd17f07cd694de146686c24489ab8c615c2871f2",
|
| 875 |
+
"sha256:4e1b9c14cf13fd2ab8d769529050629a0e68a6fc5cb8e84b4a3cc1dd8c4fe541",
|
| 876 |
+
"sha256:68104e4715a55c4bb29a85c6a8d57d820e0757da363be1ba680fa8cc5be17b52",
|
| 877 |
+
"sha256:69fe2cae7c39ccadd65a123793d30e0db881f1c1927945519c5c17323131437e",
|
| 878 |
+
"sha256:6cf6f54b43c0c30335428195589bd00e764a6d27f3b9ba637aaa8c11aaf93073",
|
| 879 |
+
"sha256:743784ccea0dc8f2a3fe6a536bec8c4763bd82c1352f314937cb4008d4805de1",
|
| 880 |
+
"sha256:8a34a2fbbaa07c921e1b203f59d3d6e00ed379f2b384445773bd14e328a5b6c8",
|
| 881 |
+
"sha256:976c3f997cea38ee91a0dd3c3a42322785414748d1761ef926b789dfa97c6134",
|
| 882 |
+
"sha256:9b356aea223772cd754edb4d9ecf2a025909b8615a7668ac7d5130f86e7ec421",
|
| 883 |
+
"sha256:9c038662db894a23e49e385df13d47b2a777ffd56d9bcd5b832593fab0a7e286",
|
| 884 |
+
"sha256:a8320ba9ad87e80ca5a6a016e46ada4d1ba0c54626e135d99b2129a4541c509d",
|
| 885 |
+
"sha256:b5dbcca369800ce99ba7ae6dee3466607a66958afca3b740690d88168752abcf",
|
| 886 |
+
"sha256:bfec2843daa654f04fda23ba823af03e7b6f7650a873cdb726752d0e3718dada",
|
| 887 |
+
"sha256:cd26d8c5640c3a28c526d41ccdca14cf1cbca0d0f2e14e8263a7ac17194ab1d2",
|
| 888 |
+
"sha256:e9c8f4a311ac29fc7e8e955cfb7733deb5dbe1bdaabf5d4af2765695824b7e0d",
|
| 889 |
+
"sha256:f00c721f489089dc6364a01fd84906348fe02243d0af737f944fddb36003400d",
|
| 890 |
+
"sha256:f3b52a634e62821e747e872084ab32fbcb01b7fa7dbb7471b6218279f02a178a"
|
| 891 |
+
],
|
| 892 |
+
"index": "pypi",
|
| 893 |
+
"version": "==1.12.1"
|
| 894 |
+
},
|
| 895 |
+
"torchvision": {
|
| 896 |
+
"hashes": [
|
| 897 |
+
"sha256:0298bae3b09ac361866088434008d82b99d6458fe8888c8df90720ef4b347d44",
|
| 898 |
+
"sha256:08f592ea61836ebeceb5c97f4d7a813b9d7dc651bbf7ce4401563ccfae6a21fc",
|
| 899 |
+
"sha256:099874088df104d54d8008f2a28539ca0117b512daed8bf3c2bbfa2b7ccb187a",
|
| 900 |
+
"sha256:0e77706cc90462653620e336bb90daf03d7bf1b88c3a9a3037df8d111823a56e",
|
| 901 |
+
"sha256:19286a733c69dcbd417b86793df807bd227db5786ed787c17297741a9b0d0fc7",
|
| 902 |
+
"sha256:3567fb3def829229ec217c1e38f08c5128ff7fb65854cac17ebac358ff7aa309",
|
| 903 |
+
"sha256:4d8bf321c4380854ef04613935fdd415dce29d1088a7ff99e06e113f0efe9203",
|
| 904 |
+
"sha256:5e631241bee3661de64f83616656224af2e3512eb2580da7c08e08b8c965a8ac",
|
| 905 |
+
"sha256:7552e80fa222252b8b217a951c85e172a710ea4cad0ae0c06fbb67addece7871",
|
| 906 |
+
"sha256:7cb789ceefe6dcd0dc8eeda37bfc45efb7cf34770eac9533861d51ca508eb5b3",
|
| 907 |
+
"sha256:83e9e2457f23110fd53b0177e1bc621518d6ea2108f570e853b768ce36b7c679",
|
| 908 |
+
"sha256:87c137f343197769a51333076e66bfcd576301d2cd8614b06657187c71b06c4f",
|
| 909 |
+
"sha256:899eec0b9f3b99b96d6f85b9aa58c002db41c672437677b553015b9135b3be7e",
|
| 910 |
+
"sha256:8e4d02e4d8a203e0c09c10dfb478214c224d080d31efc0dbf36d9c4051f7f3c6",
|
| 911 |
+
"sha256:b167934a5943242da7b1e59318f911d2d253feeca0d13ad5d832b58eed943401",
|
| 912 |
+
"sha256:c5ed609c8bc88c575226400b2232e0309094477c82af38952e0373edef0003fd",
|
| 913 |
+
"sha256:e9a563894f9fa40692e24d1aa58c3ef040450017cfed3598ff9637f404f3fe3b",
|
| 914 |
+
"sha256:ef5fe3ec1848123cd0ec74c07658192b3147dcd38e507308c790d5943e87b88c",
|
| 915 |
+
"sha256:f230a1a40ed70d51e463ce43df243ec520902f8725de2502e485efc5eea9d864"
|
| 916 |
+
],
|
| 917 |
+
"index": "pypi",
|
| 918 |
+
"version": "==0.13.1"
|
| 919 |
+
},
|
| 920 |
+
"tqdm": {
|
| 921 |
+
"hashes": [
|
| 922 |
+
"sha256:40be55d30e200777a307a7585aee69e4eabb46b4ec6a4b4a5f2d9f11e7d5408d",
|
| 923 |
+
"sha256:74a2cdefe14d11442cedf3ba4e21a3b84ff9a2dbdc6cfae2c34addb2a14a5ea6"
|
| 924 |
+
],
|
| 925 |
+
"index": "pypi",
|
| 926 |
+
"version": "==4.64.0"
|
| 927 |
+
},
|
| 928 |
+
"traitlets": {
|
| 929 |
+
"hashes": [
|
| 930 |
+
"sha256:0bb9f1f9f017aa8ec187d8b1b2a7a6626a2a1d877116baba52a129bfa124f8e2",
|
| 931 |
+
"sha256:65fa18961659635933100db8ca120ef6220555286949774b9cfc106f941d1c7a"
|
| 932 |
+
],
|
| 933 |
+
"markers": "python_version >= '3.7'",
|
| 934 |
+
"version": "==5.3.0"
|
| 935 |
+
},
|
| 936 |
+
"typing-extensions": {
|
| 937 |
+
"hashes": [
|
| 938 |
+
"sha256:25642c956049920a5aa49edcdd6ab1e06d7e5d467fc00e0506c44ac86fbfca02",
|
| 939 |
+
"sha256:e6d2677a32f47fc7eb2795db1dd15c1f34eff616bcaf2cfb5e997f854fa1c4a6"
|
| 940 |
+
],
|
| 941 |
+
"markers": "python_version >= '3.7'",
|
| 942 |
+
"version": "==4.3.0"
|
| 943 |
+
},
|
| 944 |
+
"urllib3": {
|
| 945 |
+
"hashes": [
|
| 946 |
+
"sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e",
|
| 947 |
+
"sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"
|
| 948 |
+
],
|
| 949 |
+
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4'",
|
| 950 |
+
"version": "==1.26.12"
|
| 951 |
+
},
|
| 952 |
+
"wcwidth": {
|
| 953 |
+
"hashes": [
|
| 954 |
+
"sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784",
|
| 955 |
+
"sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"
|
| 956 |
+
],
|
| 957 |
+
"version": "==0.2.5"
|
| 958 |
+
},
|
| 959 |
+
"werkzeug": {
|
| 960 |
+
"hashes": [
|
| 961 |
+
"sha256:7ea2d48322cc7c0f8b3a215ed73eabd7b5d75d0b50e31ab006286ccff9e00b8f",
|
| 962 |
+
"sha256:f979ab81f58d7318e064e99c4506445d60135ac5cd2e177a2de0089bfd4c9bd5"
|
| 963 |
+
],
|
| 964 |
+
"markers": "python_version >= '3.7'",
|
| 965 |
+
"version": "==2.2.2"
|
| 966 |
+
},
|
| 967 |
+
"wheel": {
|
| 968 |
+
"hashes": [
|
| 969 |
+
"sha256:4bdcd7d840138086126cd09254dc6195fb4fc6f01c050a1d7236f2630db1d22a",
|
| 970 |
+
"sha256:e9a504e793efbca1b8e0e9cb979a249cf4a0a7b5b8c9e8b65a5e39d49529c1c4"
|
| 971 |
+
],
|
| 972 |
+
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
| 973 |
+
"version": "==0.37.1"
|
| 974 |
+
},
|
| 975 |
+
"zipp": {
|
| 976 |
+
"hashes": [
|
| 977 |
+
"sha256:05b45f1ee8f807d0cc928485ca40a07cb491cf092ff587c0df9cb1fd154848d2",
|
| 978 |
+
"sha256:47c40d7fe183a6f21403a199b3e4192cca5774656965b0a4988ad2f8feb5f009"
|
| 979 |
+
],
|
| 980 |
+
"markers": "python_version >= '3.7'",
|
| 981 |
+
"version": "==3.8.1"
|
| 982 |
+
}
|
| 983 |
+
},
|
| 984 |
+
"develop": {}
|
| 985 |
+
}
|
README.md → detection/README.md
RENAMED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
-
title: BIB Number
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.1.7
|
| 8 |
app_file: app.py
|
|
|
|
| 1 |
---
|
| 2 |
+
title: BIB Number Detection
|
| 3 |
+
emoji: 🚀
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.1.7
|
| 8 |
app_file: app.py
|
detection/app.py
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
os.system("wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt")
|
| 3 |
+
os.system("wget https://gitlab.com/annasblackhat/bib-weight/-/raw/main/bib-best.pt")
|
| 4 |
+
os.system("wget https://gitlab.com/annasblackhat/bib-weight/-/raw/main/bib-best-v2.pt")
|
| 5 |
+
os.mkdir('Inference')
|
| 6 |
+
|
| 7 |
+
import gradio as gr
|
| 8 |
+
import argparse
|
| 9 |
+
import time
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
import cv2
|
| 13 |
+
import torch
|
| 14 |
+
import torch.backends.cudnn as cudnn
|
| 15 |
+
from numpy import random
|
| 16 |
+
|
| 17 |
+
from models.experimental import attempt_load
|
| 18 |
+
from utils.datasets import LoadStreams, LoadImages
|
| 19 |
+
from utils.general import check_img_size, check_requirements, check_imshow, non_max_suppression, apply_classifier, \
|
| 20 |
+
scale_coords, xyxy2xywh, strip_optimizer, set_logging, increment_path
|
| 21 |
+
from utils.plots import plot_one_box
|
| 22 |
+
from utils.torch_utils import select_device, load_classifier, time_synchronized, TracedModel
|
| 23 |
+
from PIL import Image
|
| 24 |
+
|
| 25 |
+
weights_paths = {'V1': 'bib-best.pt', 'V2': 'bib-best-v2.pt'}
|
| 26 |
+
|
| 27 |
+
def detect(img, weight = "V2"):
|
| 28 |
+
print('weight: ', weight)
|
| 29 |
+
parser = argparse.ArgumentParser()
|
| 30 |
+
parser.add_argument('--weights', nargs='+', type=str, default=weights_paths[weight], help='model.pt path(s)')
|
| 31 |
+
parser.add_argument('--source', type=str, default='Inference/', help='source') # file/folder, 0 for webcam
|
| 32 |
+
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
|
| 33 |
+
parser.add_argument('--conf-thres', type=float, default=0.25, help='object confidence threshold')
|
| 34 |
+
parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
|
| 35 |
+
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
| 36 |
+
parser.add_argument('--view-img', action='store_true', help='display results')
|
| 37 |
+
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
|
| 38 |
+
parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
|
| 39 |
+
parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
|
| 40 |
+
parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --class 0, or --class 0 2 3')
|
| 41 |
+
parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
|
| 42 |
+
parser.add_argument('--augment', action='store_true', help='augmented inference')
|
| 43 |
+
parser.add_argument('--update', action='store_true', help='update all models')
|
| 44 |
+
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
| 45 |
+
parser.add_argument('--name', default='exp', help='save results to project/name')
|
| 46 |
+
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
| 47 |
+
parser.add_argument('--trace', action='store_true', help='trace model')
|
| 48 |
+
opt = parser.parse_args()
|
| 49 |
+
print(opt)
|
| 50 |
+
img.save("Inference/test.jpg")
|
| 51 |
+
source, weights, view_img, save_txt, imgsz, trace = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size, opt.trace
|
| 52 |
+
save_img = True # save inference images
|
| 53 |
+
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
|
| 54 |
+
('rtsp://', 'rtmp://', 'http://', 'https://'))
|
| 55 |
+
|
| 56 |
+
# Directories
|
| 57 |
+
save_dir = Path(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)) # increment run
|
| 58 |
+
(save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True) # make dir
|
| 59 |
+
|
| 60 |
+
# Initialize
|
| 61 |
+
set_logging()
|
| 62 |
+
device = select_device(opt.device)
|
| 63 |
+
half = device.type != 'cpu' # half precision only supported on CUDA
|
| 64 |
+
|
| 65 |
+
# Load model
|
| 66 |
+
model = attempt_load(weights, map_location=device) # load FP32 model
|
| 67 |
+
stride = int(model.stride.max()) # model stride
|
| 68 |
+
imgsz = check_img_size(imgsz, s=stride) # check img_size
|
| 69 |
+
|
| 70 |
+
if trace:
|
| 71 |
+
model = TracedModel(model, device, opt.img_size)
|
| 72 |
+
|
| 73 |
+
if half:
|
| 74 |
+
model.half() # to FP16
|
| 75 |
+
|
| 76 |
+
# Second-stage classifier
|
| 77 |
+
classify = False
|
| 78 |
+
if classify:
|
| 79 |
+
modelc = load_classifier(name='resnet101', n=2) # initialize
|
| 80 |
+
modelc.load_state_dict(torch.load('weights/resnet101.pt', map_location=device)['model']).to(device).eval()
|
| 81 |
+
|
| 82 |
+
# Set Dataloader
|
| 83 |
+
vid_path, vid_writer = None, None
|
| 84 |
+
if webcam:
|
| 85 |
+
view_img = check_imshow()
|
| 86 |
+
cudnn.benchmark = True # set True to speed up constant image size inference
|
| 87 |
+
dataset = LoadStreams(source, img_size=imgsz, stride=stride)
|
| 88 |
+
else:
|
| 89 |
+
dataset = LoadImages(source, img_size=imgsz, stride=stride)
|
| 90 |
+
|
| 91 |
+
# Get names and colors
|
| 92 |
+
names = model.module.names if hasattr(model, 'module') else model.names
|
| 93 |
+
colors = [[random.randint(0, 255) for _ in range(3)] for _ in names]
|
| 94 |
+
|
| 95 |
+
# Run inference
|
| 96 |
+
if device.type != 'cpu':
|
| 97 |
+
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
|
| 98 |
+
t0 = time.time()
|
| 99 |
+
xyxy_pred = []
|
| 100 |
+
for path, img, im0s, vid_cap in dataset:
|
| 101 |
+
img = torch.from_numpy(img).to(device)
|
| 102 |
+
img = img.half() if half else img.float() # uint8 to fp16/32
|
| 103 |
+
img /= 255.0 # 0 - 255 to 0.0 - 1.0
|
| 104 |
+
if img.ndimension() == 3:
|
| 105 |
+
img = img.unsqueeze(0)
|
| 106 |
+
|
| 107 |
+
# Inference
|
| 108 |
+
t1 = time_synchronized()
|
| 109 |
+
pred = model(img, augment=opt.augment)[0]
|
| 110 |
+
|
| 111 |
+
# Apply NMS
|
| 112 |
+
pred = non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=opt.agnostic_nms)
|
| 113 |
+
t2 = time_synchronized()
|
| 114 |
+
|
| 115 |
+
# Apply Classifier
|
| 116 |
+
if classify:
|
| 117 |
+
pred = apply_classifier(pred, modelc, img, im0s)
|
| 118 |
+
|
| 119 |
+
# Process detections
|
| 120 |
+
for i, det in enumerate(pred): # detections per image
|
| 121 |
+
if webcam: # batch_size >= 1
|
| 122 |
+
p, s, im0, frame = path[i], '%g: ' % i, im0s[i].copy(), dataset.count
|
| 123 |
+
else:
|
| 124 |
+
p, s, im0, frame = path, '', im0s, getattr(dataset, 'frame', 0)
|
| 125 |
+
|
| 126 |
+
p = Path(p) # to Path
|
| 127 |
+
save_path = str(save_dir / p.name) # img.jpg
|
| 128 |
+
txt_path = str(save_dir / 'labels' / p.stem) + ('' if dataset.mode == 'image' else f'_{frame}') # img.txt
|
| 129 |
+
s += '%gx%g ' % img.shape[2:] # print string
|
| 130 |
+
gn = torch.tensor(im0.shape)[[1, 0, 1, 0]] # normalization gain whwh
|
| 131 |
+
if len(det):
|
| 132 |
+
# Rescale boxes from img_size to im0 size
|
| 133 |
+
det[:, :4] = scale_coords(img.shape[2:], det[:, :4], im0.shape).round()
|
| 134 |
+
|
| 135 |
+
# Print results
|
| 136 |
+
for c in det[:, -1].unique():
|
| 137 |
+
n = (det[:, -1] == c).sum() # detections per class
|
| 138 |
+
s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string
|
| 139 |
+
|
| 140 |
+
# Write results
|
| 141 |
+
for *xyxy, conf, cls in reversed(det):
|
| 142 |
+
x1, y1, x2, y2 = int(xyxy[0]), int(xyxy[1]), int(xyxy[2]), int(xyxy[3])
|
| 143 |
+
xyxy_pred.append({'x1': x1, 'y1': y1, 'x2': x2, 'y2': y2})
|
| 144 |
+
if save_txt: # Write to file
|
| 145 |
+
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
| 146 |
+
line = (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label format
|
| 147 |
+
with open(txt_path + '.txt', 'a') as f:
|
| 148 |
+
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
| 149 |
+
|
| 150 |
+
if save_img or view_img: # Add bbox to image
|
| 151 |
+
label = f'{names[int(cls)]} {conf:.2f}'
|
| 152 |
+
plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=3)
|
| 153 |
+
print('---xyxy: ', xyxy)
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
# Print time (inference + NMS)
|
| 157 |
+
#print(f'{s}Done. ({t2 - t1:.3f}s)')
|
| 158 |
+
|
| 159 |
+
# Stream results
|
| 160 |
+
if view_img:
|
| 161 |
+
cv2.imshow(str(p), im0)
|
| 162 |
+
cv2.waitKey(1) # 1 millisecond
|
| 163 |
+
|
| 164 |
+
# Save results (image with detections)
|
| 165 |
+
if save_img:
|
| 166 |
+
if dataset.mode == 'image':
|
| 167 |
+
cv2.imwrite(save_path, im0)
|
| 168 |
+
else: # 'video' or 'stream'
|
| 169 |
+
if vid_path != save_path: # new video
|
| 170 |
+
vid_path = save_path
|
| 171 |
+
if isinstance(vid_writer, cv2.VideoWriter):
|
| 172 |
+
vid_writer.release() # release previous video writer
|
| 173 |
+
if vid_cap: # video
|
| 174 |
+
fps = vid_cap.get(cv2.CAP_PROP_FPS)
|
| 175 |
+
w = int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 176 |
+
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 177 |
+
else: # stream
|
| 178 |
+
fps, w, h = 30, im0.shape[1], im0.shape[0]
|
| 179 |
+
save_path += '.mp4'
|
| 180 |
+
vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
|
| 181 |
+
vid_writer.write(im0)
|
| 182 |
+
|
| 183 |
+
print(f'Done. ({time.time() - t0:.3f}s)')
|
| 184 |
+
|
| 185 |
+
return Image.fromarray(im0[:,:,::-1]), xyxy_pred
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
iface = gr.Interface(fn=detect, inputs=[gr.Image(type="pil"), gr.Dropdown(['V1', 'V2'], label='Weight', value='V2')], outputs=[gr.Image(type='pil'), 'json'], description='BIB Race Number Detection')
|
| 190 |
+
iface.launch()
|
detection/cfg/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
detection/cfg/baseline/r50-csp.yaml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# CSP-ResNet backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Stem, [128]], # 0-P1/2
|
| 16 |
+
[-1, 3, ResCSPC, [128]],
|
| 17 |
+
[-1, 1, Conv, [256, 3, 2]], # 2-P3/8
|
| 18 |
+
[-1, 4, ResCSPC, [256]],
|
| 19 |
+
[-1, 1, Conv, [512, 3, 2]], # 4-P3/8
|
| 20 |
+
[-1, 6, ResCSPC, [512]],
|
| 21 |
+
[-1, 1, Conv, [1024, 3, 2]], # 6-P3/8
|
| 22 |
+
[-1, 3, ResCSPC, [1024]], # 7
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
# CSP-Res-PAN head
|
| 26 |
+
head:
|
| 27 |
+
[[-1, 1, SPPCSPC, [512]], # 8
|
| 28 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 29 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 30 |
+
[5, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 31 |
+
[[-1, -2], 1, Concat, [1]],
|
| 32 |
+
[-1, 2, ResCSPB, [256]], # 13
|
| 33 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 34 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 35 |
+
[3, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 36 |
+
[[-1, -2], 1, Concat, [1]],
|
| 37 |
+
[-1, 2, ResCSPB, [128]], # 18
|
| 38 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 39 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 40 |
+
[[-1, 13], 1, Concat, [1]], # cat
|
| 41 |
+
[-1, 2, ResCSPB, [256]], # 22
|
| 42 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 43 |
+
[-2, 1, Conv, [512, 3, 2]],
|
| 44 |
+
[[-1, 8], 1, Concat, [1]], # cat
|
| 45 |
+
[-1, 2, ResCSPB, [512]], # 26
|
| 46 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 47 |
+
|
| 48 |
+
[[19,23,27], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 49 |
+
]
|
detection/cfg/baseline/x50-csp.yaml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# CSP-ResNeXt backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Stem, [128]], # 0-P1/2
|
| 16 |
+
[-1, 3, ResXCSPC, [128]],
|
| 17 |
+
[-1, 1, Conv, [256, 3, 2]], # 2-P3/8
|
| 18 |
+
[-1, 4, ResXCSPC, [256]],
|
| 19 |
+
[-1, 1, Conv, [512, 3, 2]], # 4-P3/8
|
| 20 |
+
[-1, 6, ResXCSPC, [512]],
|
| 21 |
+
[-1, 1, Conv, [1024, 3, 2]], # 6-P3/8
|
| 22 |
+
[-1, 3, ResXCSPC, [1024]], # 7
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
# CSP-ResX-PAN head
|
| 26 |
+
head:
|
| 27 |
+
[[-1, 1, SPPCSPC, [512]], # 8
|
| 28 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 29 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 30 |
+
[5, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 31 |
+
[[-1, -2], 1, Concat, [1]],
|
| 32 |
+
[-1, 2, ResXCSPB, [256]], # 13
|
| 33 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 34 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 35 |
+
[3, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 36 |
+
[[-1, -2], 1, Concat, [1]],
|
| 37 |
+
[-1, 2, ResXCSPB, [128]], # 18
|
| 38 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 39 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 40 |
+
[[-1, 13], 1, Concat, [1]], # cat
|
| 41 |
+
[-1, 2, ResXCSPB, [256]], # 22
|
| 42 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 43 |
+
[-2, 1, Conv, [512, 3, 2]],
|
| 44 |
+
[[-1, 8], 1, Concat, [1]], # cat
|
| 45 |
+
[-1, 2, ResXCSPB, [512]], # 26
|
| 46 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 47 |
+
|
| 48 |
+
[[19,23,27], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 49 |
+
]
|
detection/cfg/baseline/yolor-csp-x.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.33 # model depth multiple
|
| 4 |
+
width_multiple: 1.25 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# CSP-Darknet backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 17 |
+
[-1, 1, Bottleneck, [64]],
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 19 |
+
[-1, 2, BottleneckCSPC, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 5-P3/8
|
| 21 |
+
[-1, 8, BottleneckCSPC, [256]],
|
| 22 |
+
[-1, 1, Conv, [512, 3, 2]], # 7-P4/16
|
| 23 |
+
[-1, 8, BottleneckCSPC, [512]],
|
| 24 |
+
[-1, 1, Conv, [1024, 3, 2]], # 9-P5/32
|
| 25 |
+
[-1, 4, BottleneckCSPC, [1024]], # 10
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# CSP-Dark-PAN head
|
| 29 |
+
head:
|
| 30 |
+
[[-1, 1, SPPCSPC, [512]], # 11
|
| 31 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 32 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 33 |
+
[8, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 34 |
+
[[-1, -2], 1, Concat, [1]],
|
| 35 |
+
[-1, 2, BottleneckCSPB, [256]], # 16
|
| 36 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 37 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 38 |
+
[6, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 39 |
+
[[-1, -2], 1, Concat, [1]],
|
| 40 |
+
[-1, 2, BottleneckCSPB, [128]], # 21
|
| 41 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 42 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 43 |
+
[[-1, 16], 1, Concat, [1]], # cat
|
| 44 |
+
[-1, 2, BottleneckCSPB, [256]], # 25
|
| 45 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 46 |
+
[-2, 1, Conv, [512, 3, 2]],
|
| 47 |
+
[[-1, 11], 1, Concat, [1]], # cat
|
| 48 |
+
[-1, 2, BottleneckCSPB, [512]], # 29
|
| 49 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 50 |
+
|
| 51 |
+
[[22,26,30], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 52 |
+
]
|
detection/cfg/baseline/yolor-csp.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# CSP-Darknet backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 17 |
+
[-1, 1, Bottleneck, [64]],
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 19 |
+
[-1, 2, BottleneckCSPC, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 5-P3/8
|
| 21 |
+
[-1, 8, BottleneckCSPC, [256]],
|
| 22 |
+
[-1, 1, Conv, [512, 3, 2]], # 7-P4/16
|
| 23 |
+
[-1, 8, BottleneckCSPC, [512]],
|
| 24 |
+
[-1, 1, Conv, [1024, 3, 2]], # 9-P5/32
|
| 25 |
+
[-1, 4, BottleneckCSPC, [1024]], # 10
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# CSP-Dark-PAN head
|
| 29 |
+
head:
|
| 30 |
+
[[-1, 1, SPPCSPC, [512]], # 11
|
| 31 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 32 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 33 |
+
[8, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 34 |
+
[[-1, -2], 1, Concat, [1]],
|
| 35 |
+
[-1, 2, BottleneckCSPB, [256]], # 16
|
| 36 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 37 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 38 |
+
[6, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 39 |
+
[[-1, -2], 1, Concat, [1]],
|
| 40 |
+
[-1, 2, BottleneckCSPB, [128]], # 21
|
| 41 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 42 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 43 |
+
[[-1, 16], 1, Concat, [1]], # cat
|
| 44 |
+
[-1, 2, BottleneckCSPB, [256]], # 25
|
| 45 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 46 |
+
[-2, 1, Conv, [512, 3, 2]],
|
| 47 |
+
[[-1, 11], 1, Concat, [1]], # cat
|
| 48 |
+
[-1, 2, BottleneckCSPB, [512]], # 29
|
| 49 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 50 |
+
|
| 51 |
+
[[22,26,30], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 52 |
+
]
|
detection/cfg/baseline/yolor-d6.yaml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # expand model depth
|
| 4 |
+
width_multiple: 1.25 # expand layer channels
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# CSP-Darknet backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args]
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [64, 3, 1]], # 1-P1/2
|
| 18 |
+
[-1, 1, DownC, [128]], # 2-P2/4
|
| 19 |
+
[-1, 3, BottleneckCSPA, [128]],
|
| 20 |
+
[-1, 1, DownC, [256]], # 4-P3/8
|
| 21 |
+
[-1, 15, BottleneckCSPA, [256]],
|
| 22 |
+
[-1, 1, DownC, [512]], # 6-P4/16
|
| 23 |
+
[-1, 15, BottleneckCSPA, [512]],
|
| 24 |
+
[-1, 1, DownC, [768]], # 8-P5/32
|
| 25 |
+
[-1, 7, BottleneckCSPA, [768]],
|
| 26 |
+
[-1, 1, DownC, [1024]], # 10-P6/64
|
| 27 |
+
[-1, 7, BottleneckCSPA, [1024]], # 11
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
# CSP-Dark-PAN head
|
| 31 |
+
head:
|
| 32 |
+
[[-1, 1, SPPCSPC, [512]], # 12
|
| 33 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 34 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 35 |
+
[-6, 1, Conv, [384, 1, 1]], # route backbone P5
|
| 36 |
+
[[-1, -2], 1, Concat, [1]],
|
| 37 |
+
[-1, 3, BottleneckCSPB, [384]], # 17
|
| 38 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 39 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 40 |
+
[-13, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 41 |
+
[[-1, -2], 1, Concat, [1]],
|
| 42 |
+
[-1, 3, BottleneckCSPB, [256]], # 22
|
| 43 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 44 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 45 |
+
[-20, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 46 |
+
[[-1, -2], 1, Concat, [1]],
|
| 47 |
+
[-1, 3, BottleneckCSPB, [128]], # 27
|
| 48 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 49 |
+
[-2, 1, DownC, [256]],
|
| 50 |
+
[[-1, 22], 1, Concat, [1]], # cat
|
| 51 |
+
[-1, 3, BottleneckCSPB, [256]], # 31
|
| 52 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 53 |
+
[-2, 1, DownC, [384]],
|
| 54 |
+
[[-1, 17], 1, Concat, [1]], # cat
|
| 55 |
+
[-1, 3, BottleneckCSPB, [384]], # 35
|
| 56 |
+
[-1, 1, Conv, [768, 3, 1]],
|
| 57 |
+
[-2, 1, DownC, [512]],
|
| 58 |
+
[[-1, 12], 1, Concat, [1]], # cat
|
| 59 |
+
[-1, 3, BottleneckCSPB, [512]], # 39
|
| 60 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 61 |
+
|
| 62 |
+
[[28,32,36,40], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 63 |
+
]
|
detection/cfg/baseline/yolor-e6.yaml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # expand model depth
|
| 4 |
+
width_multiple: 1.25 # expand layer channels
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# CSP-Darknet backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args]
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [64, 3, 1]], # 1-P1/2
|
| 18 |
+
[-1, 1, DownC, [128]], # 2-P2/4
|
| 19 |
+
[-1, 3, BottleneckCSPA, [128]],
|
| 20 |
+
[-1, 1, DownC, [256]], # 4-P3/8
|
| 21 |
+
[-1, 7, BottleneckCSPA, [256]],
|
| 22 |
+
[-1, 1, DownC, [512]], # 6-P4/16
|
| 23 |
+
[-1, 7, BottleneckCSPA, [512]],
|
| 24 |
+
[-1, 1, DownC, [768]], # 8-P5/32
|
| 25 |
+
[-1, 3, BottleneckCSPA, [768]],
|
| 26 |
+
[-1, 1, DownC, [1024]], # 10-P6/64
|
| 27 |
+
[-1, 3, BottleneckCSPA, [1024]], # 11
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
# CSP-Dark-PAN head
|
| 31 |
+
head:
|
| 32 |
+
[[-1, 1, SPPCSPC, [512]], # 12
|
| 33 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 34 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 35 |
+
[-6, 1, Conv, [384, 1, 1]], # route backbone P5
|
| 36 |
+
[[-1, -2], 1, Concat, [1]],
|
| 37 |
+
[-1, 3, BottleneckCSPB, [384]], # 17
|
| 38 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 39 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 40 |
+
[-13, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 41 |
+
[[-1, -2], 1, Concat, [1]],
|
| 42 |
+
[-1, 3, BottleneckCSPB, [256]], # 22
|
| 43 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 44 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 45 |
+
[-20, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 46 |
+
[[-1, -2], 1, Concat, [1]],
|
| 47 |
+
[-1, 3, BottleneckCSPB, [128]], # 27
|
| 48 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 49 |
+
[-2, 1, DownC, [256]],
|
| 50 |
+
[[-1, 22], 1, Concat, [1]], # cat
|
| 51 |
+
[-1, 3, BottleneckCSPB, [256]], # 31
|
| 52 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 53 |
+
[-2, 1, DownC, [384]],
|
| 54 |
+
[[-1, 17], 1, Concat, [1]], # cat
|
| 55 |
+
[-1, 3, BottleneckCSPB, [384]], # 35
|
| 56 |
+
[-1, 1, Conv, [768, 3, 1]],
|
| 57 |
+
[-2, 1, DownC, [512]],
|
| 58 |
+
[[-1, 12], 1, Concat, [1]], # cat
|
| 59 |
+
[-1, 3, BottleneckCSPB, [512]], # 39
|
| 60 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 61 |
+
|
| 62 |
+
[[28,32,36,40], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 63 |
+
]
|
detection/cfg/baseline/yolor-p6.yaml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # expand model depth
|
| 4 |
+
width_multiple: 1.0 # expand layer channels
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# CSP-Darknet backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args]
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [64, 3, 1]], # 1-P1/2
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 2-P2/4
|
| 19 |
+
[-1, 3, BottleneckCSPA, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 4-P3/8
|
| 21 |
+
[-1, 7, BottleneckCSPA, [256]],
|
| 22 |
+
[-1, 1, Conv, [384, 3, 2]], # 6-P4/16
|
| 23 |
+
[-1, 7, BottleneckCSPA, [384]],
|
| 24 |
+
[-1, 1, Conv, [512, 3, 2]], # 8-P5/32
|
| 25 |
+
[-1, 3, BottleneckCSPA, [512]],
|
| 26 |
+
[-1, 1, Conv, [640, 3, 2]], # 10-P6/64
|
| 27 |
+
[-1, 3, BottleneckCSPA, [640]], # 11
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
# CSP-Dark-PAN head
|
| 31 |
+
head:
|
| 32 |
+
[[-1, 1, SPPCSPC, [320]], # 12
|
| 33 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 34 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 35 |
+
[-6, 1, Conv, [256, 1, 1]], # route backbone P5
|
| 36 |
+
[[-1, -2], 1, Concat, [1]],
|
| 37 |
+
[-1, 3, BottleneckCSPB, [256]], # 17
|
| 38 |
+
[-1, 1, Conv, [192, 1, 1]],
|
| 39 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 40 |
+
[-13, 1, Conv, [192, 1, 1]], # route backbone P4
|
| 41 |
+
[[-1, -2], 1, Concat, [1]],
|
| 42 |
+
[-1, 3, BottleneckCSPB, [192]], # 22
|
| 43 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 44 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 45 |
+
[-20, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 46 |
+
[[-1, -2], 1, Concat, [1]],
|
| 47 |
+
[-1, 3, BottleneckCSPB, [128]], # 27
|
| 48 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 49 |
+
[-2, 1, Conv, [192, 3, 2]],
|
| 50 |
+
[[-1, 22], 1, Concat, [1]], # cat
|
| 51 |
+
[-1, 3, BottleneckCSPB, [192]], # 31
|
| 52 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 53 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 54 |
+
[[-1, 17], 1, Concat, [1]], # cat
|
| 55 |
+
[-1, 3, BottleneckCSPB, [256]], # 35
|
| 56 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 57 |
+
[-2, 1, Conv, [320, 3, 2]],
|
| 58 |
+
[[-1, 12], 1, Concat, [1]], # cat
|
| 59 |
+
[-1, 3, BottleneckCSPB, [320]], # 39
|
| 60 |
+
[-1, 1, Conv, [640, 3, 1]],
|
| 61 |
+
|
| 62 |
+
[[28,32,36,40], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 63 |
+
]
|
detection/cfg/baseline/yolor-w6.yaml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # expand model depth
|
| 4 |
+
width_multiple: 1.0 # expand layer channels
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# CSP-Darknet backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args]
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [64, 3, 1]], # 1-P1/2
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 2-P2/4
|
| 19 |
+
[-1, 3, BottleneckCSPA, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 4-P3/8
|
| 21 |
+
[-1, 7, BottleneckCSPA, [256]],
|
| 22 |
+
[-1, 1, Conv, [512, 3, 2]], # 6-P4/16
|
| 23 |
+
[-1, 7, BottleneckCSPA, [512]],
|
| 24 |
+
[-1, 1, Conv, [768, 3, 2]], # 8-P5/32
|
| 25 |
+
[-1, 3, BottleneckCSPA, [768]],
|
| 26 |
+
[-1, 1, Conv, [1024, 3, 2]], # 10-P6/64
|
| 27 |
+
[-1, 3, BottleneckCSPA, [1024]], # 11
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
# CSP-Dark-PAN head
|
| 31 |
+
head:
|
| 32 |
+
[[-1, 1, SPPCSPC, [512]], # 12
|
| 33 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 34 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 35 |
+
[-6, 1, Conv, [384, 1, 1]], # route backbone P5
|
| 36 |
+
[[-1, -2], 1, Concat, [1]],
|
| 37 |
+
[-1, 3, BottleneckCSPB, [384]], # 17
|
| 38 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 39 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 40 |
+
[-13, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 41 |
+
[[-1, -2], 1, Concat, [1]],
|
| 42 |
+
[-1, 3, BottleneckCSPB, [256]], # 22
|
| 43 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 44 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 45 |
+
[-20, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 46 |
+
[[-1, -2], 1, Concat, [1]],
|
| 47 |
+
[-1, 3, BottleneckCSPB, [128]], # 27
|
| 48 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 49 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 50 |
+
[[-1, 22], 1, Concat, [1]], # cat
|
| 51 |
+
[-1, 3, BottleneckCSPB, [256]], # 31
|
| 52 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 53 |
+
[-2, 1, Conv, [384, 3, 2]],
|
| 54 |
+
[[-1, 17], 1, Concat, [1]], # cat
|
| 55 |
+
[-1, 3, BottleneckCSPB, [384]], # 35
|
| 56 |
+
[-1, 1, Conv, [768, 3, 1]],
|
| 57 |
+
[-2, 1, Conv, [512, 3, 2]],
|
| 58 |
+
[[-1, 12], 1, Concat, [1]], # cat
|
| 59 |
+
[-1, 3, BottleneckCSPB, [512]], # 39
|
| 60 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 61 |
+
|
| 62 |
+
[[28,32,36,40], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 63 |
+
]
|
detection/cfg/baseline/yolov3-spp.yaml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [10,13, 16,30, 33,23] # P3/8
|
| 9 |
+
- [30,61, 62,45, 59,119] # P4/16
|
| 10 |
+
- [116,90, 156,198, 373,326] # P5/32
|
| 11 |
+
|
| 12 |
+
# darknet53 backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 17 |
+
[-1, 1, Bottleneck, [64]],
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 19 |
+
[-1, 2, Bottleneck, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 5-P3/8
|
| 21 |
+
[-1, 8, Bottleneck, [256]],
|
| 22 |
+
[-1, 1, Conv, [512, 3, 2]], # 7-P4/16
|
| 23 |
+
[-1, 8, Bottleneck, [512]],
|
| 24 |
+
[-1, 1, Conv, [1024, 3, 2]], # 9-P5/32
|
| 25 |
+
[-1, 4, Bottleneck, [1024]], # 10
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# YOLOv3-SPP head
|
| 29 |
+
head:
|
| 30 |
+
[[-1, 1, Bottleneck, [1024, False]],
|
| 31 |
+
[-1, 1, SPP, [512, [5, 9, 13]]],
|
| 32 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 33 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 34 |
+
[-1, 1, Conv, [1024, 3, 1]], # 15 (P5/32-large)
|
| 35 |
+
|
| 36 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 37 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 38 |
+
[[-1, 8], 1, Concat, [1]], # cat backbone P4
|
| 39 |
+
[-1, 1, Bottleneck, [512, False]],
|
| 40 |
+
[-1, 1, Bottleneck, [512, False]],
|
| 41 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 42 |
+
[-1, 1, Conv, [512, 3, 1]], # 22 (P4/16-medium)
|
| 43 |
+
|
| 44 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 45 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 46 |
+
[[-1, 6], 1, Concat, [1]], # cat backbone P3
|
| 47 |
+
[-1, 1, Bottleneck, [256, False]],
|
| 48 |
+
[-1, 2, Bottleneck, [256, False]], # 27 (P3/8-small)
|
| 49 |
+
|
| 50 |
+
[[27, 22, 15], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 51 |
+
]
|
detection/cfg/baseline/yolov3.yaml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [10,13, 16,30, 33,23] # P3/8
|
| 9 |
+
- [30,61, 62,45, 59,119] # P4/16
|
| 10 |
+
- [116,90, 156,198, 373,326] # P5/32
|
| 11 |
+
|
| 12 |
+
# darknet53 backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 17 |
+
[-1, 1, Bottleneck, [64]],
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 19 |
+
[-1, 2, Bottleneck, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 5-P3/8
|
| 21 |
+
[-1, 8, Bottleneck, [256]],
|
| 22 |
+
[-1, 1, Conv, [512, 3, 2]], # 7-P4/16
|
| 23 |
+
[-1, 8, Bottleneck, [512]],
|
| 24 |
+
[-1, 1, Conv, [1024, 3, 2]], # 9-P5/32
|
| 25 |
+
[-1, 4, Bottleneck, [1024]], # 10
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# YOLOv3 head
|
| 29 |
+
head:
|
| 30 |
+
[[-1, 1, Bottleneck, [1024, False]],
|
| 31 |
+
[-1, 1, Conv, [512, [1, 1]]],
|
| 32 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 33 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 34 |
+
[-1, 1, Conv, [1024, 3, 1]], # 15 (P5/32-large)
|
| 35 |
+
|
| 36 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 37 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 38 |
+
[[-1, 8], 1, Concat, [1]], # cat backbone P4
|
| 39 |
+
[-1, 1, Bottleneck, [512, False]],
|
| 40 |
+
[-1, 1, Bottleneck, [512, False]],
|
| 41 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 42 |
+
[-1, 1, Conv, [512, 3, 1]], # 22 (P4/16-medium)
|
| 43 |
+
|
| 44 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 45 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 46 |
+
[[-1, 6], 1, Concat, [1]], # cat backbone P3
|
| 47 |
+
[-1, 1, Bottleneck, [256, False]],
|
| 48 |
+
[-1, 2, Bottleneck, [256, False]], # 27 (P3/8-small)
|
| 49 |
+
|
| 50 |
+
[[27, 22, 15], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 51 |
+
]
|
detection/cfg/baseline/yolov4-csp.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# CSP-Darknet backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 17 |
+
[-1, 1, Bottleneck, [64]],
|
| 18 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 19 |
+
[-1, 2, BottleneckCSPC, [128]],
|
| 20 |
+
[-1, 1, Conv, [256, 3, 2]], # 5-P3/8
|
| 21 |
+
[-1, 8, BottleneckCSPC, [256]],
|
| 22 |
+
[-1, 1, Conv, [512, 3, 2]], # 7-P4/16
|
| 23 |
+
[-1, 8, BottleneckCSPC, [512]],
|
| 24 |
+
[-1, 1, Conv, [1024, 3, 2]], # 9-P5/32
|
| 25 |
+
[-1, 4, BottleneckCSPC, [1024]], # 10
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
# CSP-Dark-PAN head
|
| 29 |
+
head:
|
| 30 |
+
[[-1, 1, SPPCSPC, [512]], # 11
|
| 31 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 32 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 33 |
+
[8, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 34 |
+
[[-1, -2], 1, Concat, [1]],
|
| 35 |
+
[-1, 2, BottleneckCSPB, [256]], # 16
|
| 36 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 37 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 38 |
+
[6, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 39 |
+
[[-1, -2], 1, Concat, [1]],
|
| 40 |
+
[-1, 2, BottleneckCSPB, [128]], # 21
|
| 41 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 42 |
+
[-2, 1, Conv, [256, 3, 2]],
|
| 43 |
+
[[-1, 16], 1, Concat, [1]], # cat
|
| 44 |
+
[-1, 2, BottleneckCSPB, [256]], # 25
|
| 45 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 46 |
+
[-2, 1, Conv, [512, 3, 2]],
|
| 47 |
+
[[-1, 11], 1, Concat, [1]], # cat
|
| 48 |
+
[-1, 2, BottleneckCSPB, [512]], # 29
|
| 49 |
+
[-1, 1, Conv, [1024, 3, 1]],
|
| 50 |
+
|
| 51 |
+
[[22,26,30], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 52 |
+
]
|
detection/cfg/deploy/yolov7-d6.yaml
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7-d6 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args],
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [96, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, DownC, [192]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 29 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 30 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 31 |
+
[-1, 1, Conv, [192, 1, 1]], # 14
|
| 32 |
+
|
| 33 |
+
[-1, 1, DownC, [384]], # 15-P3/8
|
| 34 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 35 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 36 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 41 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 42 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 43 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 44 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 45 |
+
[-1, 1, Conv, [384, 1, 1]], # 27
|
| 46 |
+
|
| 47 |
+
[-1, 1, DownC, [768]], # 28-P4/16
|
| 48 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 49 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 50 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 51 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 52 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 53 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 54 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 55 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 56 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 57 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 58 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 59 |
+
[-1, 1, Conv, [768, 1, 1]], # 40
|
| 60 |
+
|
| 61 |
+
[-1, 1, DownC, [1152]], # 41-P5/32
|
| 62 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 63 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 64 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 65 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 66 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 67 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 68 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 69 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 70 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 72 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 73 |
+
[-1, 1, Conv, [1152, 1, 1]], # 53
|
| 74 |
+
|
| 75 |
+
[-1, 1, DownC, [1536]], # 54-P6/64
|
| 76 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 77 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 78 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 79 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 80 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 81 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 82 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 84 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 85 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 86 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 87 |
+
[-1, 1, Conv, [1536, 1, 1]], # 66
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
# yolov7-d6 head
|
| 91 |
+
head:
|
| 92 |
+
[[-1, 1, SPPCSPC, [768]], # 67
|
| 93 |
+
|
| 94 |
+
[-1, 1, Conv, [576, 1, 1]],
|
| 95 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 96 |
+
[53, 1, Conv, [576, 1, 1]], # route backbone P5
|
| 97 |
+
[[-1, -2], 1, Concat, [1]],
|
| 98 |
+
|
| 99 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 100 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 101 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 102 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 103 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 104 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 105 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 106 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 107 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 108 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 109 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 110 |
+
[-1, 1, Conv, [576, 1, 1]], # 83
|
| 111 |
+
|
| 112 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 113 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 114 |
+
[40, 1, Conv, [384, 1, 1]], # route backbone P4
|
| 115 |
+
[[-1, -2], 1, Concat, [1]],
|
| 116 |
+
|
| 117 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 118 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 119 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 120 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 121 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 122 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 123 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 124 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 125 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 127 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 128 |
+
[-1, 1, Conv, [384, 1, 1]], # 99
|
| 129 |
+
|
| 130 |
+
[-1, 1, Conv, [192, 1, 1]],
|
| 131 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 132 |
+
[27, 1, Conv, [192, 1, 1]], # route backbone P3
|
| 133 |
+
[[-1, -2], 1, Concat, [1]],
|
| 134 |
+
|
| 135 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 136 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 137 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 138 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 139 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 140 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 141 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 142 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 143 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 144 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 145 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 146 |
+
[-1, 1, Conv, [192, 1, 1]], # 115
|
| 147 |
+
|
| 148 |
+
[-1, 1, DownC, [384]],
|
| 149 |
+
[[-1, 99], 1, Concat, [1]],
|
| 150 |
+
|
| 151 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 152 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 153 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 154 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 155 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 156 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 157 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 158 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 159 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 160 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 161 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 162 |
+
[-1, 1, Conv, [384, 1, 1]], # 129
|
| 163 |
+
|
| 164 |
+
[-1, 1, DownC, [576]],
|
| 165 |
+
[[-1, 83], 1, Concat, [1]],
|
| 166 |
+
|
| 167 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 168 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 169 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 170 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 171 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 172 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 173 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 174 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 175 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 176 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 177 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 178 |
+
[-1, 1, Conv, [576, 1, 1]], # 143
|
| 179 |
+
|
| 180 |
+
[-1, 1, DownC, [768]],
|
| 181 |
+
[[-1, 67], 1, Concat, [1]],
|
| 182 |
+
|
| 183 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 184 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 185 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 186 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 187 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 188 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 189 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 190 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 191 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 192 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 193 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 194 |
+
[-1, 1, Conv, [768, 1, 1]], # 157
|
| 195 |
+
|
| 196 |
+
[115, 1, Conv, [384, 3, 1]],
|
| 197 |
+
[129, 1, Conv, [768, 3, 1]],
|
| 198 |
+
[143, 1, Conv, [1152, 3, 1]],
|
| 199 |
+
[157, 1, Conv, [1536, 3, 1]],
|
| 200 |
+
|
| 201 |
+
[[158,159,160,161], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 202 |
+
]
|
detection/cfg/deploy/yolov7-e6.yaml
ADDED
|
@@ -0,0 +1,180 @@
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7-e6 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args],
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [80, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, DownC, [160]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 29 |
+
[-1, 1, Conv, [160, 1, 1]], # 12
|
| 30 |
+
|
| 31 |
+
[-1, 1, DownC, [320]], # 13-P3/8
|
| 32 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 33 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 34 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 35 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 36 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 41 |
+
[-1, 1, Conv, [320, 1, 1]], # 23
|
| 42 |
+
|
| 43 |
+
[-1, 1, DownC, [640]], # 24-P4/16
|
| 44 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 45 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 46 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 47 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 48 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 49 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 50 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 51 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 52 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 53 |
+
[-1, 1, Conv, [640, 1, 1]], # 34
|
| 54 |
+
|
| 55 |
+
[-1, 1, DownC, [960]], # 35-P5/32
|
| 56 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 57 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 58 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 59 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 60 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 61 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 62 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 63 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 64 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 65 |
+
[-1, 1, Conv, [960, 1, 1]], # 45
|
| 66 |
+
|
| 67 |
+
[-1, 1, DownC, [1280]], # 46-P6/64
|
| 68 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 69 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 70 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 72 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 73 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 74 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 75 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 76 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 77 |
+
[-1, 1, Conv, [1280, 1, 1]], # 56
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
# yolov7-e6 head
|
| 81 |
+
head:
|
| 82 |
+
[[-1, 1, SPPCSPC, [640]], # 57
|
| 83 |
+
|
| 84 |
+
[-1, 1, Conv, [480, 1, 1]],
|
| 85 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 86 |
+
[45, 1, Conv, [480, 1, 1]], # route backbone P5
|
| 87 |
+
[[-1, -2], 1, Concat, [1]],
|
| 88 |
+
|
| 89 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 90 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 91 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 92 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 94 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 95 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 97 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 98 |
+
[-1, 1, Conv, [480, 1, 1]], # 71
|
| 99 |
+
|
| 100 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 101 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 102 |
+
[34, 1, Conv, [320, 1, 1]], # route backbone P4
|
| 103 |
+
[[-1, -2], 1, Concat, [1]],
|
| 104 |
+
|
| 105 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 106 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 107 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 108 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 109 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 110 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 111 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 112 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 113 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 114 |
+
[-1, 1, Conv, [320, 1, 1]], # 85
|
| 115 |
+
|
| 116 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 117 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 118 |
+
[23, 1, Conv, [160, 1, 1]], # route backbone P3
|
| 119 |
+
[[-1, -2], 1, Concat, [1]],
|
| 120 |
+
|
| 121 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 122 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 123 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 124 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 125 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 127 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 128 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 129 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 130 |
+
[-1, 1, Conv, [160, 1, 1]], # 99
|
| 131 |
+
|
| 132 |
+
[-1, 1, DownC, [320]],
|
| 133 |
+
[[-1, 85], 1, Concat, [1]],
|
| 134 |
+
|
| 135 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 136 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 137 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 138 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 139 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 140 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 141 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 142 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 143 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 144 |
+
[-1, 1, Conv, [320, 1, 1]], # 111
|
| 145 |
+
|
| 146 |
+
[-1, 1, DownC, [480]],
|
| 147 |
+
[[-1, 71], 1, Concat, [1]],
|
| 148 |
+
|
| 149 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 150 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 151 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 152 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 153 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 154 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 155 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 156 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 157 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 158 |
+
[-1, 1, Conv, [480, 1, 1]], # 123
|
| 159 |
+
|
| 160 |
+
[-1, 1, DownC, [640]],
|
| 161 |
+
[[-1, 57], 1, Concat, [1]],
|
| 162 |
+
|
| 163 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 164 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 165 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 166 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 167 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 168 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 169 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 170 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 171 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 172 |
+
[-1, 1, Conv, [640, 1, 1]], # 135
|
| 173 |
+
|
| 174 |
+
[99, 1, Conv, [320, 3, 1]],
|
| 175 |
+
[111, 1, Conv, [640, 3, 1]],
|
| 176 |
+
[123, 1, Conv, [960, 3, 1]],
|
| 177 |
+
[135, 1, Conv, [1280, 3, 1]],
|
| 178 |
+
|
| 179 |
+
[[136,137,138,139], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 180 |
+
]
|
detection/cfg/deploy/yolov7-e6e.yaml
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7-e6e backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args],
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [80, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, DownC, [160]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 29 |
+
[-1, 1, Conv, [160, 1, 1]], # 12
|
| 30 |
+
[-11, 1, Conv, [64, 1, 1]],
|
| 31 |
+
[-12, 1, Conv, [64, 1, 1]],
|
| 32 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 33 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 34 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 35 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 36 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 37 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 38 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 39 |
+
[-1, 1, Conv, [160, 1, 1]], # 22
|
| 40 |
+
[[-1, -11], 1, Shortcut, [1]], # 23
|
| 41 |
+
|
| 42 |
+
[-1, 1, DownC, [320]], # 24-P3/8
|
| 43 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 44 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 45 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 46 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 47 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 48 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 49 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 50 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 51 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 52 |
+
[-1, 1, Conv, [320, 1, 1]], # 34
|
| 53 |
+
[-11, 1, Conv, [128, 1, 1]],
|
| 54 |
+
[-12, 1, Conv, [128, 1, 1]],
|
| 55 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 56 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 57 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 58 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 59 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 60 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 61 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 62 |
+
[-1, 1, Conv, [320, 1, 1]], # 44
|
| 63 |
+
[[-1, -11], 1, Shortcut, [1]], # 45
|
| 64 |
+
|
| 65 |
+
[-1, 1, DownC, [640]], # 46-P4/16
|
| 66 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 67 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 68 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 69 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 70 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 72 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 73 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 74 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 75 |
+
[-1, 1, Conv, [640, 1, 1]], # 56
|
| 76 |
+
[-11, 1, Conv, [256, 1, 1]],
|
| 77 |
+
[-12, 1, Conv, [256, 1, 1]],
|
| 78 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 79 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 80 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 81 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 82 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 84 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 85 |
+
[-1, 1, Conv, [640, 1, 1]], # 66
|
| 86 |
+
[[-1, -11], 1, Shortcut, [1]], # 67
|
| 87 |
+
|
| 88 |
+
[-1, 1, DownC, [960]], # 68-P5/32
|
| 89 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 90 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 91 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 92 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 94 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 95 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 97 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 98 |
+
[-1, 1, Conv, [960, 1, 1]], # 78
|
| 99 |
+
[-11, 1, Conv, [384, 1, 1]],
|
| 100 |
+
[-12, 1, Conv, [384, 1, 1]],
|
| 101 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 102 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 103 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 104 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 105 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 106 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 107 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 108 |
+
[-1, 1, Conv, [960, 1, 1]], # 88
|
| 109 |
+
[[-1, -11], 1, Shortcut, [1]], # 89
|
| 110 |
+
|
| 111 |
+
[-1, 1, DownC, [1280]], # 90-P6/64
|
| 112 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 113 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 114 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 115 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 116 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 117 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 118 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 119 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 120 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 121 |
+
[-1, 1, Conv, [1280, 1, 1]], # 100
|
| 122 |
+
[-11, 1, Conv, [512, 1, 1]],
|
| 123 |
+
[-12, 1, Conv, [512, 1, 1]],
|
| 124 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 125 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 127 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 128 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 129 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 130 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 131 |
+
[-1, 1, Conv, [1280, 1, 1]], # 110
|
| 132 |
+
[[-1, -11], 1, Shortcut, [1]], # 111
|
| 133 |
+
]
|
| 134 |
+
|
| 135 |
+
# yolov7-e6e head
|
| 136 |
+
head:
|
| 137 |
+
[[-1, 1, SPPCSPC, [640]], # 112
|
| 138 |
+
|
| 139 |
+
[-1, 1, Conv, [480, 1, 1]],
|
| 140 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 141 |
+
[89, 1, Conv, [480, 1, 1]], # route backbone P5
|
| 142 |
+
[[-1, -2], 1, Concat, [1]],
|
| 143 |
+
|
| 144 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 145 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 146 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 147 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 148 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 149 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 150 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 151 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 152 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 153 |
+
[-1, 1, Conv, [480, 1, 1]], # 126
|
| 154 |
+
[-11, 1, Conv, [384, 1, 1]],
|
| 155 |
+
[-12, 1, Conv, [384, 1, 1]],
|
| 156 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 157 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 158 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 159 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 160 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 161 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 162 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 163 |
+
[-1, 1, Conv, [480, 1, 1]], # 136
|
| 164 |
+
[[-1, -11], 1, Shortcut, [1]], # 137
|
| 165 |
+
|
| 166 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 167 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 168 |
+
[67, 1, Conv, [320, 1, 1]], # route backbone P4
|
| 169 |
+
[[-1, -2], 1, Concat, [1]],
|
| 170 |
+
|
| 171 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 172 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 173 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 174 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 175 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 176 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 177 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 178 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 179 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 180 |
+
[-1, 1, Conv, [320, 1, 1]], # 151
|
| 181 |
+
[-11, 1, Conv, [256, 1, 1]],
|
| 182 |
+
[-12, 1, Conv, [256, 1, 1]],
|
| 183 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 184 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 185 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 186 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 187 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 188 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 189 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 190 |
+
[-1, 1, Conv, [320, 1, 1]], # 161
|
| 191 |
+
[[-1, -11], 1, Shortcut, [1]], # 162
|
| 192 |
+
|
| 193 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 194 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 195 |
+
[45, 1, Conv, [160, 1, 1]], # route backbone P3
|
| 196 |
+
[[-1, -2], 1, Concat, [1]],
|
| 197 |
+
|
| 198 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 199 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 200 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 201 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 202 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 203 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 204 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 205 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 206 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 207 |
+
[-1, 1, Conv, [160, 1, 1]], # 176
|
| 208 |
+
[-11, 1, Conv, [128, 1, 1]],
|
| 209 |
+
[-12, 1, Conv, [128, 1, 1]],
|
| 210 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 211 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 212 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 213 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 214 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 215 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 216 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 217 |
+
[-1, 1, Conv, [160, 1, 1]], # 186
|
| 218 |
+
[[-1, -11], 1, Shortcut, [1]], # 187
|
| 219 |
+
|
| 220 |
+
[-1, 1, DownC, [320]],
|
| 221 |
+
[[-1, 162], 1, Concat, [1]],
|
| 222 |
+
|
| 223 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 224 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 225 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 226 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 227 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 228 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 229 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 230 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 231 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 232 |
+
[-1, 1, Conv, [320, 1, 1]], # 199
|
| 233 |
+
[-11, 1, Conv, [256, 1, 1]],
|
| 234 |
+
[-12, 1, Conv, [256, 1, 1]],
|
| 235 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 236 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 237 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 238 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 239 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 240 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 241 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 242 |
+
[-1, 1, Conv, [320, 1, 1]], # 209
|
| 243 |
+
[[-1, -11], 1, Shortcut, [1]], # 210
|
| 244 |
+
|
| 245 |
+
[-1, 1, DownC, [480]],
|
| 246 |
+
[[-1, 137], 1, Concat, [1]],
|
| 247 |
+
|
| 248 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 249 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 250 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 251 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 252 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 253 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 254 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 255 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 256 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 257 |
+
[-1, 1, Conv, [480, 1, 1]], # 222
|
| 258 |
+
[-11, 1, Conv, [384, 1, 1]],
|
| 259 |
+
[-12, 1, Conv, [384, 1, 1]],
|
| 260 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 261 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 262 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 263 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 264 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 265 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 266 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 267 |
+
[-1, 1, Conv, [480, 1, 1]], # 232
|
| 268 |
+
[[-1, -11], 1, Shortcut, [1]], # 233
|
| 269 |
+
|
| 270 |
+
[-1, 1, DownC, [640]],
|
| 271 |
+
[[-1, 112], 1, Concat, [1]],
|
| 272 |
+
|
| 273 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 274 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 275 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 276 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 277 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 278 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 279 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 280 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 281 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 282 |
+
[-1, 1, Conv, [640, 1, 1]], # 245
|
| 283 |
+
[-11, 1, Conv, [512, 1, 1]],
|
| 284 |
+
[-12, 1, Conv, [512, 1, 1]],
|
| 285 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 286 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 287 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 288 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 289 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 290 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 291 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 292 |
+
[-1, 1, Conv, [640, 1, 1]], # 255
|
| 293 |
+
[[-1, -11], 1, Shortcut, [1]], # 256
|
| 294 |
+
|
| 295 |
+
[187, 1, Conv, [320, 3, 1]],
|
| 296 |
+
[210, 1, Conv, [640, 3, 1]],
|
| 297 |
+
[233, 1, Conv, [960, 3, 1]],
|
| 298 |
+
[256, 1, Conv, [1280, 3, 1]],
|
| 299 |
+
|
| 300 |
+
[[257,258,259,260], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 301 |
+
]
|
detection/cfg/deploy/yolov7-tiny-silu.yaml
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [10,13, 16,30, 33,23] # P3/8
|
| 9 |
+
- [30,61, 62,45, 59,119] # P4/16
|
| 10 |
+
- [116,90, 156,198, 373,326] # P5/32
|
| 11 |
+
|
| 12 |
+
# YOLOv7-tiny backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 2]], # 0-P1/2
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P2/4
|
| 18 |
+
|
| 19 |
+
[-1, 1, Conv, [32, 1, 1]],
|
| 20 |
+
[-2, 1, Conv, [32, 1, 1]],
|
| 21 |
+
[-1, 1, Conv, [32, 3, 1]],
|
| 22 |
+
[-1, 1, Conv, [32, 3, 1]],
|
| 23 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 24 |
+
[-1, 1, Conv, [64, 1, 1]], # 7
|
| 25 |
+
|
| 26 |
+
[-1, 1, MP, []], # 8-P3/8
|
| 27 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 28 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 29 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 30 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 31 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 32 |
+
[-1, 1, Conv, [128, 1, 1]], # 14
|
| 33 |
+
|
| 34 |
+
[-1, 1, MP, []], # 15-P4/16
|
| 35 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 36 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 40 |
+
[-1, 1, Conv, [256, 1, 1]], # 21
|
| 41 |
+
|
| 42 |
+
[-1, 1, MP, []], # 22-P5/32
|
| 43 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 44 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 45 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 46 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 47 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 48 |
+
[-1, 1, Conv, [512, 1, 1]], # 28
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# YOLOv7-tiny head
|
| 52 |
+
head:
|
| 53 |
+
[[-1, 1, Conv, [256, 1, 1]],
|
| 54 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 55 |
+
[-1, 1, SP, [5]],
|
| 56 |
+
[-2, 1, SP, [9]],
|
| 57 |
+
[-3, 1, SP, [13]],
|
| 58 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 59 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 60 |
+
[[-1, -7], 1, Concat, [1]],
|
| 61 |
+
[-1, 1, Conv, [256, 1, 1]], # 37
|
| 62 |
+
|
| 63 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 64 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 65 |
+
[21, 1, Conv, [128, 1, 1]], # route backbone P4
|
| 66 |
+
[[-1, -2], 1, Concat, [1]],
|
| 67 |
+
|
| 68 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 69 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 70 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 72 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 73 |
+
[-1, 1, Conv, [128, 1, 1]], # 47
|
| 74 |
+
|
| 75 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 76 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 77 |
+
[14, 1, Conv, [64, 1, 1]], # route backbone P3
|
| 78 |
+
[[-1, -2], 1, Concat, [1]],
|
| 79 |
+
|
| 80 |
+
[-1, 1, Conv, [32, 1, 1]],
|
| 81 |
+
[-2, 1, Conv, [32, 1, 1]],
|
| 82 |
+
[-1, 1, Conv, [32, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [32, 3, 1]],
|
| 84 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 85 |
+
[-1, 1, Conv, [64, 1, 1]], # 57
|
| 86 |
+
|
| 87 |
+
[-1, 1, Conv, [128, 3, 2]],
|
| 88 |
+
[[-1, 47], 1, Concat, [1]],
|
| 89 |
+
|
| 90 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 91 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 92 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 94 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 95 |
+
[-1, 1, Conv, [128, 1, 1]], # 65
|
| 96 |
+
|
| 97 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 98 |
+
[[-1, 37], 1, Concat, [1]],
|
| 99 |
+
|
| 100 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 101 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 102 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 103 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 104 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 105 |
+
[-1, 1, Conv, [256, 1, 1]], # 73
|
| 106 |
+
|
| 107 |
+
[57, 1, Conv, [128, 3, 1]],
|
| 108 |
+
[65, 1, Conv, [256, 3, 1]],
|
| 109 |
+
[73, 1, Conv, [512, 3, 1]],
|
| 110 |
+
|
| 111 |
+
[[74,75,76], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 112 |
+
]
|
detection/cfg/deploy/yolov7-tiny.yaml
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [10,13, 16,30, 33,23] # P3/8
|
| 9 |
+
- [30,61, 62,45, 59,119] # P4/16
|
| 10 |
+
- [116,90, 156,198, 373,326] # P5/32
|
| 11 |
+
|
| 12 |
+
# yolov7-tiny backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args] c2, k=1, s=1, p=None, g=1, act=True
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 2, None, 1, nn.LeakyReLU(0.1)]], # 0-P1/2
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [64, 3, 2, None, 1, nn.LeakyReLU(0.1)]], # 1-P2/4
|
| 18 |
+
|
| 19 |
+
[-1, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 20 |
+
[-2, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 21 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 22 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 23 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 24 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 7
|
| 25 |
+
|
| 26 |
+
[-1, 1, MP, []], # 8-P3/8
|
| 27 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 28 |
+
[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 29 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 30 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 31 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 32 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 14
|
| 33 |
+
|
| 34 |
+
[-1, 1, MP, []], # 15-P4/16
|
| 35 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 36 |
+
[-2, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 39 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 40 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 21
|
| 41 |
+
|
| 42 |
+
[-1, 1, MP, []], # 22-P5/32
|
| 43 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 44 |
+
[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 45 |
+
[-1, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 46 |
+
[-1, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 47 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 48 |
+
[-1, 1, Conv, [512, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 28
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# yolov7-tiny head
|
| 52 |
+
head:
|
| 53 |
+
[[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 54 |
+
[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 55 |
+
[-1, 1, SP, [5]],
|
| 56 |
+
[-2, 1, SP, [9]],
|
| 57 |
+
[-3, 1, SP, [13]],
|
| 58 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 59 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 60 |
+
[[-1, -7], 1, Concat, [1]],
|
| 61 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 37
|
| 62 |
+
|
| 63 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 64 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 65 |
+
[21, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # route backbone P4
|
| 66 |
+
[[-1, -2], 1, Concat, [1]],
|
| 67 |
+
|
| 68 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 69 |
+
[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 70 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 71 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 72 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 73 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 47
|
| 74 |
+
|
| 75 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 76 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 77 |
+
[14, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # route backbone P3
|
| 78 |
+
[[-1, -2], 1, Concat, [1]],
|
| 79 |
+
|
| 80 |
+
[-1, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 81 |
+
[-2, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 82 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 83 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 84 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 85 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 57
|
| 86 |
+
|
| 87 |
+
[-1, 1, Conv, [128, 3, 2, None, 1, nn.LeakyReLU(0.1)]],
|
| 88 |
+
[[-1, 47], 1, Concat, [1]],
|
| 89 |
+
|
| 90 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 91 |
+
[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 92 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 93 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 94 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 95 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 65
|
| 96 |
+
|
| 97 |
+
[-1, 1, Conv, [256, 3, 2, None, 1, nn.LeakyReLU(0.1)]],
|
| 98 |
+
[[-1, 37], 1, Concat, [1]],
|
| 99 |
+
|
| 100 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 101 |
+
[-2, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 102 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 103 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 104 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 105 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 73
|
| 106 |
+
|
| 107 |
+
[57, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 108 |
+
[65, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 109 |
+
[73, 1, Conv, [512, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 110 |
+
|
| 111 |
+
[[74,75,76], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 112 |
+
]
|
detection/cfg/deploy/yolov7-w6.yaml
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7-w6 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args]
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [64, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, Conv, [128, 3, 2]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 27 |
+
[-1, 1, Conv, [128, 1, 1]], # 10
|
| 28 |
+
|
| 29 |
+
[-1, 1, Conv, [256, 3, 2]], # 11-P3/8
|
| 30 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 31 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 32 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 33 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 34 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 35 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 36 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 37 |
+
[-1, 1, Conv, [256, 1, 1]], # 19
|
| 38 |
+
|
| 39 |
+
[-1, 1, Conv, [512, 3, 2]], # 20-P4/16
|
| 40 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 41 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 42 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 43 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 44 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 45 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 46 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 47 |
+
[-1, 1, Conv, [512, 1, 1]], # 28
|
| 48 |
+
|
| 49 |
+
[-1, 1, Conv, [768, 3, 2]], # 29-P5/32
|
| 50 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 51 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 52 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 53 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 54 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 55 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 56 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 57 |
+
[-1, 1, Conv, [768, 1, 1]], # 37
|
| 58 |
+
|
| 59 |
+
[-1, 1, Conv, [1024, 3, 2]], # 38-P6/64
|
| 60 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 61 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 62 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 63 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 64 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 65 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 66 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 67 |
+
[-1, 1, Conv, [1024, 1, 1]], # 46
|
| 68 |
+
]
|
| 69 |
+
|
| 70 |
+
# yolov7-w6 head
|
| 71 |
+
head:
|
| 72 |
+
[[-1, 1, SPPCSPC, [512]], # 47
|
| 73 |
+
|
| 74 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 75 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 76 |
+
[37, 1, Conv, [384, 1, 1]], # route backbone P5
|
| 77 |
+
[[-1, -2], 1, Concat, [1]],
|
| 78 |
+
|
| 79 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 80 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 81 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 82 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 84 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 85 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 86 |
+
[-1, 1, Conv, [384, 1, 1]], # 59
|
| 87 |
+
|
| 88 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 89 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 90 |
+
[28, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 91 |
+
[[-1, -2], 1, Concat, [1]],
|
| 92 |
+
|
| 93 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 94 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 95 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 97 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 98 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 99 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 100 |
+
[-1, 1, Conv, [256, 1, 1]], # 71
|
| 101 |
+
|
| 102 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 103 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 104 |
+
[19, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 105 |
+
[[-1, -2], 1, Concat, [1]],
|
| 106 |
+
|
| 107 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 108 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 109 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 110 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 111 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 112 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 113 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 114 |
+
[-1, 1, Conv, [128, 1, 1]], # 83
|
| 115 |
+
|
| 116 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 117 |
+
[[-1, 71], 1, Concat, [1]], # cat
|
| 118 |
+
|
| 119 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 120 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 121 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 122 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 123 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 124 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 125 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 126 |
+
[-1, 1, Conv, [256, 1, 1]], # 93
|
| 127 |
+
|
| 128 |
+
[-1, 1, Conv, [384, 3, 2]],
|
| 129 |
+
[[-1, 59], 1, Concat, [1]], # cat
|
| 130 |
+
|
| 131 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 132 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 133 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 134 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 135 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 136 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 137 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 138 |
+
[-1, 1, Conv, [384, 1, 1]], # 103
|
| 139 |
+
|
| 140 |
+
[-1, 1, Conv, [512, 3, 2]],
|
| 141 |
+
[[-1, 47], 1, Concat, [1]], # cat
|
| 142 |
+
|
| 143 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 144 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 145 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 146 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 147 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 148 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 149 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 150 |
+
[-1, 1, Conv, [512, 1, 1]], # 113
|
| 151 |
+
|
| 152 |
+
[83, 1, Conv, [256, 3, 1]],
|
| 153 |
+
[93, 1, Conv, [512, 3, 1]],
|
| 154 |
+
[103, 1, Conv, [768, 3, 1]],
|
| 155 |
+
[113, 1, Conv, [1024, 3, 1]],
|
| 156 |
+
|
| 157 |
+
[[114,115,116,117], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 158 |
+
]
|
detection/cfg/deploy/yolov7.yaml
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# yolov7 backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 18 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 19 |
+
|
| 20 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 21 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 28 |
+
[-1, 1, Conv, [256, 1, 1]], # 11
|
| 29 |
+
|
| 30 |
+
[-1, 1, MP, []],
|
| 31 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 32 |
+
[-3, 1, Conv, [128, 1, 1]],
|
| 33 |
+
[-1, 1, Conv, [128, 3, 2]],
|
| 34 |
+
[[-1, -3], 1, Concat, [1]], # 16-P3/8
|
| 35 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 36 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 41 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 42 |
+
[-1, 1, Conv, [512, 1, 1]], # 24
|
| 43 |
+
|
| 44 |
+
[-1, 1, MP, []],
|
| 45 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 46 |
+
[-3, 1, Conv, [256, 1, 1]],
|
| 47 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 48 |
+
[[-1, -3], 1, Concat, [1]], # 29-P4/16
|
| 49 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 50 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 51 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 52 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 53 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 54 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 55 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 56 |
+
[-1, 1, Conv, [1024, 1, 1]], # 37
|
| 57 |
+
|
| 58 |
+
[-1, 1, MP, []],
|
| 59 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 60 |
+
[-3, 1, Conv, [512, 1, 1]],
|
| 61 |
+
[-1, 1, Conv, [512, 3, 2]],
|
| 62 |
+
[[-1, -3], 1, Concat, [1]], # 42-P5/32
|
| 63 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 64 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 65 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 66 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 67 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 68 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 69 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 70 |
+
[-1, 1, Conv, [1024, 1, 1]], # 50
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
# yolov7 head
|
| 74 |
+
head:
|
| 75 |
+
[[-1, 1, SPPCSPC, [512]], # 51
|
| 76 |
+
|
| 77 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 78 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 79 |
+
[37, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 80 |
+
[[-1, -2], 1, Concat, [1]],
|
| 81 |
+
|
| 82 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 83 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 84 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 85 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 86 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 87 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 88 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 89 |
+
[-1, 1, Conv, [256, 1, 1]], # 63
|
| 90 |
+
|
| 91 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 92 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 93 |
+
[24, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 94 |
+
[[-1, -2], 1, Concat, [1]],
|
| 95 |
+
|
| 96 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 97 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 98 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 99 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 100 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 101 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 102 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 103 |
+
[-1, 1, Conv, [128, 1, 1]], # 75
|
| 104 |
+
|
| 105 |
+
[-1, 1, MP, []],
|
| 106 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 107 |
+
[-3, 1, Conv, [128, 1, 1]],
|
| 108 |
+
[-1, 1, Conv, [128, 3, 2]],
|
| 109 |
+
[[-1, -3, 63], 1, Concat, [1]],
|
| 110 |
+
|
| 111 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 112 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 113 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 114 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 115 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 116 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 117 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 118 |
+
[-1, 1, Conv, [256, 1, 1]], # 88
|
| 119 |
+
|
| 120 |
+
[-1, 1, MP, []],
|
| 121 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 122 |
+
[-3, 1, Conv, [256, 1, 1]],
|
| 123 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 124 |
+
[[-1, -3, 51], 1, Concat, [1]],
|
| 125 |
+
|
| 126 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 127 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 128 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 129 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 130 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 131 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 132 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 133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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# yolov7x backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [40, 3, 1]], # 0
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [80, 3, 2]], # 1-P1/2
|
| 18 |
+
[-1, 1, Conv, [80, 3, 1]],
|
| 19 |
+
|
| 20 |
+
[-1, 1, Conv, [160, 3, 2]], # 3-P2/4
|
| 21 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 29 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 30 |
+
[-1, 1, Conv, [320, 1, 1]], # 13
|
| 31 |
+
|
| 32 |
+
[-1, 1, MP, []],
|
| 33 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 34 |
+
[-3, 1, Conv, [160, 1, 1]],
|
| 35 |
+
[-1, 1, Conv, [160, 3, 2]],
|
| 36 |
+
[[-1, -3], 1, Concat, [1]], # 18-P3/8
|
| 37 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 38 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 41 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 42 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 43 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 44 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 45 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 46 |
+
[-1, 1, Conv, [640, 1, 1]], # 28
|
| 47 |
+
|
| 48 |
+
[-1, 1, MP, []],
|
| 49 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 50 |
+
[-3, 1, Conv, [320, 1, 1]],
|
| 51 |
+
[-1, 1, Conv, [320, 3, 2]],
|
| 52 |
+
[[-1, -3], 1, Concat, [1]], # 33-P4/16
|
| 53 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 54 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 55 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 56 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 57 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 58 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 59 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 60 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 61 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 62 |
+
[-1, 1, Conv, [1280, 1, 1]], # 43
|
| 63 |
+
|
| 64 |
+
[-1, 1, MP, []],
|
| 65 |
+
[-1, 1, Conv, [640, 1, 1]],
|
| 66 |
+
[-3, 1, Conv, [640, 1, 1]],
|
| 67 |
+
[-1, 1, Conv, [640, 3, 2]],
|
| 68 |
+
[[-1, -3], 1, Concat, [1]], # 48-P5/32
|
| 69 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 70 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 71 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 72 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 73 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 74 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 75 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 76 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 77 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 78 |
+
[-1, 1, Conv, [1280, 1, 1]], # 58
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
# yolov7x head
|
| 82 |
+
head:
|
| 83 |
+
[[-1, 1, SPPCSPC, [640]], # 59
|
| 84 |
+
|
| 85 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 86 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 87 |
+
[43, 1, Conv, [320, 1, 1]], # route backbone P4
|
| 88 |
+
[[-1, -2], 1, Concat, [1]],
|
| 89 |
+
|
| 90 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 91 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 92 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 94 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 95 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 97 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 98 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 99 |
+
[-1, 1, Conv, [320, 1, 1]], # 73
|
| 100 |
+
|
| 101 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 102 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 103 |
+
[28, 1, Conv, [160, 1, 1]], # route backbone P3
|
| 104 |
+
[[-1, -2], 1, Concat, [1]],
|
| 105 |
+
|
| 106 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 107 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 108 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 109 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 110 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 111 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 112 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 113 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 114 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 115 |
+
[-1, 1, Conv, [160, 1, 1]], # 87
|
| 116 |
+
|
| 117 |
+
[-1, 1, MP, []],
|
| 118 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 119 |
+
[-3, 1, Conv, [160, 1, 1]],
|
| 120 |
+
[-1, 1, Conv, [160, 3, 2]],
|
| 121 |
+
[[-1, -3, 73], 1, Concat, [1]],
|
| 122 |
+
|
| 123 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 124 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 125 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 127 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 128 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 129 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 130 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 131 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 132 |
+
[-1, 1, Conv, [320, 1, 1]], # 102
|
| 133 |
+
|
| 134 |
+
[-1, 1, MP, []],
|
| 135 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 136 |
+
[-3, 1, Conv, [320, 1, 1]],
|
| 137 |
+
[-1, 1, Conv, [320, 3, 2]],
|
| 138 |
+
[[-1, -3, 59], 1, Concat, [1]],
|
| 139 |
+
|
| 140 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 141 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 142 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 143 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 144 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 145 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 146 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 147 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 148 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 149 |
+
[-1, 1, Conv, [640, 1, 1]], # 117
|
| 150 |
+
|
| 151 |
+
[87, 1, Conv, [320, 3, 1]],
|
| 152 |
+
[102, 1, Conv, [640, 3, 1]],
|
| 153 |
+
[117, 1, Conv, [1280, 3, 1]],
|
| 154 |
+
|
| 155 |
+
[[118,119,120], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 156 |
+
]
|
detection/cfg/training/yolov7-d6.yaml
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args],
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [96, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, DownC, [192]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 29 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 30 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 31 |
+
[-1, 1, Conv, [192, 1, 1]], # 14
|
| 32 |
+
|
| 33 |
+
[-1, 1, DownC, [384]], # 15-P3/8
|
| 34 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 35 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 36 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 41 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 42 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 43 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 44 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 45 |
+
[-1, 1, Conv, [384, 1, 1]], # 27
|
| 46 |
+
|
| 47 |
+
[-1, 1, DownC, [768]], # 28-P4/16
|
| 48 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 49 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 50 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 51 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 52 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 53 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 54 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 55 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 56 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 57 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 58 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 59 |
+
[-1, 1, Conv, [768, 1, 1]], # 40
|
| 60 |
+
|
| 61 |
+
[-1, 1, DownC, [1152]], # 41-P5/32
|
| 62 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 63 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 64 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 65 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 66 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 67 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 68 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 69 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 70 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 72 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 73 |
+
[-1, 1, Conv, [1152, 1, 1]], # 53
|
| 74 |
+
|
| 75 |
+
[-1, 1, DownC, [1536]], # 54-P6/64
|
| 76 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 77 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 78 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 79 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 80 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 81 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 82 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 84 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 85 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 86 |
+
[[-1, -3, -5, -7, -9, -10], 1, Concat, [1]],
|
| 87 |
+
[-1, 1, Conv, [1536, 1, 1]], # 66
|
| 88 |
+
]
|
| 89 |
+
|
| 90 |
+
# yolov7 head
|
| 91 |
+
head:
|
| 92 |
+
[[-1, 1, SPPCSPC, [768]], # 67
|
| 93 |
+
|
| 94 |
+
[-1, 1, Conv, [576, 1, 1]],
|
| 95 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 96 |
+
[53, 1, Conv, [576, 1, 1]], # route backbone P5
|
| 97 |
+
[[-1, -2], 1, Concat, [1]],
|
| 98 |
+
|
| 99 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 100 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 101 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 102 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 103 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 104 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 105 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 106 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 107 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 108 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 109 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 110 |
+
[-1, 1, Conv, [576, 1, 1]], # 83
|
| 111 |
+
|
| 112 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 113 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 114 |
+
[40, 1, Conv, [384, 1, 1]], # route backbone P4
|
| 115 |
+
[[-1, -2], 1, Concat, [1]],
|
| 116 |
+
|
| 117 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 118 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 119 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 120 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 121 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 122 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 123 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 124 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 125 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 127 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 128 |
+
[-1, 1, Conv, [384, 1, 1]], # 99
|
| 129 |
+
|
| 130 |
+
[-1, 1, Conv, [192, 1, 1]],
|
| 131 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 132 |
+
[27, 1, Conv, [192, 1, 1]], # route backbone P3
|
| 133 |
+
[[-1, -2], 1, Concat, [1]],
|
| 134 |
+
|
| 135 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 136 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 137 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 138 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 139 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 140 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 141 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 142 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 143 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 144 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 145 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 146 |
+
[-1, 1, Conv, [192, 1, 1]], # 115
|
| 147 |
+
|
| 148 |
+
[-1, 1, DownC, [384]],
|
| 149 |
+
[[-1, 99], 1, Concat, [1]],
|
| 150 |
+
|
| 151 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 152 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 153 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 154 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 155 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 156 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 157 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 158 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 159 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 160 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 161 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 162 |
+
[-1, 1, Conv, [384, 1, 1]], # 129
|
| 163 |
+
|
| 164 |
+
[-1, 1, DownC, [576]],
|
| 165 |
+
[[-1, 83], 1, Concat, [1]],
|
| 166 |
+
|
| 167 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 168 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 169 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 170 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 171 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 172 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 173 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 174 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 175 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 176 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 177 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 178 |
+
[-1, 1, Conv, [576, 1, 1]], # 143
|
| 179 |
+
|
| 180 |
+
[-1, 1, DownC, [768]],
|
| 181 |
+
[[-1, 67], 1, Concat, [1]],
|
| 182 |
+
|
| 183 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 184 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 185 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 186 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 187 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 188 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 189 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 190 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 191 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 192 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 193 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], 1, Concat, [1]],
|
| 194 |
+
[-1, 1, Conv, [768, 1, 1]], # 157
|
| 195 |
+
|
| 196 |
+
[115, 1, Conv, [384, 3, 1]],
|
| 197 |
+
[129, 1, Conv, [768, 3, 1]],
|
| 198 |
+
[143, 1, Conv, [1152, 3, 1]],
|
| 199 |
+
[157, 1, Conv, [1536, 3, 1]],
|
| 200 |
+
|
| 201 |
+
[115, 1, Conv, [384, 3, 1]],
|
| 202 |
+
[99, 1, Conv, [768, 3, 1]],
|
| 203 |
+
[83, 1, Conv, [1152, 3, 1]],
|
| 204 |
+
[67, 1, Conv, [1536, 3, 1]],
|
| 205 |
+
|
| 206 |
+
[[158,159,160,161,162,163,164,165], 1, IAuxDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 207 |
+
]
|
detection/cfg/training/yolov7-e6.yaml
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args],
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [80, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, DownC, [160]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 29 |
+
[-1, 1, Conv, [160, 1, 1]], # 12
|
| 30 |
+
|
| 31 |
+
[-1, 1, DownC, [320]], # 13-P3/8
|
| 32 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 33 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 34 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 35 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 36 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 41 |
+
[-1, 1, Conv, [320, 1, 1]], # 23
|
| 42 |
+
|
| 43 |
+
[-1, 1, DownC, [640]], # 24-P4/16
|
| 44 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 45 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 46 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 47 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 48 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 49 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 50 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 51 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 52 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 53 |
+
[-1, 1, Conv, [640, 1, 1]], # 34
|
| 54 |
+
|
| 55 |
+
[-1, 1, DownC, [960]], # 35-P5/32
|
| 56 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 57 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 58 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 59 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 60 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 61 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 62 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 63 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 64 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 65 |
+
[-1, 1, Conv, [960, 1, 1]], # 45
|
| 66 |
+
|
| 67 |
+
[-1, 1, DownC, [1280]], # 46-P6/64
|
| 68 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 69 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 70 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 72 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 73 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 74 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 75 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 76 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 77 |
+
[-1, 1, Conv, [1280, 1, 1]], # 56
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
# yolov7 head
|
| 81 |
+
head:
|
| 82 |
+
[[-1, 1, SPPCSPC, [640]], # 57
|
| 83 |
+
|
| 84 |
+
[-1, 1, Conv, [480, 1, 1]],
|
| 85 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 86 |
+
[45, 1, Conv, [480, 1, 1]], # route backbone P5
|
| 87 |
+
[[-1, -2], 1, Concat, [1]],
|
| 88 |
+
|
| 89 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 90 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 91 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 92 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 94 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 95 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 97 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 98 |
+
[-1, 1, Conv, [480, 1, 1]], # 71
|
| 99 |
+
|
| 100 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 101 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 102 |
+
[34, 1, Conv, [320, 1, 1]], # route backbone P4
|
| 103 |
+
[[-1, -2], 1, Concat, [1]],
|
| 104 |
+
|
| 105 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 106 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 107 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 108 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 109 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 110 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 111 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 112 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 113 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 114 |
+
[-1, 1, Conv, [320, 1, 1]], # 85
|
| 115 |
+
|
| 116 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 117 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 118 |
+
[23, 1, Conv, [160, 1, 1]], # route backbone P3
|
| 119 |
+
[[-1, -2], 1, Concat, [1]],
|
| 120 |
+
|
| 121 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 122 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 123 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 124 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 125 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 127 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 128 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 129 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 130 |
+
[-1, 1, Conv, [160, 1, 1]], # 99
|
| 131 |
+
|
| 132 |
+
[-1, 1, DownC, [320]],
|
| 133 |
+
[[-1, 85], 1, Concat, [1]],
|
| 134 |
+
|
| 135 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 136 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 137 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 138 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 139 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 140 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 141 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 142 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 143 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 144 |
+
[-1, 1, Conv, [320, 1, 1]], # 111
|
| 145 |
+
|
| 146 |
+
[-1, 1, DownC, [480]],
|
| 147 |
+
[[-1, 71], 1, Concat, [1]],
|
| 148 |
+
|
| 149 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 150 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 151 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 152 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 153 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 154 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 155 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 156 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 157 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 158 |
+
[-1, 1, Conv, [480, 1, 1]], # 123
|
| 159 |
+
|
| 160 |
+
[-1, 1, DownC, [640]],
|
| 161 |
+
[[-1, 57], 1, Concat, [1]],
|
| 162 |
+
|
| 163 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 164 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 165 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 166 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 167 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 168 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 169 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 170 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 171 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 172 |
+
[-1, 1, Conv, [640, 1, 1]], # 135
|
| 173 |
+
|
| 174 |
+
[99, 1, Conv, [320, 3, 1]],
|
| 175 |
+
[111, 1, Conv, [640, 3, 1]],
|
| 176 |
+
[123, 1, Conv, [960, 3, 1]],
|
| 177 |
+
[135, 1, Conv, [1280, 3, 1]],
|
| 178 |
+
|
| 179 |
+
[99, 1, Conv, [320, 3, 1]],
|
| 180 |
+
[85, 1, Conv, [640, 3, 1]],
|
| 181 |
+
[71, 1, Conv, [960, 3, 1]],
|
| 182 |
+
[57, 1, Conv, [1280, 3, 1]],
|
| 183 |
+
|
| 184 |
+
[[136,137,138,139,140,141,142,143], 1, IAuxDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 185 |
+
]
|
detection/cfg/training/yolov7-e6e.yaml
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args],
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [80, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, DownC, [160]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 29 |
+
[-1, 1, Conv, [160, 1, 1]], # 12
|
| 30 |
+
[-11, 1, Conv, [64, 1, 1]],
|
| 31 |
+
[-12, 1, Conv, [64, 1, 1]],
|
| 32 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 33 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 34 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 35 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 36 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 37 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 38 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 39 |
+
[-1, 1, Conv, [160, 1, 1]], # 22
|
| 40 |
+
[[-1, -11], 1, Shortcut, [1]], # 23
|
| 41 |
+
|
| 42 |
+
[-1, 1, DownC, [320]], # 24-P3/8
|
| 43 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 44 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 45 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 46 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 47 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 48 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 49 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 50 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 51 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 52 |
+
[-1, 1, Conv, [320, 1, 1]], # 34
|
| 53 |
+
[-11, 1, Conv, [128, 1, 1]],
|
| 54 |
+
[-12, 1, Conv, [128, 1, 1]],
|
| 55 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 56 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 57 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 58 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 59 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 60 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 61 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 62 |
+
[-1, 1, Conv, [320, 1, 1]], # 44
|
| 63 |
+
[[-1, -11], 1, Shortcut, [1]], # 45
|
| 64 |
+
|
| 65 |
+
[-1, 1, DownC, [640]], # 46-P4/16
|
| 66 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 67 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 68 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 69 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 70 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 71 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 72 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 73 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 74 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 75 |
+
[-1, 1, Conv, [640, 1, 1]], # 56
|
| 76 |
+
[-11, 1, Conv, [256, 1, 1]],
|
| 77 |
+
[-12, 1, Conv, [256, 1, 1]],
|
| 78 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 79 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 80 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 81 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 82 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 84 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 85 |
+
[-1, 1, Conv, [640, 1, 1]], # 66
|
| 86 |
+
[[-1, -11], 1, Shortcut, [1]], # 67
|
| 87 |
+
|
| 88 |
+
[-1, 1, DownC, [960]], # 68-P5/32
|
| 89 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 90 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 91 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 92 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 94 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 95 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 97 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 98 |
+
[-1, 1, Conv, [960, 1, 1]], # 78
|
| 99 |
+
[-11, 1, Conv, [384, 1, 1]],
|
| 100 |
+
[-12, 1, Conv, [384, 1, 1]],
|
| 101 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 102 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 103 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 104 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 105 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 106 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 107 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 108 |
+
[-1, 1, Conv, [960, 1, 1]], # 88
|
| 109 |
+
[[-1, -11], 1, Shortcut, [1]], # 89
|
| 110 |
+
|
| 111 |
+
[-1, 1, DownC, [1280]], # 90-P6/64
|
| 112 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 113 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 114 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 115 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 116 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 117 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 118 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 119 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 120 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 121 |
+
[-1, 1, Conv, [1280, 1, 1]], # 100
|
| 122 |
+
[-11, 1, Conv, [512, 1, 1]],
|
| 123 |
+
[-12, 1, Conv, [512, 1, 1]],
|
| 124 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 125 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 127 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 128 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 129 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 130 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 131 |
+
[-1, 1, Conv, [1280, 1, 1]], # 110
|
| 132 |
+
[[-1, -11], 1, Shortcut, [1]], # 111
|
| 133 |
+
]
|
| 134 |
+
|
| 135 |
+
# yolov7 head
|
| 136 |
+
head:
|
| 137 |
+
[[-1, 1, SPPCSPC, [640]], # 112
|
| 138 |
+
|
| 139 |
+
[-1, 1, Conv, [480, 1, 1]],
|
| 140 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 141 |
+
[89, 1, Conv, [480, 1, 1]], # route backbone P5
|
| 142 |
+
[[-1, -2], 1, Concat, [1]],
|
| 143 |
+
|
| 144 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 145 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 146 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 147 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 148 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 149 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 150 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 151 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 152 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 153 |
+
[-1, 1, Conv, [480, 1, 1]], # 126
|
| 154 |
+
[-11, 1, Conv, [384, 1, 1]],
|
| 155 |
+
[-12, 1, Conv, [384, 1, 1]],
|
| 156 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 157 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 158 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 159 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 160 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 161 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 162 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 163 |
+
[-1, 1, Conv, [480, 1, 1]], # 136
|
| 164 |
+
[[-1, -11], 1, Shortcut, [1]], # 137
|
| 165 |
+
|
| 166 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 167 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 168 |
+
[67, 1, Conv, [320, 1, 1]], # route backbone P4
|
| 169 |
+
[[-1, -2], 1, Concat, [1]],
|
| 170 |
+
|
| 171 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 172 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 173 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 174 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 175 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 176 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 177 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 178 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 179 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 180 |
+
[-1, 1, Conv, [320, 1, 1]], # 151
|
| 181 |
+
[-11, 1, Conv, [256, 1, 1]],
|
| 182 |
+
[-12, 1, Conv, [256, 1, 1]],
|
| 183 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 184 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 185 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 186 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 187 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 188 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 189 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 190 |
+
[-1, 1, Conv, [320, 1, 1]], # 161
|
| 191 |
+
[[-1, -11], 1, Shortcut, [1]], # 162
|
| 192 |
+
|
| 193 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 194 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 195 |
+
[45, 1, Conv, [160, 1, 1]], # route backbone P3
|
| 196 |
+
[[-1, -2], 1, Concat, [1]],
|
| 197 |
+
|
| 198 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 199 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 200 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 201 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 202 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 203 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 204 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 205 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 206 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 207 |
+
[-1, 1, Conv, [160, 1, 1]], # 176
|
| 208 |
+
[-11, 1, Conv, [128, 1, 1]],
|
| 209 |
+
[-12, 1, Conv, [128, 1, 1]],
|
| 210 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 211 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 212 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 213 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 214 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 215 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 216 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 217 |
+
[-1, 1, Conv, [160, 1, 1]], # 186
|
| 218 |
+
[[-1, -11], 1, Shortcut, [1]], # 187
|
| 219 |
+
|
| 220 |
+
[-1, 1, DownC, [320]],
|
| 221 |
+
[[-1, 162], 1, Concat, [1]],
|
| 222 |
+
|
| 223 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 224 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 225 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 226 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 227 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 228 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 229 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 230 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 231 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 232 |
+
[-1, 1, Conv, [320, 1, 1]], # 199
|
| 233 |
+
[-11, 1, Conv, [256, 1, 1]],
|
| 234 |
+
[-12, 1, Conv, [256, 1, 1]],
|
| 235 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 236 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 237 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 238 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 239 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 240 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 241 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 242 |
+
[-1, 1, Conv, [320, 1, 1]], # 209
|
| 243 |
+
[[-1, -11], 1, Shortcut, [1]], # 210
|
| 244 |
+
|
| 245 |
+
[-1, 1, DownC, [480]],
|
| 246 |
+
[[-1, 137], 1, Concat, [1]],
|
| 247 |
+
|
| 248 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 249 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 250 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 251 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 252 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 253 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 254 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 255 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 256 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 257 |
+
[-1, 1, Conv, [480, 1, 1]], # 222
|
| 258 |
+
[-11, 1, Conv, [384, 1, 1]],
|
| 259 |
+
[-12, 1, Conv, [384, 1, 1]],
|
| 260 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 261 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 262 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 263 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 264 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 265 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 266 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 267 |
+
[-1, 1, Conv, [480, 1, 1]], # 232
|
| 268 |
+
[[-1, -11], 1, Shortcut, [1]], # 233
|
| 269 |
+
|
| 270 |
+
[-1, 1, DownC, [640]],
|
| 271 |
+
[[-1, 112], 1, Concat, [1]],
|
| 272 |
+
|
| 273 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 274 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 275 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 276 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 277 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 278 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 279 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 280 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 281 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 282 |
+
[-1, 1, Conv, [640, 1, 1]], # 245
|
| 283 |
+
[-11, 1, Conv, [512, 1, 1]],
|
| 284 |
+
[-12, 1, Conv, [512, 1, 1]],
|
| 285 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 286 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 287 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 288 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 289 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 290 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 291 |
+
[[-1, -2, -3, -4, -5, -6, -7, -8], 1, Concat, [1]],
|
| 292 |
+
[-1, 1, Conv, [640, 1, 1]], # 255
|
| 293 |
+
[[-1, -11], 1, Shortcut, [1]], # 256
|
| 294 |
+
|
| 295 |
+
[187, 1, Conv, [320, 3, 1]],
|
| 296 |
+
[210, 1, Conv, [640, 3, 1]],
|
| 297 |
+
[233, 1, Conv, [960, 3, 1]],
|
| 298 |
+
[256, 1, Conv, [1280, 3, 1]],
|
| 299 |
+
|
| 300 |
+
[186, 1, Conv, [320, 3, 1]],
|
| 301 |
+
[161, 1, Conv, [640, 3, 1]],
|
| 302 |
+
[136, 1, Conv, [960, 3, 1]],
|
| 303 |
+
[112, 1, Conv, [1280, 3, 1]],
|
| 304 |
+
|
| 305 |
+
[[257,258,259,260,261,262,263,264], 1, IAuxDetect, [nc, anchors]], # Detect(P3, P4, P5, P6)
|
| 306 |
+
]
|
detection/cfg/training/yolov7-tiny.yaml
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [10,13, 16,30, 33,23] # P3/8
|
| 9 |
+
- [30,61, 62,45, 59,119] # P4/16
|
| 10 |
+
- [116,90, 156,198, 373,326] # P5/32
|
| 11 |
+
|
| 12 |
+
# yolov7-tiny backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args] c2, k=1, s=1, p=None, g=1, act=True
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 2, None, 1, nn.LeakyReLU(0.1)]], # 0-P1/2
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [64, 3, 2, None, 1, nn.LeakyReLU(0.1)]], # 1-P2/4
|
| 18 |
+
|
| 19 |
+
[-1, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 20 |
+
[-2, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 21 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 22 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 23 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 24 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 7
|
| 25 |
+
|
| 26 |
+
[-1, 1, MP, []], # 8-P3/8
|
| 27 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 28 |
+
[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 29 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 30 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 31 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 32 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 14
|
| 33 |
+
|
| 34 |
+
[-1, 1, MP, []], # 15-P4/16
|
| 35 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 36 |
+
[-2, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 39 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 40 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 21
|
| 41 |
+
|
| 42 |
+
[-1, 1, MP, []], # 22-P5/32
|
| 43 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 44 |
+
[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 45 |
+
[-1, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 46 |
+
[-1, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 47 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 48 |
+
[-1, 1, Conv, [512, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 28
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# yolov7-tiny head
|
| 52 |
+
head:
|
| 53 |
+
[[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 54 |
+
[-2, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 55 |
+
[-1, 1, SP, [5]],
|
| 56 |
+
[-2, 1, SP, [9]],
|
| 57 |
+
[-3, 1, SP, [13]],
|
| 58 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 59 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 60 |
+
[[-1, -7], 1, Concat, [1]],
|
| 61 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 37
|
| 62 |
+
|
| 63 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 64 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 65 |
+
[21, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # route backbone P4
|
| 66 |
+
[[-1, -2], 1, Concat, [1]],
|
| 67 |
+
|
| 68 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 69 |
+
[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 70 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 71 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 72 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 73 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 47
|
| 74 |
+
|
| 75 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 76 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 77 |
+
[14, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # route backbone P3
|
| 78 |
+
[[-1, -2], 1, Concat, [1]],
|
| 79 |
+
|
| 80 |
+
[-1, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 81 |
+
[-2, 1, Conv, [32, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 82 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 83 |
+
[-1, 1, Conv, [32, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 84 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 85 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 57
|
| 86 |
+
|
| 87 |
+
[-1, 1, Conv, [128, 3, 2, None, 1, nn.LeakyReLU(0.1)]],
|
| 88 |
+
[[-1, 47], 1, Concat, [1]],
|
| 89 |
+
|
| 90 |
+
[-1, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 91 |
+
[-2, 1, Conv, [64, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 92 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 93 |
+
[-1, 1, Conv, [64, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 94 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 95 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 65
|
| 96 |
+
|
| 97 |
+
[-1, 1, Conv, [256, 3, 2, None, 1, nn.LeakyReLU(0.1)]],
|
| 98 |
+
[[-1, 37], 1, Concat, [1]],
|
| 99 |
+
|
| 100 |
+
[-1, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 101 |
+
[-2, 1, Conv, [128, 1, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 102 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 103 |
+
[-1, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 104 |
+
[[-1, -2, -3, -4], 1, Concat, [1]],
|
| 105 |
+
[-1, 1, Conv, [256, 1, 1, None, 1, nn.LeakyReLU(0.1)]], # 73
|
| 106 |
+
|
| 107 |
+
[57, 1, Conv, [128, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 108 |
+
[65, 1, Conv, [256, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 109 |
+
[73, 1, Conv, [512, 3, 1, None, 1, nn.LeakyReLU(0.1)]],
|
| 110 |
+
|
| 111 |
+
[[74,75,76], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 112 |
+
]
|
detection/cfg/training/yolov7-w6.yaml
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [ 19,27, 44,40, 38,94 ] # P3/8
|
| 9 |
+
- [ 96,68, 86,152, 180,137 ] # P4/16
|
| 10 |
+
- [ 140,301, 303,264, 238,542 ] # P5/32
|
| 11 |
+
- [ 436,615, 739,380, 925,792 ] # P6/64
|
| 12 |
+
|
| 13 |
+
# yolov7 backbone
|
| 14 |
+
backbone:
|
| 15 |
+
# [from, number, module, args]
|
| 16 |
+
[[-1, 1, ReOrg, []], # 0
|
| 17 |
+
[-1, 1, Conv, [64, 3, 1]], # 1-P1/2
|
| 18 |
+
|
| 19 |
+
[-1, 1, Conv, [128, 3, 2]], # 2-P2/4
|
| 20 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 21 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 27 |
+
[-1, 1, Conv, [128, 1, 1]], # 10
|
| 28 |
+
|
| 29 |
+
[-1, 1, Conv, [256, 3, 2]], # 11-P3/8
|
| 30 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 31 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 32 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 33 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 34 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 35 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 36 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 37 |
+
[-1, 1, Conv, [256, 1, 1]], # 19
|
| 38 |
+
|
| 39 |
+
[-1, 1, Conv, [512, 3, 2]], # 20-P4/16
|
| 40 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 41 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 42 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 43 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 44 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 45 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 46 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 47 |
+
[-1, 1, Conv, [512, 1, 1]], # 28
|
| 48 |
+
|
| 49 |
+
[-1, 1, Conv, [768, 3, 2]], # 29-P5/32
|
| 50 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 51 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 52 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 53 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 54 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 55 |
+
[-1, 1, Conv, [384, 3, 1]],
|
| 56 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 57 |
+
[-1, 1, Conv, [768, 1, 1]], # 37
|
| 58 |
+
|
| 59 |
+
[-1, 1, Conv, [1024, 3, 2]], # 38-P6/64
|
| 60 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 61 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 62 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 63 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 64 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 65 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 66 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 67 |
+
[-1, 1, Conv, [1024, 1, 1]], # 46
|
| 68 |
+
]
|
| 69 |
+
|
| 70 |
+
# yolov7 head
|
| 71 |
+
head:
|
| 72 |
+
[[-1, 1, SPPCSPC, [512]], # 47
|
| 73 |
+
|
| 74 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 75 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 76 |
+
[37, 1, Conv, [384, 1, 1]], # route backbone P5
|
| 77 |
+
[[-1, -2], 1, Concat, [1]],
|
| 78 |
+
|
| 79 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 80 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 81 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 82 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 83 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 84 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 85 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 86 |
+
[-1, 1, Conv, [384, 1, 1]], # 59
|
| 87 |
+
|
| 88 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 89 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 90 |
+
[28, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 91 |
+
[[-1, -2], 1, Concat, [1]],
|
| 92 |
+
|
| 93 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 94 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 95 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 97 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 98 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 99 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 100 |
+
[-1, 1, Conv, [256, 1, 1]], # 71
|
| 101 |
+
|
| 102 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 103 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 104 |
+
[19, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 105 |
+
[[-1, -2], 1, Concat, [1]],
|
| 106 |
+
|
| 107 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 108 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 109 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 110 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 111 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 112 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 113 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 114 |
+
[-1, 1, Conv, [128, 1, 1]], # 83
|
| 115 |
+
|
| 116 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 117 |
+
[[-1, 71], 1, Concat, [1]], # cat
|
| 118 |
+
|
| 119 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 120 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 121 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 122 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 123 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 124 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 125 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 126 |
+
[-1, 1, Conv, [256, 1, 1]], # 93
|
| 127 |
+
|
| 128 |
+
[-1, 1, Conv, [384, 3, 2]],
|
| 129 |
+
[[-1, 59], 1, Concat, [1]], # cat
|
| 130 |
+
|
| 131 |
+
[-1, 1, Conv, [384, 1, 1]],
|
| 132 |
+
[-2, 1, Conv, [384, 1, 1]],
|
| 133 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 134 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 135 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 136 |
+
[-1, 1, Conv, [192, 3, 1]],
|
| 137 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 138 |
+
[-1, 1, Conv, [384, 1, 1]], # 103
|
| 139 |
+
|
| 140 |
+
[-1, 1, Conv, [512, 3, 2]],
|
| 141 |
+
[[-1, 47], 1, Concat, [1]], # cat
|
| 142 |
+
|
| 143 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 144 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 145 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 146 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 147 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 148 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 149 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 150 |
+
[-1, 1, Conv, [512, 1, 1]], # 113
|
| 151 |
+
|
| 152 |
+
[83, 1, Conv, [256, 3, 1]],
|
| 153 |
+
[93, 1, Conv, [512, 3, 1]],
|
| 154 |
+
[103, 1, Conv, [768, 3, 1]],
|
| 155 |
+
[113, 1, Conv, [1024, 3, 1]],
|
| 156 |
+
|
| 157 |
+
[83, 1, Conv, [320, 3, 1]],
|
| 158 |
+
[71, 1, Conv, [640, 3, 1]],
|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
|
|
|
|
|
|
|
|
| 1 |
+
# parameters
|
| 2 |
+
nc: 80 # number of classes
|
| 3 |
+
depth_multiple: 1.0 # model depth multiple
|
| 4 |
+
width_multiple: 1.0 # layer channel multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# yolov7 backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [32, 3, 1]], # 0
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [64, 3, 2]], # 1-P1/2
|
| 18 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 19 |
+
|
| 20 |
+
[-1, 1, Conv, [128, 3, 2]], # 3-P2/4
|
| 21 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 28 |
+
[-1, 1, Conv, [256, 1, 1]], # 11
|
| 29 |
+
|
| 30 |
+
[-1, 1, MP, []],
|
| 31 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 32 |
+
[-3, 1, Conv, [128, 1, 1]],
|
| 33 |
+
[-1, 1, Conv, [128, 3, 2]],
|
| 34 |
+
[[-1, -3], 1, Concat, [1]], # 16-P3/8
|
| 35 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 36 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 37 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 38 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 41 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 42 |
+
[-1, 1, Conv, [512, 1, 1]], # 24
|
| 43 |
+
|
| 44 |
+
[-1, 1, MP, []],
|
| 45 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 46 |
+
[-3, 1, Conv, [256, 1, 1]],
|
| 47 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 48 |
+
[[-1, -3], 1, Concat, [1]], # 29-P4/16
|
| 49 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 50 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 51 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 52 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 53 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 54 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 55 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 56 |
+
[-1, 1, Conv, [1024, 1, 1]], # 37
|
| 57 |
+
|
| 58 |
+
[-1, 1, MP, []],
|
| 59 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 60 |
+
[-3, 1, Conv, [512, 1, 1]],
|
| 61 |
+
[-1, 1, Conv, [512, 3, 2]],
|
| 62 |
+
[[-1, -3], 1, Concat, [1]], # 42-P5/32
|
| 63 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 64 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 65 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 66 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 67 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 68 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 69 |
+
[[-1, -3, -5, -6], 1, Concat, [1]],
|
| 70 |
+
[-1, 1, Conv, [1024, 1, 1]], # 50
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
# yolov7 head
|
| 74 |
+
head:
|
| 75 |
+
[[-1, 1, SPPCSPC, [512]], # 51
|
| 76 |
+
|
| 77 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 78 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 79 |
+
[37, 1, Conv, [256, 1, 1]], # route backbone P4
|
| 80 |
+
[[-1, -2], 1, Concat, [1]],
|
| 81 |
+
|
| 82 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 83 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 84 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 85 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 86 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 87 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 88 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 89 |
+
[-1, 1, Conv, [256, 1, 1]], # 63
|
| 90 |
+
|
| 91 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 92 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 93 |
+
[24, 1, Conv, [128, 1, 1]], # route backbone P3
|
| 94 |
+
[[-1, -2], 1, Concat, [1]],
|
| 95 |
+
|
| 96 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 97 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 98 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 99 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 100 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 101 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 102 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 103 |
+
[-1, 1, Conv, [128, 1, 1]], # 75
|
| 104 |
+
|
| 105 |
+
[-1, 1, MP, []],
|
| 106 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 107 |
+
[-3, 1, Conv, [128, 1, 1]],
|
| 108 |
+
[-1, 1, Conv, [128, 3, 2]],
|
| 109 |
+
[[-1, -3, 63], 1, Concat, [1]],
|
| 110 |
+
|
| 111 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 112 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 113 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 114 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 115 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 116 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 117 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 118 |
+
[-1, 1, Conv, [256, 1, 1]], # 88
|
| 119 |
+
|
| 120 |
+
[-1, 1, MP, []],
|
| 121 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 122 |
+
[-3, 1, Conv, [256, 1, 1]],
|
| 123 |
+
[-1, 1, Conv, [256, 3, 2]],
|
| 124 |
+
[[-1, -3, 51], 1, Concat, [1]],
|
| 125 |
+
|
| 126 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 127 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 128 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 129 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 130 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 131 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 132 |
+
[[-1, -2, -3, -4, -5, -6], 1, Concat, [1]],
|
| 133 |
+
[-1, 1, Conv, [512, 1, 1]], # 101
|
| 134 |
+
|
| 135 |
+
[75, 1, RepConv, [256, 3, 1]],
|
| 136 |
+
[88, 1, RepConv, [512, 3, 1]],
|
| 137 |
+
[101, 1, RepConv, [1024, 3, 1]],
|
| 138 |
+
|
| 139 |
+
[[102,103,104], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 140 |
+
]
|
detection/cfg/training/yolov7x.yaml
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|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multiple
|
| 5 |
+
|
| 6 |
+
# anchors
|
| 7 |
+
anchors:
|
| 8 |
+
- [12,16, 19,36, 40,28] # P3/8
|
| 9 |
+
- [36,75, 76,55, 72,146] # P4/16
|
| 10 |
+
- [142,110, 192,243, 459,401] # P5/32
|
| 11 |
+
|
| 12 |
+
# yolov7 backbone
|
| 13 |
+
backbone:
|
| 14 |
+
# [from, number, module, args]
|
| 15 |
+
[[-1, 1, Conv, [40, 3, 1]], # 0
|
| 16 |
+
|
| 17 |
+
[-1, 1, Conv, [80, 3, 2]], # 1-P1/2
|
| 18 |
+
[-1, 1, Conv, [80, 3, 1]],
|
| 19 |
+
|
| 20 |
+
[-1, 1, Conv, [160, 3, 2]], # 3-P2/4
|
| 21 |
+
[-1, 1, Conv, [64, 1, 1]],
|
| 22 |
+
[-2, 1, Conv, [64, 1, 1]],
|
| 23 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 24 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 25 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 26 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 27 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 28 |
+
[-1, 1, Conv, [64, 3, 1]],
|
| 29 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 30 |
+
[-1, 1, Conv, [320, 1, 1]], # 13
|
| 31 |
+
|
| 32 |
+
[-1, 1, MP, []],
|
| 33 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 34 |
+
[-3, 1, Conv, [160, 1, 1]],
|
| 35 |
+
[-1, 1, Conv, [160, 3, 2]],
|
| 36 |
+
[[-1, -3], 1, Concat, [1]], # 18-P3/8
|
| 37 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 38 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 39 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 40 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 41 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 42 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 43 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 44 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 45 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 46 |
+
[-1, 1, Conv, [640, 1, 1]], # 28
|
| 47 |
+
|
| 48 |
+
[-1, 1, MP, []],
|
| 49 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 50 |
+
[-3, 1, Conv, [320, 1, 1]],
|
| 51 |
+
[-1, 1, Conv, [320, 3, 2]],
|
| 52 |
+
[[-1, -3], 1, Concat, [1]], # 33-P4/16
|
| 53 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 54 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 55 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 56 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 57 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 58 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 59 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 60 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 61 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 62 |
+
[-1, 1, Conv, [1280, 1, 1]], # 43
|
| 63 |
+
|
| 64 |
+
[-1, 1, MP, []],
|
| 65 |
+
[-1, 1, Conv, [640, 1, 1]],
|
| 66 |
+
[-3, 1, Conv, [640, 1, 1]],
|
| 67 |
+
[-1, 1, Conv, [640, 3, 2]],
|
| 68 |
+
[[-1, -3], 1, Concat, [1]], # 48-P5/32
|
| 69 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 70 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 71 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 72 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 73 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 74 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 75 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 76 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 77 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 78 |
+
[-1, 1, Conv, [1280, 1, 1]], # 58
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
# yolov7 head
|
| 82 |
+
head:
|
| 83 |
+
[[-1, 1, SPPCSPC, [640]], # 59
|
| 84 |
+
|
| 85 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 86 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 87 |
+
[43, 1, Conv, [320, 1, 1]], # route backbone P4
|
| 88 |
+
[[-1, -2], 1, Concat, [1]],
|
| 89 |
+
|
| 90 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 91 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 92 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 93 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 94 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 95 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 96 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 97 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 98 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 99 |
+
[-1, 1, Conv, [320, 1, 1]], # 73
|
| 100 |
+
|
| 101 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 102 |
+
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
| 103 |
+
[28, 1, Conv, [160, 1, 1]], # route backbone P3
|
| 104 |
+
[[-1, -2], 1, Concat, [1]],
|
| 105 |
+
|
| 106 |
+
[-1, 1, Conv, [128, 1, 1]],
|
| 107 |
+
[-2, 1, Conv, [128, 1, 1]],
|
| 108 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 109 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 110 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 111 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 112 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 113 |
+
[-1, 1, Conv, [128, 3, 1]],
|
| 114 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 115 |
+
[-1, 1, Conv, [160, 1, 1]], # 87
|
| 116 |
+
|
| 117 |
+
[-1, 1, MP, []],
|
| 118 |
+
[-1, 1, Conv, [160, 1, 1]],
|
| 119 |
+
[-3, 1, Conv, [160, 1, 1]],
|
| 120 |
+
[-1, 1, Conv, [160, 3, 2]],
|
| 121 |
+
[[-1, -3, 73], 1, Concat, [1]],
|
| 122 |
+
|
| 123 |
+
[-1, 1, Conv, [256, 1, 1]],
|
| 124 |
+
[-2, 1, Conv, [256, 1, 1]],
|
| 125 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 126 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 127 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 128 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 129 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 130 |
+
[-1, 1, Conv, [256, 3, 1]],
|
| 131 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 132 |
+
[-1, 1, Conv, [320, 1, 1]], # 102
|
| 133 |
+
|
| 134 |
+
[-1, 1, MP, []],
|
| 135 |
+
[-1, 1, Conv, [320, 1, 1]],
|
| 136 |
+
[-3, 1, Conv, [320, 1, 1]],
|
| 137 |
+
[-1, 1, Conv, [320, 3, 2]],
|
| 138 |
+
[[-1, -3, 59], 1, Concat, [1]],
|
| 139 |
+
|
| 140 |
+
[-1, 1, Conv, [512, 1, 1]],
|
| 141 |
+
[-2, 1, Conv, [512, 1, 1]],
|
| 142 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 143 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 144 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 145 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 146 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 147 |
+
[-1, 1, Conv, [512, 3, 1]],
|
| 148 |
+
[[-1, -3, -5, -7, -8], 1, Concat, [1]],
|
| 149 |
+
[-1, 1, Conv, [640, 1, 1]], # 117
|
| 150 |
+
|
| 151 |
+
[87, 1, Conv, [320, 3, 1]],
|
| 152 |
+
[102, 1, Conv, [640, 3, 1]],
|
| 153 |
+
[117, 1, Conv, [1280, 3, 1]],
|
| 154 |
+
|
| 155 |
+
[[118,119,120], 1, IDetect, [nc, anchors]], # Detect(P3, P4, P5)
|
| 156 |
+
]
|
detection/data/coco.yaml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# COCO 2017 dataset http://cocodataset.org
|
| 2 |
+
|
| 3 |
+
# download command/URL (optional)
|
| 4 |
+
download: bash ./scripts/get_coco.sh
|
| 5 |
+
|
| 6 |
+
# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
|
| 7 |
+
train: ./coco/train2017.txt # 118287 images
|
| 8 |
+
val: ./coco/val2017.txt # 5000 images
|
| 9 |
+
test: ./coco/test-dev2017.txt # 20288 of 40670 images, submit to https://competitions.codalab.org/competitions/20794
|
| 10 |
+
|
| 11 |
+
# number of classes
|
| 12 |
+
nc: 80
|
| 13 |
+
|
| 14 |
+
# class names
|
| 15 |
+
names: [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
|
| 16 |
+
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
|
| 17 |
+
'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
|
| 18 |
+
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
|
| 19 |
+
'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
|
| 20 |
+
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
|
| 21 |
+
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
|
| 22 |
+
'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
|
| 23 |
+
'hair drier', 'toothbrush' ]
|
detection/data/hyp.scratch.custom.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
|
| 2 |
+
lrf: 0.1 # final OneCycleLR learning rate (lr0 * lrf)
|
| 3 |
+
momentum: 0.937 # SGD momentum/Adam beta1
|
| 4 |
+
weight_decay: 0.0005 # optimizer weight decay 5e-4
|
| 5 |
+
warmup_epochs: 3.0 # warmup epochs (fractions ok)
|
| 6 |
+
warmup_momentum: 0.8 # warmup initial momentum
|
| 7 |
+
warmup_bias_lr: 0.1 # warmup initial bias lr
|
| 8 |
+
box: 0.05 # box loss gain
|
| 9 |
+
cls: 0.3 # cls loss gain
|
| 10 |
+
cls_pw: 1.0 # cls BCELoss positive_weight
|
| 11 |
+
obj: 0.7 # obj loss gain (scale with pixels)
|
| 12 |
+
obj_pw: 1.0 # obj BCELoss positive_weight
|
| 13 |
+
iou_t: 0.20 # IoU training threshold
|
| 14 |
+
anchor_t: 4.0 # anchor-multiple threshold
|
| 15 |
+
# anchors: 3 # anchors per output layer (0 to ignore)
|
| 16 |
+
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
|
| 17 |
+
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
|
| 18 |
+
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
|
| 19 |
+
hsv_v: 0.4 # image HSV-Value augmentation (fraction)
|
| 20 |
+
degrees: 0.0 # image rotation (+/- deg)
|
| 21 |
+
translate: 0.2 # image translation (+/- fraction)
|
| 22 |
+
scale: 0.5 # image scale (+/- gain)
|
| 23 |
+
shear: 0.0 # image shear (+/- deg)
|
| 24 |
+
perspective: 0.0 # image perspective (+/- fraction), range 0-0.001
|
| 25 |
+
flipud: 0.0 # image flip up-down (probability)
|
| 26 |
+
fliplr: 0.5 # image flip left-right (probability)
|
| 27 |
+
mosaic: 1.0 # image mosaic (probability)
|
| 28 |
+
mixup: 0.0 # image mixup (probability)
|
| 29 |
+
copy_paste: 0.0 # image copy paste (probability)
|
| 30 |
+
paste_in: 0.0 # image copy paste (probability), use 0 for faster training
|
| 31 |
+
loss_ota: 1 # use ComputeLossOTA, use 0 for faster training
|
detection/data/hyp.scratch.p5.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
|
| 2 |
+
lrf: 0.1 # final OneCycleLR learning rate (lr0 * lrf)
|
| 3 |
+
momentum: 0.937 # SGD momentum/Adam beta1
|
| 4 |
+
weight_decay: 0.0005 # optimizer weight decay 5e-4
|
| 5 |
+
warmup_epochs: 3.0 # warmup epochs (fractions ok)
|
| 6 |
+
warmup_momentum: 0.8 # warmup initial momentum
|
| 7 |
+
warmup_bias_lr: 0.1 # warmup initial bias lr
|
| 8 |
+
box: 0.05 # box loss gain
|
| 9 |
+
cls: 0.3 # cls loss gain
|
| 10 |
+
cls_pw: 1.0 # cls BCELoss positive_weight
|
| 11 |
+
obj: 0.7 # obj loss gain (scale with pixels)
|
| 12 |
+
obj_pw: 1.0 # obj BCELoss positive_weight
|
| 13 |
+
iou_t: 0.20 # IoU training threshold
|
| 14 |
+
anchor_t: 4.0 # anchor-multiple threshold
|
| 15 |
+
# anchors: 3 # anchors per output layer (0 to ignore)
|
| 16 |
+
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
|
| 17 |
+
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
|
| 18 |
+
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
|
| 19 |
+
hsv_v: 0.4 # image HSV-Value augmentation (fraction)
|
| 20 |
+
degrees: 0.0 # image rotation (+/- deg)
|
| 21 |
+
translate: 0.2 # image translation (+/- fraction)
|
| 22 |
+
scale: 0.9 # image scale (+/- gain)
|
| 23 |
+
shear: 0.0 # image shear (+/- deg)
|
| 24 |
+
perspective: 0.0 # image perspective (+/- fraction), range 0-0.001
|
| 25 |
+
flipud: 0.0 # image flip up-down (probability)
|
| 26 |
+
fliplr: 0.5 # image flip left-right (probability)
|
| 27 |
+
mosaic: 1.0 # image mosaic (probability)
|
| 28 |
+
mixup: 0.15 # image mixup (probability)
|
| 29 |
+
copy_paste: 0.0 # image copy paste (probability)
|
| 30 |
+
paste_in: 0.15 # image copy paste (probability), use 0 for faster training
|
| 31 |
+
loss_ota: 1 # use ComputeLossOTA, use 0 for faster training
|
detection/data/hyp.scratch.p6.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
|
| 2 |
+
lrf: 0.2 # final OneCycleLR learning rate (lr0 * lrf)
|
| 3 |
+
momentum: 0.937 # SGD momentum/Adam beta1
|
| 4 |
+
weight_decay: 0.0005 # optimizer weight decay 5e-4
|
| 5 |
+
warmup_epochs: 3.0 # warmup epochs (fractions ok)
|
| 6 |
+
warmup_momentum: 0.8 # warmup initial momentum
|
| 7 |
+
warmup_bias_lr: 0.1 # warmup initial bias lr
|
| 8 |
+
box: 0.05 # box loss gain
|
| 9 |
+
cls: 0.3 # cls loss gain
|
| 10 |
+
cls_pw: 1.0 # cls BCELoss positive_weight
|
| 11 |
+
obj: 0.7 # obj loss gain (scale with pixels)
|
| 12 |
+
obj_pw: 1.0 # obj BCELoss positive_weight
|
| 13 |
+
iou_t: 0.20 # IoU training threshold
|
| 14 |
+
anchor_t: 4.0 # anchor-multiple threshold
|
| 15 |
+
# anchors: 3 # anchors per output layer (0 to ignore)
|
| 16 |
+
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
|
| 17 |
+
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
|
| 18 |
+
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
|
| 19 |
+
hsv_v: 0.4 # image HSV-Value augmentation (fraction)
|
| 20 |
+
degrees: 0.0 # image rotation (+/- deg)
|
| 21 |
+
translate: 0.2 # image translation (+/- fraction)
|
| 22 |
+
scale: 0.9 # image scale (+/- gain)
|
| 23 |
+
shear: 0.0 # image shear (+/- deg)
|
| 24 |
+
perspective: 0.0 # image perspective (+/- fraction), range 0-0.001
|
| 25 |
+
flipud: 0.0 # image flip up-down (probability)
|
| 26 |
+
fliplr: 0.5 # image flip left-right (probability)
|
| 27 |
+
mosaic: 1.0 # image mosaic (probability)
|
| 28 |
+
mixup: 0.15 # image mixup (probability)
|
| 29 |
+
copy_paste: 0.0 # image copy paste (probability)
|
| 30 |
+
paste_in: 0.15 # image copy paste (probability), use 0 for faster training
|
| 31 |
+
loss_ota: 1 # use ComputeLossOTA, use 0 for faster training
|
detection/data/hyp.scratch.tiny.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
lr0: 0.01 # initial learning rate (SGD=1E-2, Adam=1E-3)
|
| 2 |
+
lrf: 0.01 # final OneCycleLR learning rate (lr0 * lrf)
|
| 3 |
+
momentum: 0.937 # SGD momentum/Adam beta1
|
| 4 |
+
weight_decay: 0.0005 # optimizer weight decay 5e-4
|
| 5 |
+
warmup_epochs: 3.0 # warmup epochs (fractions ok)
|
| 6 |
+
warmup_momentum: 0.8 # warmup initial momentum
|
| 7 |
+
warmup_bias_lr: 0.1 # warmup initial bias lr
|
| 8 |
+
box: 0.05 # box loss gain
|
| 9 |
+
cls: 0.5 # cls loss gain
|
| 10 |
+
cls_pw: 1.0 # cls BCELoss positive_weight
|
| 11 |
+
obj: 1.0 # obj loss gain (scale with pixels)
|
| 12 |
+
obj_pw: 1.0 # obj BCELoss positive_weight
|
| 13 |
+
iou_t: 0.20 # IoU training threshold
|
| 14 |
+
anchor_t: 4.0 # anchor-multiple threshold
|
| 15 |
+
# anchors: 3 # anchors per output layer (0 to ignore)
|
| 16 |
+
fl_gamma: 0.0 # focal loss gamma (efficientDet default gamma=1.5)
|
| 17 |
+
hsv_h: 0.015 # image HSV-Hue augmentation (fraction)
|
| 18 |
+
hsv_s: 0.7 # image HSV-Saturation augmentation (fraction)
|
| 19 |
+
hsv_v: 0.4 # image HSV-Value augmentation (fraction)
|
| 20 |
+
degrees: 0.0 # image rotation (+/- deg)
|
| 21 |
+
translate: 0.1 # image translation (+/- fraction)
|
| 22 |
+
scale: 0.5 # image scale (+/- gain)
|
| 23 |
+
shear: 0.0 # image shear (+/- deg)
|
| 24 |
+
perspective: 0.0 # image perspective (+/- fraction), range 0-0.001
|
| 25 |
+
flipud: 0.0 # image flip up-down (probability)
|
| 26 |
+
fliplr: 0.5 # image flip left-right (probability)
|
| 27 |
+
mosaic: 1.0 # image mosaic (probability)
|
| 28 |
+
mixup: 0.05 # image mixup (probability)
|
| 29 |
+
copy_paste: 0.0 # image copy paste (probability)
|
| 30 |
+
paste_in: 0.05 # image copy paste (probability), use 0 for faster training
|
| 31 |
+
loss_ota: 1 # use ComputeLossOTA, use 0 for faster training
|
detection/detect.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import time
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import cv2
|
| 6 |
+
import torch
|
| 7 |
+
import torch.backends.cudnn as cudnn
|
| 8 |
+
from numpy import random
|
| 9 |
+
|
| 10 |
+
from models.experimental import attempt_load
|
| 11 |
+
from utils.datasets import LoadStreams, LoadImages
|
| 12 |
+
from utils.general import check_img_size, check_requirements, check_imshow, non_max_suppression, apply_classifier, \
|
| 13 |
+
scale_coords, xyxy2xywh, strip_optimizer, set_logging, increment_path
|
| 14 |
+
from utils.plots import plot_one_box
|
| 15 |
+
from utils.torch_utils import select_device, load_classifier, time_synchronized, TracedModel
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def detect(save_img=False):
|
| 19 |
+
source, weights, view_img, save_txt, imgsz, trace = opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_size, not opt.no_trace
|
| 20 |
+
save_img = not opt.nosave and not source.endswith('.txt') # save inference images
|
| 21 |
+
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
|
| 22 |
+
('rtsp://', 'rtmp://', 'http://', 'https://'))
|
| 23 |
+
|
| 24 |
+
# Directories
|
| 25 |
+
save_dir = Path(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)) # increment run
|
| 26 |
+
(save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True) # make dir
|
| 27 |
+
|
| 28 |
+
# Initialize
|
| 29 |
+
set_logging()
|
| 30 |
+
device = select_device(opt.device)
|
| 31 |
+
half = device.type != 'cpu' # half precision only supported on CUDA
|
| 32 |
+
|
| 33 |
+
# Load model
|
| 34 |
+
model = attempt_load(weights, map_location=device) # load FP32 model
|
| 35 |
+
stride = int(model.stride.max()) # model stride
|
| 36 |
+
imgsz = check_img_size(imgsz, s=stride) # check img_size
|
| 37 |
+
|
| 38 |
+
if trace:
|
| 39 |
+
model = TracedModel(model, device, opt.img_size)
|
| 40 |
+
|
| 41 |
+
if half:
|
| 42 |
+
model.half() # to FP16
|
| 43 |
+
|
| 44 |
+
# Second-stage classifier
|
| 45 |
+
classify = False
|
| 46 |
+
if classify:
|
| 47 |
+
modelc = load_classifier(name='resnet101', n=2) # initialize
|
| 48 |
+
modelc.load_state_dict(torch.load('weights/resnet101.pt', map_location=device)['model']).to(device).eval()
|
| 49 |
+
|
| 50 |
+
# Set Dataloader
|
| 51 |
+
vid_path, vid_writer = None, None
|
| 52 |
+
if webcam:
|
| 53 |
+
view_img = check_imshow()
|
| 54 |
+
cudnn.benchmark = True # set True to speed up constant image size inference
|
| 55 |
+
dataset = LoadStreams(source, img_size=imgsz, stride=stride)
|
| 56 |
+
else:
|
| 57 |
+
dataset = LoadImages(source, img_size=imgsz, stride=stride)
|
| 58 |
+
|
| 59 |
+
# Get names and colors
|
| 60 |
+
names = model.module.names if hasattr(model, 'module') else model.names
|
| 61 |
+
colors = [[random.randint(0, 255) for _ in range(3)] for _ in names]
|
| 62 |
+
|
| 63 |
+
# Run inference
|
| 64 |
+
if device.type != 'cpu':
|
| 65 |
+
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
|
| 66 |
+
old_img_w = old_img_h = imgsz
|
| 67 |
+
old_img_b = 1
|
| 68 |
+
|
| 69 |
+
t0 = time.time()
|
| 70 |
+
for path, img, im0s, vid_cap in dataset:
|
| 71 |
+
img = torch.from_numpy(img).to(device)
|
| 72 |
+
img = img.half() if half else img.float() # uint8 to fp16/32
|
| 73 |
+
img /= 255.0 # 0 - 255 to 0.0 - 1.0
|
| 74 |
+
if img.ndimension() == 3:
|
| 75 |
+
img = img.unsqueeze(0)
|
| 76 |
+
|
| 77 |
+
# Warmup
|
| 78 |
+
if device.type != 'cpu' and (old_img_b != img.shape[0] or old_img_h != img.shape[2] or old_img_w != img.shape[3]):
|
| 79 |
+
old_img_b = img.shape[0]
|
| 80 |
+
old_img_h = img.shape[2]
|
| 81 |
+
old_img_w = img.shape[3]
|
| 82 |
+
for i in range(3):
|
| 83 |
+
model(img, augment=opt.augment)[0]
|
| 84 |
+
|
| 85 |
+
# Inference
|
| 86 |
+
t1 = time_synchronized()
|
| 87 |
+
pred = model(img, augment=opt.augment)[0]
|
| 88 |
+
t2 = time_synchronized()
|
| 89 |
+
|
| 90 |
+
# Apply NMS
|
| 91 |
+
pred = non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=opt.agnostic_nms)
|
| 92 |
+
t3 = time_synchronized()
|
| 93 |
+
|
| 94 |
+
# Apply Classifier
|
| 95 |
+
if classify:
|
| 96 |
+
pred = apply_classifier(pred, modelc, img, im0s)
|
| 97 |
+
|
| 98 |
+
# Process detections
|
| 99 |
+
for i, det in enumerate(pred): # detections per image
|
| 100 |
+
if webcam: # batch_size >= 1
|
| 101 |
+
p, s, im0, frame = path[i], '%g: ' % i, im0s[i].copy(), dataset.count
|
| 102 |
+
else:
|
| 103 |
+
p, s, im0, frame = path, '', im0s, getattr(dataset, 'frame', 0)
|
| 104 |
+
|
| 105 |
+
p = Path(p) # to Path
|
| 106 |
+
save_path = str(save_dir / p.name) # img.jpg
|
| 107 |
+
txt_path = str(save_dir / 'labels' / p.stem) + ('' if dataset.mode == 'image' else f'_{frame}') # img.txt
|
| 108 |
+
gn = torch.tensor(im0.shape)[[1, 0, 1, 0]] # normalization gain whwh
|
| 109 |
+
if len(det):
|
| 110 |
+
# Rescale boxes from img_size to im0 size
|
| 111 |
+
det[:, :4] = scale_coords(img.shape[2:], det[:, :4], im0.shape).round()
|
| 112 |
+
|
| 113 |
+
# Print results
|
| 114 |
+
for c in det[:, -1].unique():
|
| 115 |
+
n = (det[:, -1] == c).sum() # detections per class
|
| 116 |
+
s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string
|
| 117 |
+
|
| 118 |
+
# Write results
|
| 119 |
+
for *xyxy, conf, cls in reversed(det):
|
| 120 |
+
if save_txt: # Write to file
|
| 121 |
+
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
| 122 |
+
line = (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label format
|
| 123 |
+
with open(txt_path + '.txt', 'a') as f:
|
| 124 |
+
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
| 125 |
+
|
| 126 |
+
if save_img or view_img: # Add bbox to image
|
| 127 |
+
label = f'{names[int(cls)]} {conf:.2f}'
|
| 128 |
+
plot_one_box(xyxy, im0, label=label, color=colors[int(cls)], line_thickness=1)
|
| 129 |
+
|
| 130 |
+
# Print time (inference + NMS)
|
| 131 |
+
print(f'{s}Done. ({(1E3 * (t2 - t1)):.1f}ms) Inference, ({(1E3 * (t3 - t2)):.1f}ms) NMS')
|
| 132 |
+
|
| 133 |
+
# Stream results
|
| 134 |
+
if view_img:
|
| 135 |
+
cv2.imshow(str(p), im0)
|
| 136 |
+
cv2.waitKey(1) # 1 millisecond
|
| 137 |
+
|
| 138 |
+
# Save results (image with detections)
|
| 139 |
+
if save_img:
|
| 140 |
+
if dataset.mode == 'image':
|
| 141 |
+
cv2.imwrite(save_path, im0)
|
| 142 |
+
print(f" The image with the result is saved in: {save_path}")
|
| 143 |
+
else: # 'video' or 'stream'
|
| 144 |
+
if vid_path != save_path: # new video
|
| 145 |
+
vid_path = save_path
|
| 146 |
+
if isinstance(vid_writer, cv2.VideoWriter):
|
| 147 |
+
vid_writer.release() # release previous video writer
|
| 148 |
+
if vid_cap: # video
|
| 149 |
+
fps = vid_cap.get(cv2.CAP_PROP_FPS)
|
| 150 |
+
w = int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 151 |
+
h = int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 152 |
+
else: # stream
|
| 153 |
+
fps, w, h = 30, im0.shape[1], im0.shape[0]
|
| 154 |
+
save_path += '.mp4'
|
| 155 |
+
vid_writer = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))
|
| 156 |
+
vid_writer.write(im0)
|
| 157 |
+
|
| 158 |
+
if save_txt or save_img:
|
| 159 |
+
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
|
| 160 |
+
#print(f"Results saved to {save_dir}{s}")
|
| 161 |
+
|
| 162 |
+
print(f'Done. ({time.time() - t0:.3f}s)')
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
if __name__ == '__main__':
|
| 166 |
+
parser = argparse.ArgumentParser()
|
| 167 |
+
parser.add_argument('--weights', nargs='+', type=str, default='yolov7.pt', help='model.pt path(s)')
|
| 168 |
+
parser.add_argument('--source', type=str, default='inference/images', help='source') # file/folder, 0 for webcam
|
| 169 |
+
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
|
| 170 |
+
parser.add_argument('--conf-thres', type=float, default=0.25, help='object confidence threshold')
|
| 171 |
+
parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
|
| 172 |
+
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
| 173 |
+
parser.add_argument('--view-img', action='store_true', help='display results')
|
| 174 |
+
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
|
| 175 |
+
parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
|
| 176 |
+
parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
|
| 177 |
+
parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --class 0, or --class 0 2 3')
|
| 178 |
+
parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
|
| 179 |
+
parser.add_argument('--augment', action='store_true', help='augmented inference')
|
| 180 |
+
parser.add_argument('--update', action='store_true', help='update all models')
|
| 181 |
+
parser.add_argument('--project', default='runs/detect', help='save results to project/name')
|
| 182 |
+
parser.add_argument('--name', default='exp', help='save results to project/name')
|
| 183 |
+
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
| 184 |
+
parser.add_argument('--no-trace', action='store_true', help='don`t trace model')
|
| 185 |
+
opt = parser.parse_args()
|
| 186 |
+
print(opt)
|
| 187 |
+
#check_requirements(exclude=('pycocotools', 'thop'))
|
| 188 |
+
|
| 189 |
+
with torch.no_grad():
|
| 190 |
+
if opt.update: # update all models (to fix SourceChangeWarning)
|
| 191 |
+
for opt.weights in ['yolov7.pt']:
|
| 192 |
+
detect()
|
| 193 |
+
strip_optimizer(opt.weights)
|
| 194 |
+
else:
|
| 195 |
+
detect()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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import sys
|
| 3 |
+
import time
|
| 4 |
+
import warnings
|
| 5 |
+
|
| 6 |
+
sys.path.append('./') # to run '$ python *.py' files in subdirectories
|
| 7 |
+
|
| 8 |
+
import torch
|
| 9 |
+
import torch.nn as nn
|
| 10 |
+
from torch.utils.mobile_optimizer import optimize_for_mobile
|
| 11 |
+
|
| 12 |
+
import models
|
| 13 |
+
from models.experimental import attempt_load, End2End
|
| 14 |
+
from utils.activations import Hardswish, SiLU
|
| 15 |
+
from utils.general import set_logging, check_img_size
|
| 16 |
+
from utils.torch_utils import select_device
|
| 17 |
+
from utils.add_nms import RegisterNMS
|
| 18 |
+
|
| 19 |
+
if __name__ == '__main__':
|
| 20 |
+
parser = argparse.ArgumentParser()
|
| 21 |
+
parser.add_argument('--weights', type=str, default='./yolor-csp-c.pt', help='weights path')
|
| 22 |
+
parser.add_argument('--img-size', nargs='+', type=int, default=[640, 640], help='image size') # height, width
|
| 23 |
+
parser.add_argument('--batch-size', type=int, default=1, help='batch size')
|
| 24 |
+
parser.add_argument('--dynamic', action='store_true', help='dynamic ONNX axes')
|
| 25 |
+
parser.add_argument('--dynamic-batch', action='store_true', help='dynamic batch onnx for tensorrt and onnx-runtime')
|
| 26 |
+
parser.add_argument('--grid', action='store_true', help='export Detect() layer grid')
|
| 27 |
+
parser.add_argument('--end2end', action='store_true', help='export end2end onnx')
|
| 28 |
+
parser.add_argument('--max-wh', type=int, default=None, help='None for tensorrt nms, int value for onnx-runtime nms')
|
| 29 |
+
parser.add_argument('--topk-all', type=int, default=100, help='topk objects for every images')
|
| 30 |
+
parser.add_argument('--iou-thres', type=float, default=0.45, help='iou threshold for NMS')
|
| 31 |
+
parser.add_argument('--conf-thres', type=float, default=0.25, help='conf threshold for NMS')
|
| 32 |
+
parser.add_argument('--device', default='cpu', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
| 33 |
+
parser.add_argument('--simplify', action='store_true', help='simplify onnx model')
|
| 34 |
+
parser.add_argument('--include-nms', action='store_true', help='export end2end onnx')
|
| 35 |
+
parser.add_argument('--fp16', action='store_true', help='CoreML FP16 half-precision export')
|
| 36 |
+
parser.add_argument('--int8', action='store_true', help='CoreML INT8 quantization')
|
| 37 |
+
opt = parser.parse_args()
|
| 38 |
+
opt.img_size *= 2 if len(opt.img_size) == 1 else 1 # expand
|
| 39 |
+
opt.dynamic = opt.dynamic and not opt.end2end
|
| 40 |
+
opt.dynamic = False if opt.dynamic_batch else opt.dynamic
|
| 41 |
+
print(opt)
|
| 42 |
+
set_logging()
|
| 43 |
+
t = time.time()
|
| 44 |
+
|
| 45 |
+
# Load PyTorch model
|
| 46 |
+
device = select_device(opt.device)
|
| 47 |
+
model = attempt_load(opt.weights, map_location=device) # load FP32 model
|
| 48 |
+
labels = model.names
|
| 49 |
+
|
| 50 |
+
# Checks
|
| 51 |
+
gs = int(max(model.stride)) # grid size (max stride)
|
| 52 |
+
opt.img_size = [check_img_size(x, gs) for x in opt.img_size] # verify img_size are gs-multiples
|
| 53 |
+
|
| 54 |
+
# Input
|
| 55 |
+
img = torch.zeros(opt.batch_size, 3, *opt.img_size).to(device) # image size(1,3,320,192) iDetection
|
| 56 |
+
|
| 57 |
+
# Update model
|
| 58 |
+
for k, m in model.named_modules():
|
| 59 |
+
m._non_persistent_buffers_set = set() # pytorch 1.6.0 compatibility
|
| 60 |
+
if isinstance(m, models.common.Conv): # assign export-friendly activations
|
| 61 |
+
if isinstance(m.act, nn.Hardswish):
|
| 62 |
+
m.act = Hardswish()
|
| 63 |
+
elif isinstance(m.act, nn.SiLU):
|
| 64 |
+
m.act = SiLU()
|
| 65 |
+
# elif isinstance(m, models.yolo.Detect):
|
| 66 |
+
# m.forward = m.forward_export # assign forward (optional)
|
| 67 |
+
model.model[-1].export = not opt.grid # set Detect() layer grid export
|
| 68 |
+
y = model(img) # dry run
|
| 69 |
+
if opt.include_nms:
|
| 70 |
+
model.model[-1].include_nms = True
|
| 71 |
+
y = None
|
| 72 |
+
|
| 73 |
+
# TorchScript export
|
| 74 |
+
try:
|
| 75 |
+
print('\nStarting TorchScript export with torch %s...' % torch.__version__)
|
| 76 |
+
f = opt.weights.replace('.pt', '.torchscript.pt') # filename
|
| 77 |
+
ts = torch.jit.trace(model, img, strict=False)
|
| 78 |
+
ts.save(f)
|
| 79 |
+
print('TorchScript export success, saved as %s' % f)
|
| 80 |
+
except Exception as e:
|
| 81 |
+
print('TorchScript export failure: %s' % e)
|
| 82 |
+
|
| 83 |
+
# CoreML export
|
| 84 |
+
try:
|
| 85 |
+
import coremltools as ct
|
| 86 |
+
|
| 87 |
+
print('\nStarting CoreML export with coremltools %s...' % ct.__version__)
|
| 88 |
+
# convert model from torchscript and apply pixel scaling as per detect.py
|
| 89 |
+
ct_model = ct.convert(ts, inputs=[ct.ImageType('image', shape=img.shape, scale=1 / 255.0, bias=[0, 0, 0])])
|
| 90 |
+
bits, mode = (8, 'kmeans_lut') if opt.int8 else (16, 'linear') if opt.fp16 else (32, None)
|
| 91 |
+
if bits < 32:
|
| 92 |
+
if sys.platform.lower() == 'darwin': # quantization only supported on macOS
|
| 93 |
+
with warnings.catch_warnings():
|
| 94 |
+
warnings.filterwarnings("ignore", category=DeprecationWarning) # suppress numpy==1.20 float warning
|
| 95 |
+
ct_model = ct.models.neural_network.quantization_utils.quantize_weights(ct_model, bits, mode)
|
| 96 |
+
else:
|
| 97 |
+
print('quantization only supported on macOS, skipping...')
|
| 98 |
+
|
| 99 |
+
f = opt.weights.replace('.pt', '.mlmodel') # filename
|
| 100 |
+
ct_model.save(f)
|
| 101 |
+
print('CoreML export success, saved as %s' % f)
|
| 102 |
+
except Exception as e:
|
| 103 |
+
print('CoreML export failure: %s' % e)
|
| 104 |
+
|
| 105 |
+
# TorchScript-Lite export
|
| 106 |
+
try:
|
| 107 |
+
print('\nStarting TorchScript-Lite export with torch %s...' % torch.__version__)
|
| 108 |
+
f = opt.weights.replace('.pt', '.torchscript.ptl') # filename
|
| 109 |
+
tsl = torch.jit.trace(model, img, strict=False)
|
| 110 |
+
tsl = optimize_for_mobile(tsl)
|
| 111 |
+
tsl._save_for_lite_interpreter(f)
|
| 112 |
+
print('TorchScript-Lite export success, saved as %s' % f)
|
| 113 |
+
except Exception as e:
|
| 114 |
+
print('TorchScript-Lite export failure: %s' % e)
|
| 115 |
+
|
| 116 |
+
# ONNX export
|
| 117 |
+
try:
|
| 118 |
+
import onnx
|
| 119 |
+
|
| 120 |
+
print('\nStarting ONNX export with onnx %s...' % onnx.__version__)
|
| 121 |
+
f = opt.weights.replace('.pt', '.onnx') # filename
|
| 122 |
+
model.eval()
|
| 123 |
+
output_names = ['classes', 'boxes'] if y is None else ['output']
|
| 124 |
+
dynamic_axes = None
|
| 125 |
+
if opt.dynamic:
|
| 126 |
+
dynamic_axes = {'images': {0: 'batch', 2: 'height', 3: 'width'}, # size(1,3,640,640)
|
| 127 |
+
'output': {0: 'batch', 2: 'y', 3: 'x'}}
|
| 128 |
+
if opt.dynamic_batch:
|
| 129 |
+
opt.batch_size = 'batch'
|
| 130 |
+
dynamic_axes = {
|
| 131 |
+
'images': {
|
| 132 |
+
0: 'batch',
|
| 133 |
+
}, }
|
| 134 |
+
if opt.end2end and opt.max_wh is None:
|
| 135 |
+
output_axes = {
|
| 136 |
+
'num_dets': {0: 'batch'},
|
| 137 |
+
'det_boxes': {0: 'batch'},
|
| 138 |
+
'det_scores': {0: 'batch'},
|
| 139 |
+
'det_classes': {0: 'batch'},
|
| 140 |
+
}
|
| 141 |
+
else:
|
| 142 |
+
output_axes = {
|
| 143 |
+
'output': {0: 'batch'},
|
| 144 |
+
}
|
| 145 |
+
dynamic_axes.update(output_axes)
|
| 146 |
+
if opt.grid:
|
| 147 |
+
if opt.end2end:
|
| 148 |
+
print('\nStarting export end2end onnx model for %s...' % 'TensorRT' if opt.max_wh is None else 'onnxruntime')
|
| 149 |
+
model = End2End(model,opt.topk_all,opt.iou_thres,opt.conf_thres,opt.max_wh,device)
|
| 150 |
+
if opt.end2end and opt.max_wh is None:
|
| 151 |
+
output_names = ['num_dets', 'det_boxes', 'det_scores', 'det_classes']
|
| 152 |
+
shapes = [opt.batch_size, 1, opt.batch_size, opt.topk_all, 4,
|
| 153 |
+
opt.batch_size, opt.topk_all, opt.batch_size, opt.topk_all]
|
| 154 |
+
else:
|
| 155 |
+
output_names = ['output']
|
| 156 |
+
else:
|
| 157 |
+
model.model[-1].concat = True
|
| 158 |
+
|
| 159 |
+
torch.onnx.export(model, img, f, verbose=False, opset_version=12, input_names=['images'],
|
| 160 |
+
output_names=output_names,
|
| 161 |
+
dynamic_axes=dynamic_axes)
|
| 162 |
+
|
| 163 |
+
# Checks
|
| 164 |
+
onnx_model = onnx.load(f) # load onnx model
|
| 165 |
+
onnx.checker.check_model(onnx_model) # check onnx model
|
| 166 |
+
|
| 167 |
+
if opt.end2end and opt.max_wh is None:
|
| 168 |
+
for i in onnx_model.graph.output:
|
| 169 |
+
for j in i.type.tensor_type.shape.dim:
|
| 170 |
+
j.dim_param = str(shapes.pop(0))
|
| 171 |
+
|
| 172 |
+
# print(onnx.helper.printable_graph(onnx_model.graph)) # print a human readable model
|
| 173 |
+
|
| 174 |
+
# # Metadata
|
| 175 |
+
# d = {'stride': int(max(model.stride))}
|
| 176 |
+
# for k, v in d.items():
|
| 177 |
+
# meta = onnx_model.metadata_props.add()
|
| 178 |
+
# meta.key, meta.value = k, str(v)
|
| 179 |
+
# onnx.save(onnx_model, f)
|
| 180 |
+
|
| 181 |
+
if opt.simplify:
|
| 182 |
+
try:
|
| 183 |
+
import onnxsim
|
| 184 |
+
|
| 185 |
+
print('\nStarting to simplify ONNX...')
|
| 186 |
+
onnx_model, check = onnxsim.simplify(onnx_model)
|
| 187 |
+
assert check, 'assert check failed'
|
| 188 |
+
except Exception as e:
|
| 189 |
+
print(f'Simplifier failure: {e}')
|
| 190 |
+
|
| 191 |
+
# print(onnx.helper.printable_graph(onnx_model.graph)) # print a human readable model
|
| 192 |
+
onnx.save(onnx_model,f)
|
| 193 |
+
print('ONNX export success, saved as %s' % f)
|
| 194 |
+
|
| 195 |
+
if opt.include_nms:
|
| 196 |
+
print('Registering NMS plugin for ONNX...')
|
| 197 |
+
mo = RegisterNMS(f)
|
| 198 |
+
mo.register_nms()
|
| 199 |
+
mo.save(f)
|
| 200 |
+
|
| 201 |
+
except Exception as e:
|
| 202 |
+
print('ONNX export failure: %s' % e)
|
| 203 |
+
|
| 204 |
+
# Finish
|
| 205 |
+
print('\nExport complete (%.2fs). Visualize with https://github.com/lutzroeder/netron.' % (time.time() - t))
|
detection/hubconf.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""PyTorch Hub models
|
| 2 |
+
|
| 3 |
+
Usage:
|
| 4 |
+
import torch
|
| 5 |
+
model = torch.hub.load('repo', 'model')
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
+
from models.yolo import Model
|
| 13 |
+
from utils.general import check_requirements, set_logging
|
| 14 |
+
from utils.google_utils import attempt_download
|
| 15 |
+
from utils.torch_utils import select_device
|
| 16 |
+
|
| 17 |
+
dependencies = ['torch', 'yaml']
|
| 18 |
+
check_requirements(Path(__file__).parent / 'requirements.txt', exclude=('pycocotools', 'thop'))
|
| 19 |
+
set_logging()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def create(name, pretrained, channels, classes, autoshape):
|
| 23 |
+
"""Creates a specified model
|
| 24 |
+
|
| 25 |
+
Arguments:
|
| 26 |
+
name (str): name of model, i.e. 'yolov7'
|
| 27 |
+
pretrained (bool): load pretrained weights into the model
|
| 28 |
+
channels (int): number of input channels
|
| 29 |
+
classes (int): number of model classes
|
| 30 |
+
|
| 31 |
+
Returns:
|
| 32 |
+
pytorch model
|
| 33 |
+
"""
|
| 34 |
+
try:
|
| 35 |
+
cfg = list((Path(__file__).parent / 'cfg').rglob(f'{name}.yaml'))[0] # model.yaml path
|
| 36 |
+
model = Model(cfg, channels, classes)
|
| 37 |
+
if pretrained:
|
| 38 |
+
fname = f'{name}.pt' # checkpoint filename
|
| 39 |
+
attempt_download(fname) # download if not found locally
|
| 40 |
+
ckpt = torch.load(fname, map_location=torch.device('cpu')) # load
|
| 41 |
+
msd = model.state_dict() # model state_dict
|
| 42 |
+
csd = ckpt['model'].float().state_dict() # checkpoint state_dict as FP32
|
| 43 |
+
csd = {k: v for k, v in csd.items() if msd[k].shape == v.shape} # filter
|
| 44 |
+
model.load_state_dict(csd, strict=False) # load
|
| 45 |
+
if len(ckpt['model'].names) == classes:
|
| 46 |
+
model.names = ckpt['model'].names # set class names attribute
|
| 47 |
+
if autoshape:
|
| 48 |
+
model = model.autoshape() # for file/URI/PIL/cv2/np inputs and NMS
|
| 49 |
+
device = select_device('0' if torch.cuda.is_available() else 'cpu') # default to GPU if available
|
| 50 |
+
return model.to(device)
|
| 51 |
+
|
| 52 |
+
except Exception as e:
|
| 53 |
+
s = 'Cache maybe be out of date, try force_reload=True.'
|
| 54 |
+
raise Exception(s) from e
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def custom(path_or_model='path/to/model.pt', autoshape=True):
|
| 58 |
+
"""custom mode
|
| 59 |
+
|
| 60 |
+
Arguments (3 options):
|
| 61 |
+
path_or_model (str): 'path/to/model.pt'
|
| 62 |
+
path_or_model (dict): torch.load('path/to/model.pt')
|
| 63 |
+
path_or_model (nn.Module): torch.load('path/to/model.pt')['model']
|
| 64 |
+
|
| 65 |
+
Returns:
|
| 66 |
+
pytorch model
|
| 67 |
+
"""
|
| 68 |
+
model = torch.load(path_or_model, map_location=torch.device('cpu')) if isinstance(path_or_model, str) else path_or_model # load checkpoint
|
| 69 |
+
if isinstance(model, dict):
|
| 70 |
+
model = model['ema' if model.get('ema') else 'model'] # load model
|
| 71 |
+
|
| 72 |
+
hub_model = Model(model.yaml).to(next(model.parameters()).device) # create
|
| 73 |
+
hub_model.load_state_dict(model.float().state_dict()) # load state_dict
|
| 74 |
+
hub_model.names = model.names # class names
|
| 75 |
+
if autoshape:
|
| 76 |
+
hub_model = hub_model.autoshape() # for file/URI/PIL/cv2/np inputs and NMS
|
| 77 |
+
device = select_device('0' if torch.cuda.is_available() else 'cpu') # default to GPU if available
|
| 78 |
+
return hub_model.to(device)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def yolov7(pretrained=True, channels=3, classes=80, autoshape=True):
|
| 82 |
+
return create('yolov7', pretrained, channels, classes, autoshape)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
if __name__ == '__main__':
|
| 86 |
+
model = custom(path_or_model='yolov7.pt') # custom example
|
| 87 |
+
# model = create(name='yolov7', pretrained=True, channels=3, classes=80, autoshape=True) # pretrained example
|
| 88 |
+
|
| 89 |
+
# Verify inference
|
| 90 |
+
import numpy as np
|
| 91 |
+
from PIL import Image
|
| 92 |
+
|
| 93 |
+
imgs = [np.zeros((640, 480, 3))]
|
| 94 |
+
|
| 95 |
+
results = model(imgs) # batched inference
|
| 96 |
+
results.print()
|
| 97 |
+
results.save()
|
detection/models/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# init
|
detection/models/common.py
ADDED
|
@@ -0,0 +1,2019 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
from copy import copy
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import requests
|
| 8 |
+
import torch
|
| 9 |
+
import torch.nn as nn
|
| 10 |
+
import torch.nn.functional as F
|
| 11 |
+
from torchvision.ops import DeformConv2d
|
| 12 |
+
from PIL import Image
|
| 13 |
+
from torch.cuda import amp
|
| 14 |
+
|
| 15 |
+
from utils.datasets import letterbox
|
| 16 |
+
from utils.general import non_max_suppression, make_divisible, scale_coords, increment_path, xyxy2xywh
|
| 17 |
+
from utils.plots import color_list, plot_one_box
|
| 18 |
+
from utils.torch_utils import time_synchronized
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
##### basic ####
|
| 22 |
+
|
| 23 |
+
def autopad(k, p=None): # kernel, padding
|
| 24 |
+
# Pad to 'same'
|
| 25 |
+
if p is None:
|
| 26 |
+
p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # auto-pad
|
| 27 |
+
return p
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class MP(nn.Module):
|
| 31 |
+
def __init__(self, k=2):
|
| 32 |
+
super(MP, self).__init__()
|
| 33 |
+
self.m = nn.MaxPool2d(kernel_size=k, stride=k)
|
| 34 |
+
|
| 35 |
+
def forward(self, x):
|
| 36 |
+
return self.m(x)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class SP(nn.Module):
|
| 40 |
+
def __init__(self, k=3, s=1):
|
| 41 |
+
super(SP, self).__init__()
|
| 42 |
+
self.m = nn.MaxPool2d(kernel_size=k, stride=s, padding=k // 2)
|
| 43 |
+
|
| 44 |
+
def forward(self, x):
|
| 45 |
+
return self.m(x)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class ReOrg(nn.Module):
|
| 49 |
+
def __init__(self):
|
| 50 |
+
super(ReOrg, self).__init__()
|
| 51 |
+
|
| 52 |
+
def forward(self, x): # x(b,c,w,h) -> y(b,4c,w/2,h/2)
|
| 53 |
+
return torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class Concat(nn.Module):
|
| 57 |
+
def __init__(self, dimension=1):
|
| 58 |
+
super(Concat, self).__init__()
|
| 59 |
+
self.d = dimension
|
| 60 |
+
|
| 61 |
+
def forward(self, x):
|
| 62 |
+
return torch.cat(x, self.d)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class Chuncat(nn.Module):
|
| 66 |
+
def __init__(self, dimension=1):
|
| 67 |
+
super(Chuncat, self).__init__()
|
| 68 |
+
self.d = dimension
|
| 69 |
+
|
| 70 |
+
def forward(self, x):
|
| 71 |
+
x1 = []
|
| 72 |
+
x2 = []
|
| 73 |
+
for xi in x:
|
| 74 |
+
xi1, xi2 = xi.chunk(2, self.d)
|
| 75 |
+
x1.append(xi1)
|
| 76 |
+
x2.append(xi2)
|
| 77 |
+
return torch.cat(x1+x2, self.d)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class Shortcut(nn.Module):
|
| 81 |
+
def __init__(self, dimension=0):
|
| 82 |
+
super(Shortcut, self).__init__()
|
| 83 |
+
self.d = dimension
|
| 84 |
+
|
| 85 |
+
def forward(self, x):
|
| 86 |
+
return x[0]+x[1]
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class Foldcut(nn.Module):
|
| 90 |
+
def __init__(self, dimension=0):
|
| 91 |
+
super(Foldcut, self).__init__()
|
| 92 |
+
self.d = dimension
|
| 93 |
+
|
| 94 |
+
def forward(self, x):
|
| 95 |
+
x1, x2 = x.chunk(2, self.d)
|
| 96 |
+
return x1+x2
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class Conv(nn.Module):
|
| 100 |
+
# Standard convolution
|
| 101 |
+
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups
|
| 102 |
+
super(Conv, self).__init__()
|
| 103 |
+
self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)
|
| 104 |
+
self.bn = nn.BatchNorm2d(c2)
|
| 105 |
+
self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity())
|
| 106 |
+
|
| 107 |
+
def forward(self, x):
|
| 108 |
+
return self.act(self.bn(self.conv(x)))
|
| 109 |
+
|
| 110 |
+
def fuseforward(self, x):
|
| 111 |
+
return self.act(self.conv(x))
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class RobustConv(nn.Module):
|
| 115 |
+
# Robust convolution (use high kernel size 7-11 for: downsampling and other layers). Train for 300 - 450 epochs.
|
| 116 |
+
def __init__(self, c1, c2, k=7, s=1, p=None, g=1, act=True, layer_scale_init_value=1e-6): # ch_in, ch_out, kernel, stride, padding, groups
|
| 117 |
+
super(RobustConv, self).__init__()
|
| 118 |
+
self.conv_dw = Conv(c1, c1, k=k, s=s, p=p, g=c1, act=act)
|
| 119 |
+
self.conv1x1 = nn.Conv2d(c1, c2, 1, 1, 0, groups=1, bias=True)
|
| 120 |
+
self.gamma = nn.Parameter(layer_scale_init_value * torch.ones(c2)) if layer_scale_init_value > 0 else None
|
| 121 |
+
|
| 122 |
+
def forward(self, x):
|
| 123 |
+
x = x.to(memory_format=torch.channels_last)
|
| 124 |
+
x = self.conv1x1(self.conv_dw(x))
|
| 125 |
+
if self.gamma is not None:
|
| 126 |
+
x = x.mul(self.gamma.reshape(1, -1, 1, 1))
|
| 127 |
+
return x
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
class RobustConv2(nn.Module):
|
| 131 |
+
# Robust convolution 2 (use [32, 5, 2] or [32, 7, 4] or [32, 11, 8] for one of the paths in CSP).
|
| 132 |
+
def __init__(self, c1, c2, k=7, s=4, p=None, g=1, act=True, layer_scale_init_value=1e-6): # ch_in, ch_out, kernel, stride, padding, groups
|
| 133 |
+
super(RobustConv2, self).__init__()
|
| 134 |
+
self.conv_strided = Conv(c1, c1, k=k, s=s, p=p, g=c1, act=act)
|
| 135 |
+
self.conv_deconv = nn.ConvTranspose2d(in_channels=c1, out_channels=c2, kernel_size=s, stride=s,
|
| 136 |
+
padding=0, bias=True, dilation=1, groups=1
|
| 137 |
+
)
|
| 138 |
+
self.gamma = nn.Parameter(layer_scale_init_value * torch.ones(c2)) if layer_scale_init_value > 0 else None
|
| 139 |
+
|
| 140 |
+
def forward(self, x):
|
| 141 |
+
x = self.conv_deconv(self.conv_strided(x))
|
| 142 |
+
if self.gamma is not None:
|
| 143 |
+
x = x.mul(self.gamma.reshape(1, -1, 1, 1))
|
| 144 |
+
return x
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def DWConv(c1, c2, k=1, s=1, act=True):
|
| 148 |
+
# Depthwise convolution
|
| 149 |
+
return Conv(c1, c2, k, s, g=math.gcd(c1, c2), act=act)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
class GhostConv(nn.Module):
|
| 153 |
+
# Ghost Convolution https://github.com/huawei-noah/ghostnet
|
| 154 |
+
def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups
|
| 155 |
+
super(GhostConv, self).__init__()
|
| 156 |
+
c_ = c2 // 2 # hidden channels
|
| 157 |
+
self.cv1 = Conv(c1, c_, k, s, None, g, act)
|
| 158 |
+
self.cv2 = Conv(c_, c_, 5, 1, None, c_, act)
|
| 159 |
+
|
| 160 |
+
def forward(self, x):
|
| 161 |
+
y = self.cv1(x)
|
| 162 |
+
return torch.cat([y, self.cv2(y)], 1)
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
class Stem(nn.Module):
|
| 166 |
+
# Stem
|
| 167 |
+
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups
|
| 168 |
+
super(Stem, self).__init__()
|
| 169 |
+
c_ = int(c2/2) # hidden channels
|
| 170 |
+
self.cv1 = Conv(c1, c_, 3, 2)
|
| 171 |
+
self.cv2 = Conv(c_, c_, 1, 1)
|
| 172 |
+
self.cv3 = Conv(c_, c_, 3, 2)
|
| 173 |
+
self.pool = torch.nn.MaxPool2d(2, stride=2)
|
| 174 |
+
self.cv4 = Conv(2 * c_, c2, 1, 1)
|
| 175 |
+
|
| 176 |
+
def forward(self, x):
|
| 177 |
+
x = self.cv1(x)
|
| 178 |
+
return self.cv4(torch.cat((self.cv3(self.cv2(x)), self.pool(x)), dim=1))
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
class DownC(nn.Module):
|
| 182 |
+
# Spatial pyramid pooling layer used in YOLOv3-SPP
|
| 183 |
+
def __init__(self, c1, c2, n=1, k=2):
|
| 184 |
+
super(DownC, self).__init__()
|
| 185 |
+
c_ = int(c1) # hidden channels
|
| 186 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 187 |
+
self.cv2 = Conv(c_, c2//2, 3, k)
|
| 188 |
+
self.cv3 = Conv(c1, c2//2, 1, 1)
|
| 189 |
+
self.mp = nn.MaxPool2d(kernel_size=k, stride=k)
|
| 190 |
+
|
| 191 |
+
def forward(self, x):
|
| 192 |
+
return torch.cat((self.cv2(self.cv1(x)), self.cv3(self.mp(x))), dim=1)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
class SPP(nn.Module):
|
| 196 |
+
# Spatial pyramid pooling layer used in YOLOv3-SPP
|
| 197 |
+
def __init__(self, c1, c2, k=(5, 9, 13)):
|
| 198 |
+
super(SPP, self).__init__()
|
| 199 |
+
c_ = c1 // 2 # hidden channels
|
| 200 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 201 |
+
self.cv2 = Conv(c_ * (len(k) + 1), c2, 1, 1)
|
| 202 |
+
self.m = nn.ModuleList([nn.MaxPool2d(kernel_size=x, stride=1, padding=x // 2) for x in k])
|
| 203 |
+
|
| 204 |
+
def forward(self, x):
|
| 205 |
+
x = self.cv1(x)
|
| 206 |
+
return self.cv2(torch.cat([x] + [m(x) for m in self.m], 1))
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
class Bottleneck(nn.Module):
|
| 210 |
+
# Darknet bottleneck
|
| 211 |
+
def __init__(self, c1, c2, shortcut=True, g=1, e=0.5): # ch_in, ch_out, shortcut, groups, expansion
|
| 212 |
+
super(Bottleneck, self).__init__()
|
| 213 |
+
c_ = int(c2 * e) # hidden channels
|
| 214 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 215 |
+
self.cv2 = Conv(c_, c2, 3, 1, g=g)
|
| 216 |
+
self.add = shortcut and c1 == c2
|
| 217 |
+
|
| 218 |
+
def forward(self, x):
|
| 219 |
+
return x + self.cv2(self.cv1(x)) if self.add else self.cv2(self.cv1(x))
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
class Res(nn.Module):
|
| 223 |
+
# ResNet bottleneck
|
| 224 |
+
def __init__(self, c1, c2, shortcut=True, g=1, e=0.5): # ch_in, ch_out, shortcut, groups, expansion
|
| 225 |
+
super(Res, self).__init__()
|
| 226 |
+
c_ = int(c2 * e) # hidden channels
|
| 227 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 228 |
+
self.cv2 = Conv(c_, c_, 3, 1, g=g)
|
| 229 |
+
self.cv3 = Conv(c_, c2, 1, 1)
|
| 230 |
+
self.add = shortcut and c1 == c2
|
| 231 |
+
|
| 232 |
+
def forward(self, x):
|
| 233 |
+
return x + self.cv3(self.cv2(self.cv1(x))) if self.add else self.cv3(self.cv2(self.cv1(x)))
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
class ResX(Res):
|
| 237 |
+
# ResNet bottleneck
|
| 238 |
+
def __init__(self, c1, c2, shortcut=True, g=32, e=0.5): # ch_in, ch_out, shortcut, groups, expansion
|
| 239 |
+
super().__init__(c1, c2, shortcut, g, e)
|
| 240 |
+
c_ = int(c2 * e) # hidden channels
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
class Ghost(nn.Module):
|
| 244 |
+
# Ghost Bottleneck https://github.com/huawei-noah/ghostnet
|
| 245 |
+
def __init__(self, c1, c2, k=3, s=1): # ch_in, ch_out, kernel, stride
|
| 246 |
+
super(Ghost, self).__init__()
|
| 247 |
+
c_ = c2 // 2
|
| 248 |
+
self.conv = nn.Sequential(GhostConv(c1, c_, 1, 1), # pw
|
| 249 |
+
DWConv(c_, c_, k, s, act=False) if s == 2 else nn.Identity(), # dw
|
| 250 |
+
GhostConv(c_, c2, 1, 1, act=False)) # pw-linear
|
| 251 |
+
self.shortcut = nn.Sequential(DWConv(c1, c1, k, s, act=False),
|
| 252 |
+
Conv(c1, c2, 1, 1, act=False)) if s == 2 else nn.Identity()
|
| 253 |
+
|
| 254 |
+
def forward(self, x):
|
| 255 |
+
return self.conv(x) + self.shortcut(x)
|
| 256 |
+
|
| 257 |
+
##### end of basic #####
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
##### cspnet #####
|
| 261 |
+
|
| 262 |
+
class SPPCSPC(nn.Module):
|
| 263 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 264 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5, k=(5, 9, 13)):
|
| 265 |
+
super(SPPCSPC, self).__init__()
|
| 266 |
+
c_ = int(2 * c2 * e) # hidden channels
|
| 267 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 268 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 269 |
+
self.cv3 = Conv(c_, c_, 3, 1)
|
| 270 |
+
self.cv4 = Conv(c_, c_, 1, 1)
|
| 271 |
+
self.m = nn.ModuleList([nn.MaxPool2d(kernel_size=x, stride=1, padding=x // 2) for x in k])
|
| 272 |
+
self.cv5 = Conv(4 * c_, c_, 1, 1)
|
| 273 |
+
self.cv6 = Conv(c_, c_, 3, 1)
|
| 274 |
+
self.cv7 = Conv(2 * c_, c2, 1, 1)
|
| 275 |
+
|
| 276 |
+
def forward(self, x):
|
| 277 |
+
x1 = self.cv4(self.cv3(self.cv1(x)))
|
| 278 |
+
y1 = self.cv6(self.cv5(torch.cat([x1] + [m(x1) for m in self.m], 1)))
|
| 279 |
+
y2 = self.cv2(x)
|
| 280 |
+
return self.cv7(torch.cat((y1, y2), dim=1))
|
| 281 |
+
|
| 282 |
+
class GhostSPPCSPC(SPPCSPC):
|
| 283 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 284 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5, k=(5, 9, 13)):
|
| 285 |
+
super().__init__(c1, c2, n, shortcut, g, e, k)
|
| 286 |
+
c_ = int(2 * c2 * e) # hidden channels
|
| 287 |
+
self.cv1 = GhostConv(c1, c_, 1, 1)
|
| 288 |
+
self.cv2 = GhostConv(c1, c_, 1, 1)
|
| 289 |
+
self.cv3 = GhostConv(c_, c_, 3, 1)
|
| 290 |
+
self.cv4 = GhostConv(c_, c_, 1, 1)
|
| 291 |
+
self.cv5 = GhostConv(4 * c_, c_, 1, 1)
|
| 292 |
+
self.cv6 = GhostConv(c_, c_, 3, 1)
|
| 293 |
+
self.cv7 = GhostConv(2 * c_, c2, 1, 1)
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
class GhostStem(Stem):
|
| 297 |
+
# Stem
|
| 298 |
+
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups
|
| 299 |
+
super().__init__(c1, c2, k, s, p, g, act)
|
| 300 |
+
c_ = int(c2/2) # hidden channels
|
| 301 |
+
self.cv1 = GhostConv(c1, c_, 3, 2)
|
| 302 |
+
self.cv2 = GhostConv(c_, c_, 1, 1)
|
| 303 |
+
self.cv3 = GhostConv(c_, c_, 3, 2)
|
| 304 |
+
self.cv4 = GhostConv(2 * c_, c2, 1, 1)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
class BottleneckCSPA(nn.Module):
|
| 308 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 309 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 310 |
+
super(BottleneckCSPA, self).__init__()
|
| 311 |
+
c_ = int(c2 * e) # hidden channels
|
| 312 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 313 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 314 |
+
self.cv3 = Conv(2 * c_, c2, 1, 1)
|
| 315 |
+
self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 316 |
+
|
| 317 |
+
def forward(self, x):
|
| 318 |
+
y1 = self.m(self.cv1(x))
|
| 319 |
+
y2 = self.cv2(x)
|
| 320 |
+
return self.cv3(torch.cat((y1, y2), dim=1))
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
class BottleneckCSPB(nn.Module):
|
| 324 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 325 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 326 |
+
super(BottleneckCSPB, self).__init__()
|
| 327 |
+
c_ = int(c2) # hidden channels
|
| 328 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 329 |
+
self.cv2 = Conv(c_, c_, 1, 1)
|
| 330 |
+
self.cv3 = Conv(2 * c_, c2, 1, 1)
|
| 331 |
+
self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 332 |
+
|
| 333 |
+
def forward(self, x):
|
| 334 |
+
x1 = self.cv1(x)
|
| 335 |
+
y1 = self.m(x1)
|
| 336 |
+
y2 = self.cv2(x1)
|
| 337 |
+
return self.cv3(torch.cat((y1, y2), dim=1))
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
class BottleneckCSPC(nn.Module):
|
| 341 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 342 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 343 |
+
super(BottleneckCSPC, self).__init__()
|
| 344 |
+
c_ = int(c2 * e) # hidden channels
|
| 345 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 346 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 347 |
+
self.cv3 = Conv(c_, c_, 1, 1)
|
| 348 |
+
self.cv4 = Conv(2 * c_, c2, 1, 1)
|
| 349 |
+
self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 350 |
+
|
| 351 |
+
def forward(self, x):
|
| 352 |
+
y1 = self.cv3(self.m(self.cv1(x)))
|
| 353 |
+
y2 = self.cv2(x)
|
| 354 |
+
return self.cv4(torch.cat((y1, y2), dim=1))
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
class ResCSPA(BottleneckCSPA):
|
| 358 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 359 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 360 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 361 |
+
c_ = int(c2 * e) # hidden channels
|
| 362 |
+
self.m = nn.Sequential(*[Res(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
class ResCSPB(BottleneckCSPB):
|
| 366 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 367 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 368 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 369 |
+
c_ = int(c2) # hidden channels
|
| 370 |
+
self.m = nn.Sequential(*[Res(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
class ResCSPC(BottleneckCSPC):
|
| 374 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 375 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 376 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 377 |
+
c_ = int(c2 * e) # hidden channels
|
| 378 |
+
self.m = nn.Sequential(*[Res(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
class ResXCSPA(ResCSPA):
|
| 382 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 383 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=32, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 384 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 385 |
+
c_ = int(c2 * e) # hidden channels
|
| 386 |
+
self.m = nn.Sequential(*[Res(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
class ResXCSPB(ResCSPB):
|
| 390 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 391 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=32, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 392 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 393 |
+
c_ = int(c2) # hidden channels
|
| 394 |
+
self.m = nn.Sequential(*[Res(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
class ResXCSPC(ResCSPC):
|
| 398 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 399 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=32, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 400 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 401 |
+
c_ = int(c2 * e) # hidden channels
|
| 402 |
+
self.m = nn.Sequential(*[Res(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
class GhostCSPA(BottleneckCSPA):
|
| 406 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 407 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 408 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 409 |
+
c_ = int(c2 * e) # hidden channels
|
| 410 |
+
self.m = nn.Sequential(*[Ghost(c_, c_) for _ in range(n)])
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
class GhostCSPB(BottleneckCSPB):
|
| 414 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 415 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 416 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 417 |
+
c_ = int(c2) # hidden channels
|
| 418 |
+
self.m = nn.Sequential(*[Ghost(c_, c_) for _ in range(n)])
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
class GhostCSPC(BottleneckCSPC):
|
| 422 |
+
# CSP https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 423 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 424 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 425 |
+
c_ = int(c2 * e) # hidden channels
|
| 426 |
+
self.m = nn.Sequential(*[Ghost(c_, c_) for _ in range(n)])
|
| 427 |
+
|
| 428 |
+
##### end of cspnet #####
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
##### yolor #####
|
| 432 |
+
|
| 433 |
+
class ImplicitA(nn.Module):
|
| 434 |
+
def __init__(self, channel, mean=0., std=.02):
|
| 435 |
+
super(ImplicitA, self).__init__()
|
| 436 |
+
self.channel = channel
|
| 437 |
+
self.mean = mean
|
| 438 |
+
self.std = std
|
| 439 |
+
self.implicit = nn.Parameter(torch.zeros(1, channel, 1, 1))
|
| 440 |
+
nn.init.normal_(self.implicit, mean=self.mean, std=self.std)
|
| 441 |
+
|
| 442 |
+
def forward(self, x):
|
| 443 |
+
return self.implicit + x
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
class ImplicitM(nn.Module):
|
| 447 |
+
def __init__(self, channel, mean=0., std=.02):
|
| 448 |
+
super(ImplicitM, self).__init__()
|
| 449 |
+
self.channel = channel
|
| 450 |
+
self.mean = mean
|
| 451 |
+
self.std = std
|
| 452 |
+
self.implicit = nn.Parameter(torch.ones(1, channel, 1, 1))
|
| 453 |
+
nn.init.normal_(self.implicit, mean=self.mean, std=self.std)
|
| 454 |
+
|
| 455 |
+
def forward(self, x):
|
| 456 |
+
return self.implicit * x
|
| 457 |
+
|
| 458 |
+
##### end of yolor #####
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
##### repvgg #####
|
| 462 |
+
|
| 463 |
+
class RepConv(nn.Module):
|
| 464 |
+
# Represented convolution
|
| 465 |
+
# https://arxiv.org/abs/2101.03697
|
| 466 |
+
|
| 467 |
+
def __init__(self, c1, c2, k=3, s=1, p=None, g=1, act=True, deploy=False):
|
| 468 |
+
super(RepConv, self).__init__()
|
| 469 |
+
|
| 470 |
+
self.deploy = deploy
|
| 471 |
+
self.groups = g
|
| 472 |
+
self.in_channels = c1
|
| 473 |
+
self.out_channels = c2
|
| 474 |
+
|
| 475 |
+
assert k == 3
|
| 476 |
+
assert autopad(k, p) == 1
|
| 477 |
+
|
| 478 |
+
padding_11 = autopad(k, p) - k // 2
|
| 479 |
+
|
| 480 |
+
self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity())
|
| 481 |
+
|
| 482 |
+
if deploy:
|
| 483 |
+
self.rbr_reparam = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=True)
|
| 484 |
+
|
| 485 |
+
else:
|
| 486 |
+
self.rbr_identity = (nn.BatchNorm2d(num_features=c1) if c2 == c1 and s == 1 else None)
|
| 487 |
+
|
| 488 |
+
self.rbr_dense = nn.Sequential(
|
| 489 |
+
nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False),
|
| 490 |
+
nn.BatchNorm2d(num_features=c2),
|
| 491 |
+
)
|
| 492 |
+
|
| 493 |
+
self.rbr_1x1 = nn.Sequential(
|
| 494 |
+
nn.Conv2d( c1, c2, 1, s, padding_11, groups=g, bias=False),
|
| 495 |
+
nn.BatchNorm2d(num_features=c2),
|
| 496 |
+
)
|
| 497 |
+
|
| 498 |
+
def forward(self, inputs):
|
| 499 |
+
if hasattr(self, "rbr_reparam"):
|
| 500 |
+
return self.act(self.rbr_reparam(inputs))
|
| 501 |
+
|
| 502 |
+
if self.rbr_identity is None:
|
| 503 |
+
id_out = 0
|
| 504 |
+
else:
|
| 505 |
+
id_out = self.rbr_identity(inputs)
|
| 506 |
+
|
| 507 |
+
return self.act(self.rbr_dense(inputs) + self.rbr_1x1(inputs) + id_out)
|
| 508 |
+
|
| 509 |
+
def get_equivalent_kernel_bias(self):
|
| 510 |
+
kernel3x3, bias3x3 = self._fuse_bn_tensor(self.rbr_dense)
|
| 511 |
+
kernel1x1, bias1x1 = self._fuse_bn_tensor(self.rbr_1x1)
|
| 512 |
+
kernelid, biasid = self._fuse_bn_tensor(self.rbr_identity)
|
| 513 |
+
return (
|
| 514 |
+
kernel3x3 + self._pad_1x1_to_3x3_tensor(kernel1x1) + kernelid,
|
| 515 |
+
bias3x3 + bias1x1 + biasid,
|
| 516 |
+
)
|
| 517 |
+
|
| 518 |
+
def _pad_1x1_to_3x3_tensor(self, kernel1x1):
|
| 519 |
+
if kernel1x1 is None:
|
| 520 |
+
return 0
|
| 521 |
+
else:
|
| 522 |
+
return nn.functional.pad(kernel1x1, [1, 1, 1, 1])
|
| 523 |
+
|
| 524 |
+
def _fuse_bn_tensor(self, branch):
|
| 525 |
+
if branch is None:
|
| 526 |
+
return 0, 0
|
| 527 |
+
if isinstance(branch, nn.Sequential):
|
| 528 |
+
kernel = branch[0].weight
|
| 529 |
+
running_mean = branch[1].running_mean
|
| 530 |
+
running_var = branch[1].running_var
|
| 531 |
+
gamma = branch[1].weight
|
| 532 |
+
beta = branch[1].bias
|
| 533 |
+
eps = branch[1].eps
|
| 534 |
+
else:
|
| 535 |
+
assert isinstance(branch, nn.BatchNorm2d)
|
| 536 |
+
if not hasattr(self, "id_tensor"):
|
| 537 |
+
input_dim = self.in_channels // self.groups
|
| 538 |
+
kernel_value = np.zeros(
|
| 539 |
+
(self.in_channels, input_dim, 3, 3), dtype=np.float32
|
| 540 |
+
)
|
| 541 |
+
for i in range(self.in_channels):
|
| 542 |
+
kernel_value[i, i % input_dim, 1, 1] = 1
|
| 543 |
+
self.id_tensor = torch.from_numpy(kernel_value).to(branch.weight.device)
|
| 544 |
+
kernel = self.id_tensor
|
| 545 |
+
running_mean = branch.running_mean
|
| 546 |
+
running_var = branch.running_var
|
| 547 |
+
gamma = branch.weight
|
| 548 |
+
beta = branch.bias
|
| 549 |
+
eps = branch.eps
|
| 550 |
+
std = (running_var + eps).sqrt()
|
| 551 |
+
t = (gamma / std).reshape(-1, 1, 1, 1)
|
| 552 |
+
return kernel * t, beta - running_mean * gamma / std
|
| 553 |
+
|
| 554 |
+
def repvgg_convert(self):
|
| 555 |
+
kernel, bias = self.get_equivalent_kernel_bias()
|
| 556 |
+
return (
|
| 557 |
+
kernel.detach().cpu().numpy(),
|
| 558 |
+
bias.detach().cpu().numpy(),
|
| 559 |
+
)
|
| 560 |
+
|
| 561 |
+
def fuse_conv_bn(self, conv, bn):
|
| 562 |
+
|
| 563 |
+
std = (bn.running_var + bn.eps).sqrt()
|
| 564 |
+
bias = bn.bias - bn.running_mean * bn.weight / std
|
| 565 |
+
|
| 566 |
+
t = (bn.weight / std).reshape(-1, 1, 1, 1)
|
| 567 |
+
weights = conv.weight * t
|
| 568 |
+
|
| 569 |
+
bn = nn.Identity()
|
| 570 |
+
conv = nn.Conv2d(in_channels = conv.in_channels,
|
| 571 |
+
out_channels = conv.out_channels,
|
| 572 |
+
kernel_size = conv.kernel_size,
|
| 573 |
+
stride=conv.stride,
|
| 574 |
+
padding = conv.padding,
|
| 575 |
+
dilation = conv.dilation,
|
| 576 |
+
groups = conv.groups,
|
| 577 |
+
bias = True,
|
| 578 |
+
padding_mode = conv.padding_mode)
|
| 579 |
+
|
| 580 |
+
conv.weight = torch.nn.Parameter(weights)
|
| 581 |
+
conv.bias = torch.nn.Parameter(bias)
|
| 582 |
+
return conv
|
| 583 |
+
|
| 584 |
+
def fuse_repvgg_block(self):
|
| 585 |
+
if self.deploy:
|
| 586 |
+
return
|
| 587 |
+
print(f"RepConv.fuse_repvgg_block")
|
| 588 |
+
|
| 589 |
+
self.rbr_dense = self.fuse_conv_bn(self.rbr_dense[0], self.rbr_dense[1])
|
| 590 |
+
|
| 591 |
+
self.rbr_1x1 = self.fuse_conv_bn(self.rbr_1x1[0], self.rbr_1x1[1])
|
| 592 |
+
rbr_1x1_bias = self.rbr_1x1.bias
|
| 593 |
+
weight_1x1_expanded = torch.nn.functional.pad(self.rbr_1x1.weight, [1, 1, 1, 1])
|
| 594 |
+
|
| 595 |
+
# Fuse self.rbr_identity
|
| 596 |
+
if (isinstance(self.rbr_identity, nn.BatchNorm2d) or isinstance(self.rbr_identity, nn.modules.batchnorm.SyncBatchNorm)):
|
| 597 |
+
# print(f"fuse: rbr_identity == BatchNorm2d or SyncBatchNorm")
|
| 598 |
+
identity_conv_1x1 = nn.Conv2d(
|
| 599 |
+
in_channels=self.in_channels,
|
| 600 |
+
out_channels=self.out_channels,
|
| 601 |
+
kernel_size=1,
|
| 602 |
+
stride=1,
|
| 603 |
+
padding=0,
|
| 604 |
+
groups=self.groups,
|
| 605 |
+
bias=False)
|
| 606 |
+
identity_conv_1x1.weight.data = identity_conv_1x1.weight.data.to(self.rbr_1x1.weight.data.device)
|
| 607 |
+
identity_conv_1x1.weight.data = identity_conv_1x1.weight.data.squeeze().squeeze()
|
| 608 |
+
# print(f" identity_conv_1x1.weight = {identity_conv_1x1.weight.shape}")
|
| 609 |
+
identity_conv_1x1.weight.data.fill_(0.0)
|
| 610 |
+
identity_conv_1x1.weight.data.fill_diagonal_(1.0)
|
| 611 |
+
identity_conv_1x1.weight.data = identity_conv_1x1.weight.data.unsqueeze(2).unsqueeze(3)
|
| 612 |
+
# print(f" identity_conv_1x1.weight = {identity_conv_1x1.weight.shape}")
|
| 613 |
+
|
| 614 |
+
identity_conv_1x1 = self.fuse_conv_bn(identity_conv_1x1, self.rbr_identity)
|
| 615 |
+
bias_identity_expanded = identity_conv_1x1.bias
|
| 616 |
+
weight_identity_expanded = torch.nn.functional.pad(identity_conv_1x1.weight, [1, 1, 1, 1])
|
| 617 |
+
else:
|
| 618 |
+
# print(f"fuse: rbr_identity != BatchNorm2d, rbr_identity = {self.rbr_identity}")
|
| 619 |
+
bias_identity_expanded = torch.nn.Parameter( torch.zeros_like(rbr_1x1_bias) )
|
| 620 |
+
weight_identity_expanded = torch.nn.Parameter( torch.zeros_like(weight_1x1_expanded) )
|
| 621 |
+
|
| 622 |
+
|
| 623 |
+
#print(f"self.rbr_1x1.weight = {self.rbr_1x1.weight.shape}, ")
|
| 624 |
+
#print(f"weight_1x1_expanded = {weight_1x1_expanded.shape}, ")
|
| 625 |
+
#print(f"self.rbr_dense.weight = {self.rbr_dense.weight.shape}, ")
|
| 626 |
+
|
| 627 |
+
self.rbr_dense.weight = torch.nn.Parameter(self.rbr_dense.weight + weight_1x1_expanded + weight_identity_expanded)
|
| 628 |
+
self.rbr_dense.bias = torch.nn.Parameter(self.rbr_dense.bias + rbr_1x1_bias + bias_identity_expanded)
|
| 629 |
+
|
| 630 |
+
self.rbr_reparam = self.rbr_dense
|
| 631 |
+
self.deploy = True
|
| 632 |
+
|
| 633 |
+
if self.rbr_identity is not None:
|
| 634 |
+
del self.rbr_identity
|
| 635 |
+
self.rbr_identity = None
|
| 636 |
+
|
| 637 |
+
if self.rbr_1x1 is not None:
|
| 638 |
+
del self.rbr_1x1
|
| 639 |
+
self.rbr_1x1 = None
|
| 640 |
+
|
| 641 |
+
if self.rbr_dense is not None:
|
| 642 |
+
del self.rbr_dense
|
| 643 |
+
self.rbr_dense = None
|
| 644 |
+
|
| 645 |
+
|
| 646 |
+
class RepBottleneck(Bottleneck):
|
| 647 |
+
# Standard bottleneck
|
| 648 |
+
def __init__(self, c1, c2, shortcut=True, g=1, e=0.5): # ch_in, ch_out, shortcut, groups, expansion
|
| 649 |
+
super().__init__(c1, c2, shortcut=True, g=1, e=0.5)
|
| 650 |
+
c_ = int(c2 * e) # hidden channels
|
| 651 |
+
self.cv2 = RepConv(c_, c2, 3, 1, g=g)
|
| 652 |
+
|
| 653 |
+
|
| 654 |
+
class RepBottleneckCSPA(BottleneckCSPA):
|
| 655 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 656 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 657 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 658 |
+
c_ = int(c2 * e) # hidden channels
|
| 659 |
+
self.m = nn.Sequential(*[RepBottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 660 |
+
|
| 661 |
+
|
| 662 |
+
class RepBottleneckCSPB(BottleneckCSPB):
|
| 663 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 664 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 665 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 666 |
+
c_ = int(c2) # hidden channels
|
| 667 |
+
self.m = nn.Sequential(*[RepBottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 668 |
+
|
| 669 |
+
|
| 670 |
+
class RepBottleneckCSPC(BottleneckCSPC):
|
| 671 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 672 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 673 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 674 |
+
c_ = int(c2 * e) # hidden channels
|
| 675 |
+
self.m = nn.Sequential(*[RepBottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
class RepRes(Res):
|
| 679 |
+
# Standard bottleneck
|
| 680 |
+
def __init__(self, c1, c2, shortcut=True, g=1, e=0.5): # ch_in, ch_out, shortcut, groups, expansion
|
| 681 |
+
super().__init__(c1, c2, shortcut, g, e)
|
| 682 |
+
c_ = int(c2 * e) # hidden channels
|
| 683 |
+
self.cv2 = RepConv(c_, c_, 3, 1, g=g)
|
| 684 |
+
|
| 685 |
+
|
| 686 |
+
class RepResCSPA(ResCSPA):
|
| 687 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 688 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 689 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 690 |
+
c_ = int(c2 * e) # hidden channels
|
| 691 |
+
self.m = nn.Sequential(*[RepRes(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 692 |
+
|
| 693 |
+
|
| 694 |
+
class RepResCSPB(ResCSPB):
|
| 695 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 696 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 697 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 698 |
+
c_ = int(c2) # hidden channels
|
| 699 |
+
self.m = nn.Sequential(*[RepRes(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 700 |
+
|
| 701 |
+
|
| 702 |
+
class RepResCSPC(ResCSPC):
|
| 703 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 704 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 705 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 706 |
+
c_ = int(c2 * e) # hidden channels
|
| 707 |
+
self.m = nn.Sequential(*[RepRes(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 708 |
+
|
| 709 |
+
|
| 710 |
+
class RepResX(ResX):
|
| 711 |
+
# Standard bottleneck
|
| 712 |
+
def __init__(self, c1, c2, shortcut=True, g=32, e=0.5): # ch_in, ch_out, shortcut, groups, expansion
|
| 713 |
+
super().__init__(c1, c2, shortcut, g, e)
|
| 714 |
+
c_ = int(c2 * e) # hidden channels
|
| 715 |
+
self.cv2 = RepConv(c_, c_, 3, 1, g=g)
|
| 716 |
+
|
| 717 |
+
|
| 718 |
+
class RepResXCSPA(ResXCSPA):
|
| 719 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 720 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=32, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 721 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 722 |
+
c_ = int(c2 * e) # hidden channels
|
| 723 |
+
self.m = nn.Sequential(*[RepResX(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
class RepResXCSPB(ResXCSPB):
|
| 727 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 728 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=32, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 729 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 730 |
+
c_ = int(c2) # hidden channels
|
| 731 |
+
self.m = nn.Sequential(*[RepResX(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 732 |
+
|
| 733 |
+
|
| 734 |
+
class RepResXCSPC(ResXCSPC):
|
| 735 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 736 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=32, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 737 |
+
super().__init__(c1, c2, n, shortcut, g, e)
|
| 738 |
+
c_ = int(c2 * e) # hidden channels
|
| 739 |
+
self.m = nn.Sequential(*[RepResX(c_, c_, shortcut, g, e=0.5) for _ in range(n)])
|
| 740 |
+
|
| 741 |
+
##### end of repvgg #####
|
| 742 |
+
|
| 743 |
+
|
| 744 |
+
##### transformer #####
|
| 745 |
+
|
| 746 |
+
class TransformerLayer(nn.Module):
|
| 747 |
+
# Transformer layer https://arxiv.org/abs/2010.11929 (LayerNorm layers removed for better performance)
|
| 748 |
+
def __init__(self, c, num_heads):
|
| 749 |
+
super().__init__()
|
| 750 |
+
self.q = nn.Linear(c, c, bias=False)
|
| 751 |
+
self.k = nn.Linear(c, c, bias=False)
|
| 752 |
+
self.v = nn.Linear(c, c, bias=False)
|
| 753 |
+
self.ma = nn.MultiheadAttention(embed_dim=c, num_heads=num_heads)
|
| 754 |
+
self.fc1 = nn.Linear(c, c, bias=False)
|
| 755 |
+
self.fc2 = nn.Linear(c, c, bias=False)
|
| 756 |
+
|
| 757 |
+
def forward(self, x):
|
| 758 |
+
x = self.ma(self.q(x), self.k(x), self.v(x))[0] + x
|
| 759 |
+
x = self.fc2(self.fc1(x)) + x
|
| 760 |
+
return x
|
| 761 |
+
|
| 762 |
+
|
| 763 |
+
class TransformerBlock(nn.Module):
|
| 764 |
+
# Vision Transformer https://arxiv.org/abs/2010.11929
|
| 765 |
+
def __init__(self, c1, c2, num_heads, num_layers):
|
| 766 |
+
super().__init__()
|
| 767 |
+
self.conv = None
|
| 768 |
+
if c1 != c2:
|
| 769 |
+
self.conv = Conv(c1, c2)
|
| 770 |
+
self.linear = nn.Linear(c2, c2) # learnable position embedding
|
| 771 |
+
self.tr = nn.Sequential(*[TransformerLayer(c2, num_heads) for _ in range(num_layers)])
|
| 772 |
+
self.c2 = c2
|
| 773 |
+
|
| 774 |
+
def forward(self, x):
|
| 775 |
+
if self.conv is not None:
|
| 776 |
+
x = self.conv(x)
|
| 777 |
+
b, _, w, h = x.shape
|
| 778 |
+
p = x.flatten(2)
|
| 779 |
+
p = p.unsqueeze(0)
|
| 780 |
+
p = p.transpose(0, 3)
|
| 781 |
+
p = p.squeeze(3)
|
| 782 |
+
e = self.linear(p)
|
| 783 |
+
x = p + e
|
| 784 |
+
|
| 785 |
+
x = self.tr(x)
|
| 786 |
+
x = x.unsqueeze(3)
|
| 787 |
+
x = x.transpose(0, 3)
|
| 788 |
+
x = x.reshape(b, self.c2, w, h)
|
| 789 |
+
return x
|
| 790 |
+
|
| 791 |
+
##### end of transformer #####
|
| 792 |
+
|
| 793 |
+
|
| 794 |
+
##### yolov5 #####
|
| 795 |
+
|
| 796 |
+
class Focus(nn.Module):
|
| 797 |
+
# Focus wh information into c-space
|
| 798 |
+
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups
|
| 799 |
+
super(Focus, self).__init__()
|
| 800 |
+
self.conv = Conv(c1 * 4, c2, k, s, p, g, act)
|
| 801 |
+
# self.contract = Contract(gain=2)
|
| 802 |
+
|
| 803 |
+
def forward(self, x): # x(b,c,w,h) -> y(b,4c,w/2,h/2)
|
| 804 |
+
return self.conv(torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1))
|
| 805 |
+
# return self.conv(self.contract(x))
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
class SPPF(nn.Module):
|
| 809 |
+
# Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
|
| 810 |
+
def __init__(self, c1, c2, k=5): # equivalent to SPP(k=(5, 9, 13))
|
| 811 |
+
super().__init__()
|
| 812 |
+
c_ = c1 // 2 # hidden channels
|
| 813 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 814 |
+
self.cv2 = Conv(c_ * 4, c2, 1, 1)
|
| 815 |
+
self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
|
| 816 |
+
|
| 817 |
+
def forward(self, x):
|
| 818 |
+
x = self.cv1(x)
|
| 819 |
+
y1 = self.m(x)
|
| 820 |
+
y2 = self.m(y1)
|
| 821 |
+
return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))
|
| 822 |
+
|
| 823 |
+
|
| 824 |
+
class Contract(nn.Module):
|
| 825 |
+
# Contract width-height into channels, i.e. x(1,64,80,80) to x(1,256,40,40)
|
| 826 |
+
def __init__(self, gain=2):
|
| 827 |
+
super().__init__()
|
| 828 |
+
self.gain = gain
|
| 829 |
+
|
| 830 |
+
def forward(self, x):
|
| 831 |
+
N, C, H, W = x.size() # assert (H / s == 0) and (W / s == 0), 'Indivisible gain'
|
| 832 |
+
s = self.gain
|
| 833 |
+
x = x.view(N, C, H // s, s, W // s, s) # x(1,64,40,2,40,2)
|
| 834 |
+
x = x.permute(0, 3, 5, 1, 2, 4).contiguous() # x(1,2,2,64,40,40)
|
| 835 |
+
return x.view(N, C * s * s, H // s, W // s) # x(1,256,40,40)
|
| 836 |
+
|
| 837 |
+
|
| 838 |
+
class Expand(nn.Module):
|
| 839 |
+
# Expand channels into width-height, i.e. x(1,64,80,80) to x(1,16,160,160)
|
| 840 |
+
def __init__(self, gain=2):
|
| 841 |
+
super().__init__()
|
| 842 |
+
self.gain = gain
|
| 843 |
+
|
| 844 |
+
def forward(self, x):
|
| 845 |
+
N, C, H, W = x.size() # assert C / s ** 2 == 0, 'Indivisible gain'
|
| 846 |
+
s = self.gain
|
| 847 |
+
x = x.view(N, s, s, C // s ** 2, H, W) # x(1,2,2,16,80,80)
|
| 848 |
+
x = x.permute(0, 3, 4, 1, 5, 2).contiguous() # x(1,16,80,2,80,2)
|
| 849 |
+
return x.view(N, C // s ** 2, H * s, W * s) # x(1,16,160,160)
|
| 850 |
+
|
| 851 |
+
|
| 852 |
+
class NMS(nn.Module):
|
| 853 |
+
# Non-Maximum Suppression (NMS) module
|
| 854 |
+
conf = 0.25 # confidence threshold
|
| 855 |
+
iou = 0.45 # IoU threshold
|
| 856 |
+
classes = None # (optional list) filter by class
|
| 857 |
+
|
| 858 |
+
def __init__(self):
|
| 859 |
+
super(NMS, self).__init__()
|
| 860 |
+
|
| 861 |
+
def forward(self, x):
|
| 862 |
+
return non_max_suppression(x[0], conf_thres=self.conf, iou_thres=self.iou, classes=self.classes)
|
| 863 |
+
|
| 864 |
+
|
| 865 |
+
class autoShape(nn.Module):
|
| 866 |
+
# input-robust model wrapper for passing cv2/np/PIL/torch inputs. Includes preprocessing, inference and NMS
|
| 867 |
+
conf = 0.25 # NMS confidence threshold
|
| 868 |
+
iou = 0.45 # NMS IoU threshold
|
| 869 |
+
classes = None # (optional list) filter by class
|
| 870 |
+
|
| 871 |
+
def __init__(self, model):
|
| 872 |
+
super(autoShape, self).__init__()
|
| 873 |
+
self.model = model.eval()
|
| 874 |
+
|
| 875 |
+
def autoshape(self):
|
| 876 |
+
print('autoShape already enabled, skipping... ') # model already converted to model.autoshape()
|
| 877 |
+
return self
|
| 878 |
+
|
| 879 |
+
@torch.no_grad()
|
| 880 |
+
def forward(self, imgs, size=640, augment=False, profile=False):
|
| 881 |
+
# Inference from various sources. For height=640, width=1280, RGB images example inputs are:
|
| 882 |
+
# filename: imgs = 'data/samples/zidane.jpg'
|
| 883 |
+
# URI: = 'https://github.com/ultralytics/yolov5/releases/download/v1.0/zidane.jpg'
|
| 884 |
+
# OpenCV: = cv2.imread('image.jpg')[:,:,::-1] # HWC BGR to RGB x(640,1280,3)
|
| 885 |
+
# PIL: = Image.open('image.jpg') # HWC x(640,1280,3)
|
| 886 |
+
# numpy: = np.zeros((640,1280,3)) # HWC
|
| 887 |
+
# torch: = torch.zeros(16,3,320,640) # BCHW (scaled to size=640, 0-1 values)
|
| 888 |
+
# multiple: = [Image.open('image1.jpg'), Image.open('image2.jpg'), ...] # list of images
|
| 889 |
+
|
| 890 |
+
t = [time_synchronized()]
|
| 891 |
+
p = next(self.model.parameters()) # for device and type
|
| 892 |
+
if isinstance(imgs, torch.Tensor): # torch
|
| 893 |
+
with amp.autocast(enabled=p.device.type != 'cpu'):
|
| 894 |
+
return self.model(imgs.to(p.device).type_as(p), augment, profile) # inference
|
| 895 |
+
|
| 896 |
+
# Pre-process
|
| 897 |
+
n, imgs = (len(imgs), imgs) if isinstance(imgs, list) else (1, [imgs]) # number of images, list of images
|
| 898 |
+
shape0, shape1, files = [], [], [] # image and inference shapes, filenames
|
| 899 |
+
for i, im in enumerate(imgs):
|
| 900 |
+
f = f'image{i}' # filename
|
| 901 |
+
if isinstance(im, str): # filename or uri
|
| 902 |
+
im, f = np.asarray(Image.open(requests.get(im, stream=True).raw if im.startswith('http') else im)), im
|
| 903 |
+
elif isinstance(im, Image.Image): # PIL Image
|
| 904 |
+
im, f = np.asarray(im), getattr(im, 'filename', f) or f
|
| 905 |
+
files.append(Path(f).with_suffix('.jpg').name)
|
| 906 |
+
if im.shape[0] < 5: # image in CHW
|
| 907 |
+
im = im.transpose((1, 2, 0)) # reverse dataloader .transpose(2, 0, 1)
|
| 908 |
+
im = im[:, :, :3] if im.ndim == 3 else np.tile(im[:, :, None], 3) # enforce 3ch input
|
| 909 |
+
s = im.shape[:2] # HWC
|
| 910 |
+
shape0.append(s) # image shape
|
| 911 |
+
g = (size / max(s)) # gain
|
| 912 |
+
shape1.append([y * g for y in s])
|
| 913 |
+
imgs[i] = im # update
|
| 914 |
+
shape1 = [make_divisible(x, int(self.stride.max())) for x in np.stack(shape1, 0).max(0)] # inference shape
|
| 915 |
+
x = [letterbox(im, new_shape=shape1, auto=False)[0] for im in imgs] # pad
|
| 916 |
+
x = np.stack(x, 0) if n > 1 else x[0][None] # stack
|
| 917 |
+
x = np.ascontiguousarray(x.transpose((0, 3, 1, 2))) # BHWC to BCHW
|
| 918 |
+
x = torch.from_numpy(x).to(p.device).type_as(p) / 255. # uint8 to fp16/32
|
| 919 |
+
t.append(time_synchronized())
|
| 920 |
+
|
| 921 |
+
with amp.autocast(enabled=p.device.type != 'cpu'):
|
| 922 |
+
# Inference
|
| 923 |
+
y = self.model(x, augment, profile)[0] # forward
|
| 924 |
+
t.append(time_synchronized())
|
| 925 |
+
|
| 926 |
+
# Post-process
|
| 927 |
+
y = non_max_suppression(y, conf_thres=self.conf, iou_thres=self.iou, classes=self.classes) # NMS
|
| 928 |
+
for i in range(n):
|
| 929 |
+
scale_coords(shape1, y[i][:, :4], shape0[i])
|
| 930 |
+
|
| 931 |
+
t.append(time_synchronized())
|
| 932 |
+
return Detections(imgs, y, files, t, self.names, x.shape)
|
| 933 |
+
|
| 934 |
+
|
| 935 |
+
class Detections:
|
| 936 |
+
# detections class for YOLOv5 inference results
|
| 937 |
+
def __init__(self, imgs, pred, files, times=None, names=None, shape=None):
|
| 938 |
+
super(Detections, self).__init__()
|
| 939 |
+
d = pred[0].device # device
|
| 940 |
+
gn = [torch.tensor([*[im.shape[i] for i in [1, 0, 1, 0]], 1., 1.], device=d) for im in imgs] # normalizations
|
| 941 |
+
self.imgs = imgs # list of images as numpy arrays
|
| 942 |
+
self.pred = pred # list of tensors pred[0] = (xyxy, conf, cls)
|
| 943 |
+
self.names = names # class names
|
| 944 |
+
self.files = files # image filenames
|
| 945 |
+
self.xyxy = pred # xyxy pixels
|
| 946 |
+
self.xywh = [xyxy2xywh(x) for x in pred] # xywh pixels
|
| 947 |
+
self.xyxyn = [x / g for x, g in zip(self.xyxy, gn)] # xyxy normalized
|
| 948 |
+
self.xywhn = [x / g for x, g in zip(self.xywh, gn)] # xywh normalized
|
| 949 |
+
self.n = len(self.pred) # number of images (batch size)
|
| 950 |
+
self.t = tuple((times[i + 1] - times[i]) * 1000 / self.n for i in range(3)) # timestamps (ms)
|
| 951 |
+
self.s = shape # inference BCHW shape
|
| 952 |
+
|
| 953 |
+
def display(self, pprint=False, show=False, save=False, render=False, save_dir=''):
|
| 954 |
+
colors = color_list()
|
| 955 |
+
for i, (img, pred) in enumerate(zip(self.imgs, self.pred)):
|
| 956 |
+
str = f'image {i + 1}/{len(self.pred)}: {img.shape[0]}x{img.shape[1]} '
|
| 957 |
+
if pred is not None:
|
| 958 |
+
for c in pred[:, -1].unique():
|
| 959 |
+
n = (pred[:, -1] == c).sum() # detections per class
|
| 960 |
+
str += f"{n} {self.names[int(c)]}{'s' * (n > 1)}, " # add to string
|
| 961 |
+
if show or save or render:
|
| 962 |
+
for *box, conf, cls in pred: # xyxy, confidence, class
|
| 963 |
+
label = f'{self.names[int(cls)]} {conf:.2f}'
|
| 964 |
+
plot_one_box(box, img, label=label, color=colors[int(cls) % 10])
|
| 965 |
+
img = Image.fromarray(img.astype(np.uint8)) if isinstance(img, np.ndarray) else img # from np
|
| 966 |
+
if pprint:
|
| 967 |
+
print(str.rstrip(', '))
|
| 968 |
+
if show:
|
| 969 |
+
img.show(self.files[i]) # show
|
| 970 |
+
if save:
|
| 971 |
+
f = self.files[i]
|
| 972 |
+
img.save(Path(save_dir) / f) # save
|
| 973 |
+
print(f"{'Saved' * (i == 0)} {f}", end=',' if i < self.n - 1 else f' to {save_dir}\n')
|
| 974 |
+
if render:
|
| 975 |
+
self.imgs[i] = np.asarray(img)
|
| 976 |
+
|
| 977 |
+
def print(self):
|
| 978 |
+
self.display(pprint=True) # print results
|
| 979 |
+
print(f'Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {tuple(self.s)}' % self.t)
|
| 980 |
+
|
| 981 |
+
def show(self):
|
| 982 |
+
self.display(show=True) # show results
|
| 983 |
+
|
| 984 |
+
def save(self, save_dir='runs/hub/exp'):
|
| 985 |
+
save_dir = increment_path(save_dir, exist_ok=save_dir != 'runs/hub/exp') # increment save_dir
|
| 986 |
+
Path(save_dir).mkdir(parents=True, exist_ok=True)
|
| 987 |
+
self.display(save=True, save_dir=save_dir) # save results
|
| 988 |
+
|
| 989 |
+
def render(self):
|
| 990 |
+
self.display(render=True) # render results
|
| 991 |
+
return self.imgs
|
| 992 |
+
|
| 993 |
+
def pandas(self):
|
| 994 |
+
# return detections as pandas DataFrames, i.e. print(results.pandas().xyxy[0])
|
| 995 |
+
new = copy(self) # return copy
|
| 996 |
+
ca = 'xmin', 'ymin', 'xmax', 'ymax', 'confidence', 'class', 'name' # xyxy columns
|
| 997 |
+
cb = 'xcenter', 'ycenter', 'width', 'height', 'confidence', 'class', 'name' # xywh columns
|
| 998 |
+
for k, c in zip(['xyxy', 'xyxyn', 'xywh', 'xywhn'], [ca, ca, cb, cb]):
|
| 999 |
+
a = [[x[:5] + [int(x[5]), self.names[int(x[5])]] for x in x.tolist()] for x in getattr(self, k)] # update
|
| 1000 |
+
setattr(new, k, [pd.DataFrame(x, columns=c) for x in a])
|
| 1001 |
+
return new
|
| 1002 |
+
|
| 1003 |
+
def tolist(self):
|
| 1004 |
+
# return a list of Detections objects, i.e. 'for result in results.tolist():'
|
| 1005 |
+
x = [Detections([self.imgs[i]], [self.pred[i]], self.names, self.s) for i in range(self.n)]
|
| 1006 |
+
for d in x:
|
| 1007 |
+
for k in ['imgs', 'pred', 'xyxy', 'xyxyn', 'xywh', 'xywhn']:
|
| 1008 |
+
setattr(d, k, getattr(d, k)[0]) # pop out of list
|
| 1009 |
+
return x
|
| 1010 |
+
|
| 1011 |
+
def __len__(self):
|
| 1012 |
+
return self.n
|
| 1013 |
+
|
| 1014 |
+
|
| 1015 |
+
class Classify(nn.Module):
|
| 1016 |
+
# Classification head, i.e. x(b,c1,20,20) to x(b,c2)
|
| 1017 |
+
def __init__(self, c1, c2, k=1, s=1, p=None, g=1): # ch_in, ch_out, kernel, stride, padding, groups
|
| 1018 |
+
super(Classify, self).__init__()
|
| 1019 |
+
self.aap = nn.AdaptiveAvgPool2d(1) # to x(b,c1,1,1)
|
| 1020 |
+
self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g) # to x(b,c2,1,1)
|
| 1021 |
+
self.flat = nn.Flatten()
|
| 1022 |
+
|
| 1023 |
+
def forward(self, x):
|
| 1024 |
+
z = torch.cat([self.aap(y) for y in (x if isinstance(x, list) else [x])], 1) # cat if list
|
| 1025 |
+
return self.flat(self.conv(z)) # flatten to x(b,c2)
|
| 1026 |
+
|
| 1027 |
+
##### end of yolov5 ######
|
| 1028 |
+
|
| 1029 |
+
|
| 1030 |
+
##### orepa #####
|
| 1031 |
+
|
| 1032 |
+
def transI_fusebn(kernel, bn):
|
| 1033 |
+
gamma = bn.weight
|
| 1034 |
+
std = (bn.running_var + bn.eps).sqrt()
|
| 1035 |
+
return kernel * ((gamma / std).reshape(-1, 1, 1, 1)), bn.bias - bn.running_mean * gamma / std
|
| 1036 |
+
|
| 1037 |
+
|
| 1038 |
+
class ConvBN(nn.Module):
|
| 1039 |
+
def __init__(self, in_channels, out_channels, kernel_size,
|
| 1040 |
+
stride=1, padding=0, dilation=1, groups=1, deploy=False, nonlinear=None):
|
| 1041 |
+
super().__init__()
|
| 1042 |
+
if nonlinear is None:
|
| 1043 |
+
self.nonlinear = nn.Identity()
|
| 1044 |
+
else:
|
| 1045 |
+
self.nonlinear = nonlinear
|
| 1046 |
+
if deploy:
|
| 1047 |
+
self.conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size,
|
| 1048 |
+
stride=stride, padding=padding, dilation=dilation, groups=groups, bias=True)
|
| 1049 |
+
else:
|
| 1050 |
+
self.conv = nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size,
|
| 1051 |
+
stride=stride, padding=padding, dilation=dilation, groups=groups, bias=False)
|
| 1052 |
+
self.bn = nn.BatchNorm2d(num_features=out_channels)
|
| 1053 |
+
|
| 1054 |
+
def forward(self, x):
|
| 1055 |
+
if hasattr(self, 'bn'):
|
| 1056 |
+
return self.nonlinear(self.bn(self.conv(x)))
|
| 1057 |
+
else:
|
| 1058 |
+
return self.nonlinear(self.conv(x))
|
| 1059 |
+
|
| 1060 |
+
def switch_to_deploy(self):
|
| 1061 |
+
kernel, bias = transI_fusebn(self.conv.weight, self.bn)
|
| 1062 |
+
conv = nn.Conv2d(in_channels=self.conv.in_channels, out_channels=self.conv.out_channels, kernel_size=self.conv.kernel_size,
|
| 1063 |
+
stride=self.conv.stride, padding=self.conv.padding, dilation=self.conv.dilation, groups=self.conv.groups, bias=True)
|
| 1064 |
+
conv.weight.data = kernel
|
| 1065 |
+
conv.bias.data = bias
|
| 1066 |
+
for para in self.parameters():
|
| 1067 |
+
para.detach_()
|
| 1068 |
+
self.__delattr__('conv')
|
| 1069 |
+
self.__delattr__('bn')
|
| 1070 |
+
self.conv = conv
|
| 1071 |
+
|
| 1072 |
+
class OREPA_3x3_RepConv(nn.Module):
|
| 1073 |
+
|
| 1074 |
+
def __init__(self, in_channels, out_channels, kernel_size,
|
| 1075 |
+
stride=1, padding=0, dilation=1, groups=1,
|
| 1076 |
+
internal_channels_1x1_3x3=None,
|
| 1077 |
+
deploy=False, nonlinear=None, single_init=False):
|
| 1078 |
+
super(OREPA_3x3_RepConv, self).__init__()
|
| 1079 |
+
self.deploy = deploy
|
| 1080 |
+
|
| 1081 |
+
if nonlinear is None:
|
| 1082 |
+
self.nonlinear = nn.Identity()
|
| 1083 |
+
else:
|
| 1084 |
+
self.nonlinear = nonlinear
|
| 1085 |
+
|
| 1086 |
+
self.kernel_size = kernel_size
|
| 1087 |
+
self.in_channels = in_channels
|
| 1088 |
+
self.out_channels = out_channels
|
| 1089 |
+
self.groups = groups
|
| 1090 |
+
assert padding == kernel_size // 2
|
| 1091 |
+
|
| 1092 |
+
self.stride = stride
|
| 1093 |
+
self.padding = padding
|
| 1094 |
+
self.dilation = dilation
|
| 1095 |
+
|
| 1096 |
+
self.branch_counter = 0
|
| 1097 |
+
|
| 1098 |
+
self.weight_rbr_origin = nn.Parameter(torch.Tensor(out_channels, int(in_channels/self.groups), kernel_size, kernel_size))
|
| 1099 |
+
nn.init.kaiming_uniform_(self.weight_rbr_origin, a=math.sqrt(1.0))
|
| 1100 |
+
self.branch_counter += 1
|
| 1101 |
+
|
| 1102 |
+
|
| 1103 |
+
if groups < out_channels:
|
| 1104 |
+
self.weight_rbr_avg_conv = nn.Parameter(torch.Tensor(out_channels, int(in_channels/self.groups), 1, 1))
|
| 1105 |
+
self.weight_rbr_pfir_conv = nn.Parameter(torch.Tensor(out_channels, int(in_channels/self.groups), 1, 1))
|
| 1106 |
+
nn.init.kaiming_uniform_(self.weight_rbr_avg_conv, a=1.0)
|
| 1107 |
+
nn.init.kaiming_uniform_(self.weight_rbr_pfir_conv, a=1.0)
|
| 1108 |
+
self.weight_rbr_avg_conv.data
|
| 1109 |
+
self.weight_rbr_pfir_conv.data
|
| 1110 |
+
self.register_buffer('weight_rbr_avg_avg', torch.ones(kernel_size, kernel_size).mul(1.0/kernel_size/kernel_size))
|
| 1111 |
+
self.branch_counter += 1
|
| 1112 |
+
|
| 1113 |
+
else:
|
| 1114 |
+
raise NotImplementedError
|
| 1115 |
+
self.branch_counter += 1
|
| 1116 |
+
|
| 1117 |
+
if internal_channels_1x1_3x3 is None:
|
| 1118 |
+
internal_channels_1x1_3x3 = in_channels if groups < out_channels else 2 * in_channels # For mobilenet, it is better to have 2X internal channels
|
| 1119 |
+
|
| 1120 |
+
if internal_channels_1x1_3x3 == in_channels:
|
| 1121 |
+
self.weight_rbr_1x1_kxk_idconv1 = nn.Parameter(torch.zeros(in_channels, int(in_channels/self.groups), 1, 1))
|
| 1122 |
+
id_value = np.zeros((in_channels, int(in_channels/self.groups), 1, 1))
|
| 1123 |
+
for i in range(in_channels):
|
| 1124 |
+
id_value[i, i % int(in_channels/self.groups), 0, 0] = 1
|
| 1125 |
+
id_tensor = torch.from_numpy(id_value).type_as(self.weight_rbr_1x1_kxk_idconv1)
|
| 1126 |
+
self.register_buffer('id_tensor', id_tensor)
|
| 1127 |
+
|
| 1128 |
+
else:
|
| 1129 |
+
self.weight_rbr_1x1_kxk_conv1 = nn.Parameter(torch.Tensor(internal_channels_1x1_3x3, int(in_channels/self.groups), 1, 1))
|
| 1130 |
+
nn.init.kaiming_uniform_(self.weight_rbr_1x1_kxk_conv1, a=math.sqrt(1.0))
|
| 1131 |
+
self.weight_rbr_1x1_kxk_conv2 = nn.Parameter(torch.Tensor(out_channels, int(internal_channels_1x1_3x3/self.groups), kernel_size, kernel_size))
|
| 1132 |
+
nn.init.kaiming_uniform_(self.weight_rbr_1x1_kxk_conv2, a=math.sqrt(1.0))
|
| 1133 |
+
self.branch_counter += 1
|
| 1134 |
+
|
| 1135 |
+
expand_ratio = 8
|
| 1136 |
+
self.weight_rbr_gconv_dw = nn.Parameter(torch.Tensor(in_channels*expand_ratio, 1, kernel_size, kernel_size))
|
| 1137 |
+
self.weight_rbr_gconv_pw = nn.Parameter(torch.Tensor(out_channels, in_channels*expand_ratio, 1, 1))
|
| 1138 |
+
nn.init.kaiming_uniform_(self.weight_rbr_gconv_dw, a=math.sqrt(1.0))
|
| 1139 |
+
nn.init.kaiming_uniform_(self.weight_rbr_gconv_pw, a=math.sqrt(1.0))
|
| 1140 |
+
self.branch_counter += 1
|
| 1141 |
+
|
| 1142 |
+
if out_channels == in_channels and stride == 1:
|
| 1143 |
+
self.branch_counter += 1
|
| 1144 |
+
|
| 1145 |
+
self.vector = nn.Parameter(torch.Tensor(self.branch_counter, self.out_channels))
|
| 1146 |
+
self.bn = nn.BatchNorm2d(out_channels)
|
| 1147 |
+
|
| 1148 |
+
self.fre_init()
|
| 1149 |
+
|
| 1150 |
+
nn.init.constant_(self.vector[0, :], 0.25) #origin
|
| 1151 |
+
nn.init.constant_(self.vector[1, :], 0.25) #avg
|
| 1152 |
+
nn.init.constant_(self.vector[2, :], 0.0) #prior
|
| 1153 |
+
nn.init.constant_(self.vector[3, :], 0.5) #1x1_kxk
|
| 1154 |
+
nn.init.constant_(self.vector[4, :], 0.5) #dws_conv
|
| 1155 |
+
|
| 1156 |
+
|
| 1157 |
+
def fre_init(self):
|
| 1158 |
+
prior_tensor = torch.Tensor(self.out_channels, self.kernel_size, self.kernel_size)
|
| 1159 |
+
half_fg = self.out_channels/2
|
| 1160 |
+
for i in range(self.out_channels):
|
| 1161 |
+
for h in range(3):
|
| 1162 |
+
for w in range(3):
|
| 1163 |
+
if i < half_fg:
|
| 1164 |
+
prior_tensor[i, h, w] = math.cos(math.pi*(h+0.5)*(i+1)/3)
|
| 1165 |
+
else:
|
| 1166 |
+
prior_tensor[i, h, w] = math.cos(math.pi*(w+0.5)*(i+1-half_fg)/3)
|
| 1167 |
+
|
| 1168 |
+
self.register_buffer('weight_rbr_prior', prior_tensor)
|
| 1169 |
+
|
| 1170 |
+
def weight_gen(self):
|
| 1171 |
+
|
| 1172 |
+
weight_rbr_origin = torch.einsum('oihw,o->oihw', self.weight_rbr_origin, self.vector[0, :])
|
| 1173 |
+
|
| 1174 |
+
weight_rbr_avg = torch.einsum('oihw,o->oihw', torch.einsum('oihw,hw->oihw', self.weight_rbr_avg_conv, self.weight_rbr_avg_avg), self.vector[1, :])
|
| 1175 |
+
|
| 1176 |
+
weight_rbr_pfir = torch.einsum('oihw,o->oihw', torch.einsum('oihw,ohw->oihw', self.weight_rbr_pfir_conv, self.weight_rbr_prior), self.vector[2, :])
|
| 1177 |
+
|
| 1178 |
+
weight_rbr_1x1_kxk_conv1 = None
|
| 1179 |
+
if hasattr(self, 'weight_rbr_1x1_kxk_idconv1'):
|
| 1180 |
+
weight_rbr_1x1_kxk_conv1 = (self.weight_rbr_1x1_kxk_idconv1 + self.id_tensor).squeeze()
|
| 1181 |
+
elif hasattr(self, 'weight_rbr_1x1_kxk_conv1'):
|
| 1182 |
+
weight_rbr_1x1_kxk_conv1 = self.weight_rbr_1x1_kxk_conv1.squeeze()
|
| 1183 |
+
else:
|
| 1184 |
+
raise NotImplementedError
|
| 1185 |
+
weight_rbr_1x1_kxk_conv2 = self.weight_rbr_1x1_kxk_conv2
|
| 1186 |
+
|
| 1187 |
+
if self.groups > 1:
|
| 1188 |
+
g = self.groups
|
| 1189 |
+
t, ig = weight_rbr_1x1_kxk_conv1.size()
|
| 1190 |
+
o, tg, h, w = weight_rbr_1x1_kxk_conv2.size()
|
| 1191 |
+
weight_rbr_1x1_kxk_conv1 = weight_rbr_1x1_kxk_conv1.view(g, int(t/g), ig)
|
| 1192 |
+
weight_rbr_1x1_kxk_conv2 = weight_rbr_1x1_kxk_conv2.view(g, int(o/g), tg, h, w)
|
| 1193 |
+
weight_rbr_1x1_kxk = torch.einsum('gti,gothw->goihw', weight_rbr_1x1_kxk_conv1, weight_rbr_1x1_kxk_conv2).view(o, ig, h, w)
|
| 1194 |
+
else:
|
| 1195 |
+
weight_rbr_1x1_kxk = torch.einsum('ti,othw->oihw', weight_rbr_1x1_kxk_conv1, weight_rbr_1x1_kxk_conv2)
|
| 1196 |
+
|
| 1197 |
+
weight_rbr_1x1_kxk = torch.einsum('oihw,o->oihw', weight_rbr_1x1_kxk, self.vector[3, :])
|
| 1198 |
+
|
| 1199 |
+
weight_rbr_gconv = self.dwsc2full(self.weight_rbr_gconv_dw, self.weight_rbr_gconv_pw, self.in_channels)
|
| 1200 |
+
weight_rbr_gconv = torch.einsum('oihw,o->oihw', weight_rbr_gconv, self.vector[4, :])
|
| 1201 |
+
|
| 1202 |
+
weight = weight_rbr_origin + weight_rbr_avg + weight_rbr_1x1_kxk + weight_rbr_pfir + weight_rbr_gconv
|
| 1203 |
+
|
| 1204 |
+
return weight
|
| 1205 |
+
|
| 1206 |
+
def dwsc2full(self, weight_dw, weight_pw, groups):
|
| 1207 |
+
|
| 1208 |
+
t, ig, h, w = weight_dw.size()
|
| 1209 |
+
o, _, _, _ = weight_pw.size()
|
| 1210 |
+
tg = int(t/groups)
|
| 1211 |
+
i = int(ig*groups)
|
| 1212 |
+
weight_dw = weight_dw.view(groups, tg, ig, h, w)
|
| 1213 |
+
weight_pw = weight_pw.squeeze().view(o, groups, tg)
|
| 1214 |
+
|
| 1215 |
+
weight_dsc = torch.einsum('gtihw,ogt->ogihw', weight_dw, weight_pw)
|
| 1216 |
+
return weight_dsc.view(o, i, h, w)
|
| 1217 |
+
|
| 1218 |
+
def forward(self, inputs):
|
| 1219 |
+
weight = self.weight_gen()
|
| 1220 |
+
out = F.conv2d(inputs, weight, bias=None, stride=self.stride, padding=self.padding, dilation=self.dilation, groups=self.groups)
|
| 1221 |
+
|
| 1222 |
+
return self.nonlinear(self.bn(out))
|
| 1223 |
+
|
| 1224 |
+
class RepConv_OREPA(nn.Module):
|
| 1225 |
+
|
| 1226 |
+
def __init__(self, c1, c2, k=3, s=1, padding=1, dilation=1, groups=1, padding_mode='zeros', deploy=False, use_se=False, nonlinear=nn.SiLU()):
|
| 1227 |
+
super(RepConv_OREPA, self).__init__()
|
| 1228 |
+
self.deploy = deploy
|
| 1229 |
+
self.groups = groups
|
| 1230 |
+
self.in_channels = c1
|
| 1231 |
+
self.out_channels = c2
|
| 1232 |
+
|
| 1233 |
+
self.padding = padding
|
| 1234 |
+
self.dilation = dilation
|
| 1235 |
+
self.groups = groups
|
| 1236 |
+
|
| 1237 |
+
assert k == 3
|
| 1238 |
+
assert padding == 1
|
| 1239 |
+
|
| 1240 |
+
padding_11 = padding - k // 2
|
| 1241 |
+
|
| 1242 |
+
if nonlinear is None:
|
| 1243 |
+
self.nonlinearity = nn.Identity()
|
| 1244 |
+
else:
|
| 1245 |
+
self.nonlinearity = nonlinear
|
| 1246 |
+
|
| 1247 |
+
if use_se:
|
| 1248 |
+
self.se = SEBlock(self.out_channels, internal_neurons=self.out_channels // 16)
|
| 1249 |
+
else:
|
| 1250 |
+
self.se = nn.Identity()
|
| 1251 |
+
|
| 1252 |
+
if deploy:
|
| 1253 |
+
self.rbr_reparam = nn.Conv2d(in_channels=self.in_channels, out_channels=self.out_channels, kernel_size=k, stride=s,
|
| 1254 |
+
padding=padding, dilation=dilation, groups=groups, bias=True, padding_mode=padding_mode)
|
| 1255 |
+
|
| 1256 |
+
else:
|
| 1257 |
+
self.rbr_identity = nn.BatchNorm2d(num_features=self.in_channels) if self.out_channels == self.in_channels and s == 1 else None
|
| 1258 |
+
self.rbr_dense = OREPA_3x3_RepConv(in_channels=self.in_channels, out_channels=self.out_channels, kernel_size=k, stride=s, padding=padding, groups=groups, dilation=1)
|
| 1259 |
+
self.rbr_1x1 = ConvBN(in_channels=self.in_channels, out_channels=self.out_channels, kernel_size=1, stride=s, padding=padding_11, groups=groups, dilation=1)
|
| 1260 |
+
print('RepVGG Block, identity = ', self.rbr_identity)
|
| 1261 |
+
|
| 1262 |
+
|
| 1263 |
+
def forward(self, inputs):
|
| 1264 |
+
if hasattr(self, 'rbr_reparam'):
|
| 1265 |
+
return self.nonlinearity(self.se(self.rbr_reparam(inputs)))
|
| 1266 |
+
|
| 1267 |
+
if self.rbr_identity is None:
|
| 1268 |
+
id_out = 0
|
| 1269 |
+
else:
|
| 1270 |
+
id_out = self.rbr_identity(inputs)
|
| 1271 |
+
|
| 1272 |
+
out1 = self.rbr_dense(inputs)
|
| 1273 |
+
out2 = self.rbr_1x1(inputs)
|
| 1274 |
+
out3 = id_out
|
| 1275 |
+
out = out1 + out2 + out3
|
| 1276 |
+
|
| 1277 |
+
return self.nonlinearity(self.se(out))
|
| 1278 |
+
|
| 1279 |
+
|
| 1280 |
+
# Optional. This improves the accuracy and facilitates quantization.
|
| 1281 |
+
# 1. Cancel the original weight decay on rbr_dense.conv.weight and rbr_1x1.conv.weight.
|
| 1282 |
+
# 2. Use like this.
|
| 1283 |
+
# loss = criterion(....)
|
| 1284 |
+
# for every RepVGGBlock blk:
|
| 1285 |
+
# loss += weight_decay_coefficient * 0.5 * blk.get_cust_L2()
|
| 1286 |
+
# optimizer.zero_grad()
|
| 1287 |
+
# loss.backward()
|
| 1288 |
+
|
| 1289 |
+
# Not used for OREPA
|
| 1290 |
+
def get_custom_L2(self):
|
| 1291 |
+
K3 = self.rbr_dense.weight_gen()
|
| 1292 |
+
K1 = self.rbr_1x1.conv.weight
|
| 1293 |
+
t3 = (self.rbr_dense.bn.weight / ((self.rbr_dense.bn.running_var + self.rbr_dense.bn.eps).sqrt())).reshape(-1, 1, 1, 1).detach()
|
| 1294 |
+
t1 = (self.rbr_1x1.bn.weight / ((self.rbr_1x1.bn.running_var + self.rbr_1x1.bn.eps).sqrt())).reshape(-1, 1, 1, 1).detach()
|
| 1295 |
+
|
| 1296 |
+
l2_loss_circle = (K3 ** 2).sum() - (K3[:, :, 1:2, 1:2] ** 2).sum() # The L2 loss of the "circle" of weights in 3x3 kernel. Use regular L2 on them.
|
| 1297 |
+
eq_kernel = K3[:, :, 1:2, 1:2] * t3 + K1 * t1 # The equivalent resultant central point of 3x3 kernel.
|
| 1298 |
+
l2_loss_eq_kernel = (eq_kernel ** 2 / (t3 ** 2 + t1 ** 2)).sum() # Normalize for an L2 coefficient comparable to regular L2.
|
| 1299 |
+
return l2_loss_eq_kernel + l2_loss_circle
|
| 1300 |
+
|
| 1301 |
+
def get_equivalent_kernel_bias(self):
|
| 1302 |
+
kernel3x3, bias3x3 = self._fuse_bn_tensor(self.rbr_dense)
|
| 1303 |
+
kernel1x1, bias1x1 = self._fuse_bn_tensor(self.rbr_1x1)
|
| 1304 |
+
kernelid, biasid = self._fuse_bn_tensor(self.rbr_identity)
|
| 1305 |
+
return kernel3x3 + self._pad_1x1_to_3x3_tensor(kernel1x1) + kernelid, bias3x3 + bias1x1 + biasid
|
| 1306 |
+
|
| 1307 |
+
def _pad_1x1_to_3x3_tensor(self, kernel1x1):
|
| 1308 |
+
if kernel1x1 is None:
|
| 1309 |
+
return 0
|
| 1310 |
+
else:
|
| 1311 |
+
return torch.nn.functional.pad(kernel1x1, [1,1,1,1])
|
| 1312 |
+
|
| 1313 |
+
def _fuse_bn_tensor(self, branch):
|
| 1314 |
+
if branch is None:
|
| 1315 |
+
return 0, 0
|
| 1316 |
+
if not isinstance(branch, nn.BatchNorm2d):
|
| 1317 |
+
if isinstance(branch, OREPA_3x3_RepConv):
|
| 1318 |
+
kernel = branch.weight_gen()
|
| 1319 |
+
elif isinstance(branch, ConvBN):
|
| 1320 |
+
kernel = branch.conv.weight
|
| 1321 |
+
else:
|
| 1322 |
+
raise NotImplementedError
|
| 1323 |
+
running_mean = branch.bn.running_mean
|
| 1324 |
+
running_var = branch.bn.running_var
|
| 1325 |
+
gamma = branch.bn.weight
|
| 1326 |
+
beta = branch.bn.bias
|
| 1327 |
+
eps = branch.bn.eps
|
| 1328 |
+
else:
|
| 1329 |
+
if not hasattr(self, 'id_tensor'):
|
| 1330 |
+
input_dim = self.in_channels // self.groups
|
| 1331 |
+
kernel_value = np.zeros((self.in_channels, input_dim, 3, 3), dtype=np.float32)
|
| 1332 |
+
for i in range(self.in_channels):
|
| 1333 |
+
kernel_value[i, i % input_dim, 1, 1] = 1
|
| 1334 |
+
self.id_tensor = torch.from_numpy(kernel_value).to(branch.weight.device)
|
| 1335 |
+
kernel = self.id_tensor
|
| 1336 |
+
running_mean = branch.running_mean
|
| 1337 |
+
running_var = branch.running_var
|
| 1338 |
+
gamma = branch.weight
|
| 1339 |
+
beta = branch.bias
|
| 1340 |
+
eps = branch.eps
|
| 1341 |
+
std = (running_var + eps).sqrt()
|
| 1342 |
+
t = (gamma / std).reshape(-1, 1, 1, 1)
|
| 1343 |
+
return kernel * t, beta - running_mean * gamma / std
|
| 1344 |
+
|
| 1345 |
+
def switch_to_deploy(self):
|
| 1346 |
+
if hasattr(self, 'rbr_reparam'):
|
| 1347 |
+
return
|
| 1348 |
+
print(f"RepConv_OREPA.switch_to_deploy")
|
| 1349 |
+
kernel, bias = self.get_equivalent_kernel_bias()
|
| 1350 |
+
self.rbr_reparam = nn.Conv2d(in_channels=self.rbr_dense.in_channels, out_channels=self.rbr_dense.out_channels,
|
| 1351 |
+
kernel_size=self.rbr_dense.kernel_size, stride=self.rbr_dense.stride,
|
| 1352 |
+
padding=self.rbr_dense.padding, dilation=self.rbr_dense.dilation, groups=self.rbr_dense.groups, bias=True)
|
| 1353 |
+
self.rbr_reparam.weight.data = kernel
|
| 1354 |
+
self.rbr_reparam.bias.data = bias
|
| 1355 |
+
for para in self.parameters():
|
| 1356 |
+
para.detach_()
|
| 1357 |
+
self.__delattr__('rbr_dense')
|
| 1358 |
+
self.__delattr__('rbr_1x1')
|
| 1359 |
+
if hasattr(self, 'rbr_identity'):
|
| 1360 |
+
self.__delattr__('rbr_identity')
|
| 1361 |
+
|
| 1362 |
+
##### end of orepa #####
|
| 1363 |
+
|
| 1364 |
+
|
| 1365 |
+
##### swin transformer #####
|
| 1366 |
+
|
| 1367 |
+
class WindowAttention(nn.Module):
|
| 1368 |
+
|
| 1369 |
+
def __init__(self, dim, window_size, num_heads, qkv_bias=True, qk_scale=None, attn_drop=0., proj_drop=0.):
|
| 1370 |
+
|
| 1371 |
+
super().__init__()
|
| 1372 |
+
self.dim = dim
|
| 1373 |
+
self.window_size = window_size # Wh, Ww
|
| 1374 |
+
self.num_heads = num_heads
|
| 1375 |
+
head_dim = dim // num_heads
|
| 1376 |
+
self.scale = qk_scale or head_dim ** -0.5
|
| 1377 |
+
|
| 1378 |
+
# define a parameter table of relative position bias
|
| 1379 |
+
self.relative_position_bias_table = nn.Parameter(
|
| 1380 |
+
torch.zeros((2 * window_size[0] - 1) * (2 * window_size[1] - 1), num_heads)) # 2*Wh-1 * 2*Ww-1, nH
|
| 1381 |
+
|
| 1382 |
+
# get pair-wise relative position index for each token inside the window
|
| 1383 |
+
coords_h = torch.arange(self.window_size[0])
|
| 1384 |
+
coords_w = torch.arange(self.window_size[1])
|
| 1385 |
+
coords = torch.stack(torch.meshgrid([coords_h, coords_w])) # 2, Wh, Ww
|
| 1386 |
+
coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww
|
| 1387 |
+
relative_coords = coords_flatten[:, :, None] - coords_flatten[:, None, :] # 2, Wh*Ww, Wh*Ww
|
| 1388 |
+
relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2
|
| 1389 |
+
relative_coords[:, :, 0] += self.window_size[0] - 1 # shift to start from 0
|
| 1390 |
+
relative_coords[:, :, 1] += self.window_size[1] - 1
|
| 1391 |
+
relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1
|
| 1392 |
+
relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww
|
| 1393 |
+
self.register_buffer("relative_position_index", relative_position_index)
|
| 1394 |
+
|
| 1395 |
+
self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
|
| 1396 |
+
self.attn_drop = nn.Dropout(attn_drop)
|
| 1397 |
+
self.proj = nn.Linear(dim, dim)
|
| 1398 |
+
self.proj_drop = nn.Dropout(proj_drop)
|
| 1399 |
+
|
| 1400 |
+
nn.init.normal_(self.relative_position_bias_table, std=.02)
|
| 1401 |
+
self.softmax = nn.Softmax(dim=-1)
|
| 1402 |
+
|
| 1403 |
+
def forward(self, x, mask=None):
|
| 1404 |
+
|
| 1405 |
+
B_, N, C = x.shape
|
| 1406 |
+
qkv = self.qkv(x).reshape(B_, N, 3, self.num_heads, C // self.num_heads).permute(2, 0, 3, 1, 4)
|
| 1407 |
+
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)
|
| 1408 |
+
|
| 1409 |
+
q = q * self.scale
|
| 1410 |
+
attn = (q @ k.transpose(-2, -1))
|
| 1411 |
+
|
| 1412 |
+
relative_position_bias = self.relative_position_bias_table[self.relative_position_index.view(-1)].view(
|
| 1413 |
+
self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH
|
| 1414 |
+
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww
|
| 1415 |
+
attn = attn + relative_position_bias.unsqueeze(0)
|
| 1416 |
+
|
| 1417 |
+
if mask is not None:
|
| 1418 |
+
nW = mask.shape[0]
|
| 1419 |
+
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0)
|
| 1420 |
+
attn = attn.view(-1, self.num_heads, N, N)
|
| 1421 |
+
attn = self.softmax(attn)
|
| 1422 |
+
else:
|
| 1423 |
+
attn = self.softmax(attn)
|
| 1424 |
+
|
| 1425 |
+
attn = self.attn_drop(attn)
|
| 1426 |
+
|
| 1427 |
+
# print(attn.dtype, v.dtype)
|
| 1428 |
+
try:
|
| 1429 |
+
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
|
| 1430 |
+
except:
|
| 1431 |
+
#print(attn.dtype, v.dtype)
|
| 1432 |
+
x = (attn.half() @ v).transpose(1, 2).reshape(B_, N, C)
|
| 1433 |
+
x = self.proj(x)
|
| 1434 |
+
x = self.proj_drop(x)
|
| 1435 |
+
return x
|
| 1436 |
+
|
| 1437 |
+
class Mlp(nn.Module):
|
| 1438 |
+
|
| 1439 |
+
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.SiLU, drop=0.):
|
| 1440 |
+
super().__init__()
|
| 1441 |
+
out_features = out_features or in_features
|
| 1442 |
+
hidden_features = hidden_features or in_features
|
| 1443 |
+
self.fc1 = nn.Linear(in_features, hidden_features)
|
| 1444 |
+
self.act = act_layer()
|
| 1445 |
+
self.fc2 = nn.Linear(hidden_features, out_features)
|
| 1446 |
+
self.drop = nn.Dropout(drop)
|
| 1447 |
+
|
| 1448 |
+
def forward(self, x):
|
| 1449 |
+
x = self.fc1(x)
|
| 1450 |
+
x = self.act(x)
|
| 1451 |
+
x = self.drop(x)
|
| 1452 |
+
x = self.fc2(x)
|
| 1453 |
+
x = self.drop(x)
|
| 1454 |
+
return x
|
| 1455 |
+
|
| 1456 |
+
def window_partition(x, window_size):
|
| 1457 |
+
|
| 1458 |
+
B, H, W, C = x.shape
|
| 1459 |
+
assert H % window_size == 0, 'feature map h and w can not divide by window size'
|
| 1460 |
+
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
|
| 1461 |
+
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
|
| 1462 |
+
return windows
|
| 1463 |
+
|
| 1464 |
+
def window_reverse(windows, window_size, H, W):
|
| 1465 |
+
|
| 1466 |
+
B = int(windows.shape[0] / (H * W / window_size / window_size))
|
| 1467 |
+
x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
|
| 1468 |
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
|
| 1469 |
+
return x
|
| 1470 |
+
|
| 1471 |
+
|
| 1472 |
+
class SwinTransformerLayer(nn.Module):
|
| 1473 |
+
|
| 1474 |
+
def __init__(self, dim, num_heads, window_size=8, shift_size=0,
|
| 1475 |
+
mlp_ratio=4., qkv_bias=True, qk_scale=None, drop=0., attn_drop=0., drop_path=0.,
|
| 1476 |
+
act_layer=nn.SiLU, norm_layer=nn.LayerNorm):
|
| 1477 |
+
super().__init__()
|
| 1478 |
+
self.dim = dim
|
| 1479 |
+
self.num_heads = num_heads
|
| 1480 |
+
self.window_size = window_size
|
| 1481 |
+
self.shift_size = shift_size
|
| 1482 |
+
self.mlp_ratio = mlp_ratio
|
| 1483 |
+
# if min(self.input_resolution) <= self.window_size:
|
| 1484 |
+
# # if window size is larger than input resolution, we don't partition windows
|
| 1485 |
+
# self.shift_size = 0
|
| 1486 |
+
# self.window_size = min(self.input_resolution)
|
| 1487 |
+
assert 0 <= self.shift_size < self.window_size, "shift_size must in 0-window_size"
|
| 1488 |
+
|
| 1489 |
+
self.norm1 = norm_layer(dim)
|
| 1490 |
+
self.attn = WindowAttention(
|
| 1491 |
+
dim, window_size=(self.window_size, self.window_size), num_heads=num_heads,
|
| 1492 |
+
qkv_bias=qkv_bias, qk_scale=qk_scale, attn_drop=attn_drop, proj_drop=drop)
|
| 1493 |
+
|
| 1494 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
|
| 1495 |
+
self.norm2 = norm_layer(dim)
|
| 1496 |
+
mlp_hidden_dim = int(dim * mlp_ratio)
|
| 1497 |
+
self.mlp = Mlp(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
|
| 1498 |
+
|
| 1499 |
+
def create_mask(self, H, W):
|
| 1500 |
+
# calculate attention mask for SW-MSA
|
| 1501 |
+
img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1
|
| 1502 |
+
h_slices = (slice(0, -self.window_size),
|
| 1503 |
+
slice(-self.window_size, -self.shift_size),
|
| 1504 |
+
slice(-self.shift_size, None))
|
| 1505 |
+
w_slices = (slice(0, -self.window_size),
|
| 1506 |
+
slice(-self.window_size, -self.shift_size),
|
| 1507 |
+
slice(-self.shift_size, None))
|
| 1508 |
+
cnt = 0
|
| 1509 |
+
for h in h_slices:
|
| 1510 |
+
for w in w_slices:
|
| 1511 |
+
img_mask[:, h, w, :] = cnt
|
| 1512 |
+
cnt += 1
|
| 1513 |
+
|
| 1514 |
+
mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1
|
| 1515 |
+
mask_windows = mask_windows.view(-1, self.window_size * self.window_size)
|
| 1516 |
+
attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
|
| 1517 |
+
attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))
|
| 1518 |
+
|
| 1519 |
+
return attn_mask
|
| 1520 |
+
|
| 1521 |
+
def forward(self, x):
|
| 1522 |
+
# reshape x[b c h w] to x[b l c]
|
| 1523 |
+
_, _, H_, W_ = x.shape
|
| 1524 |
+
|
| 1525 |
+
Padding = False
|
| 1526 |
+
if min(H_, W_) < self.window_size or H_ % self.window_size!=0 or W_ % self.window_size!=0:
|
| 1527 |
+
Padding = True
|
| 1528 |
+
# print(f'img_size {min(H_, W_)} is less than (or not divided by) window_size {self.window_size}, Padding.')
|
| 1529 |
+
pad_r = (self.window_size - W_ % self.window_size) % self.window_size
|
| 1530 |
+
pad_b = (self.window_size - H_ % self.window_size) % self.window_size
|
| 1531 |
+
x = F.pad(x, (0, pad_r, 0, pad_b))
|
| 1532 |
+
|
| 1533 |
+
# print('2', x.shape)
|
| 1534 |
+
B, C, H, W = x.shape
|
| 1535 |
+
L = H * W
|
| 1536 |
+
x = x.permute(0, 2, 3, 1).contiguous().view(B, L, C) # b, L, c
|
| 1537 |
+
|
| 1538 |
+
# create mask from init to forward
|
| 1539 |
+
if self.shift_size > 0:
|
| 1540 |
+
attn_mask = self.create_mask(H, W).to(x.device)
|
| 1541 |
+
else:
|
| 1542 |
+
attn_mask = None
|
| 1543 |
+
|
| 1544 |
+
shortcut = x
|
| 1545 |
+
x = self.norm1(x)
|
| 1546 |
+
x = x.view(B, H, W, C)
|
| 1547 |
+
|
| 1548 |
+
# cyclic shift
|
| 1549 |
+
if self.shift_size > 0:
|
| 1550 |
+
shifted_x = torch.roll(x, shifts=(-self.shift_size, -self.shift_size), dims=(1, 2))
|
| 1551 |
+
else:
|
| 1552 |
+
shifted_x = x
|
| 1553 |
+
|
| 1554 |
+
# partition windows
|
| 1555 |
+
x_windows = window_partition(shifted_x, self.window_size) # nW*B, window_size, window_size, C
|
| 1556 |
+
x_windows = x_windows.view(-1, self.window_size * self.window_size, C) # nW*B, window_size*window_size, C
|
| 1557 |
+
|
| 1558 |
+
# W-MSA/SW-MSA
|
| 1559 |
+
attn_windows = self.attn(x_windows, mask=attn_mask) # nW*B, window_size*window_size, C
|
| 1560 |
+
|
| 1561 |
+
# merge windows
|
| 1562 |
+
attn_windows = attn_windows.view(-1, self.window_size, self.window_size, C)
|
| 1563 |
+
shifted_x = window_reverse(attn_windows, self.window_size, H, W) # B H' W' C
|
| 1564 |
+
|
| 1565 |
+
# reverse cyclic shift
|
| 1566 |
+
if self.shift_size > 0:
|
| 1567 |
+
x = torch.roll(shifted_x, shifts=(self.shift_size, self.shift_size), dims=(1, 2))
|
| 1568 |
+
else:
|
| 1569 |
+
x = shifted_x
|
| 1570 |
+
x = x.view(B, H * W, C)
|
| 1571 |
+
|
| 1572 |
+
# FFN
|
| 1573 |
+
x = shortcut + self.drop_path(x)
|
| 1574 |
+
x = x + self.drop_path(self.mlp(self.norm2(x)))
|
| 1575 |
+
|
| 1576 |
+
x = x.permute(0, 2, 1).contiguous().view(-1, C, H, W) # b c h w
|
| 1577 |
+
|
| 1578 |
+
if Padding:
|
| 1579 |
+
x = x[:, :, :H_, :W_] # reverse padding
|
| 1580 |
+
|
| 1581 |
+
return x
|
| 1582 |
+
|
| 1583 |
+
|
| 1584 |
+
class SwinTransformerBlock(nn.Module):
|
| 1585 |
+
def __init__(self, c1, c2, num_heads, num_layers, window_size=8):
|
| 1586 |
+
super().__init__()
|
| 1587 |
+
self.conv = None
|
| 1588 |
+
if c1 != c2:
|
| 1589 |
+
self.conv = Conv(c1, c2)
|
| 1590 |
+
|
| 1591 |
+
# remove input_resolution
|
| 1592 |
+
self.blocks = nn.Sequential(*[SwinTransformerLayer(dim=c2, num_heads=num_heads, window_size=window_size,
|
| 1593 |
+
shift_size=0 if (i % 2 == 0) else window_size // 2) for i in range(num_layers)])
|
| 1594 |
+
|
| 1595 |
+
def forward(self, x):
|
| 1596 |
+
if self.conv is not None:
|
| 1597 |
+
x = self.conv(x)
|
| 1598 |
+
x = self.blocks(x)
|
| 1599 |
+
return x
|
| 1600 |
+
|
| 1601 |
+
|
| 1602 |
+
class STCSPA(nn.Module):
|
| 1603 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 1604 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 1605 |
+
super(STCSPA, self).__init__()
|
| 1606 |
+
c_ = int(c2 * e) # hidden channels
|
| 1607 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 1608 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 1609 |
+
self.cv3 = Conv(2 * c_, c2, 1, 1)
|
| 1610 |
+
num_heads = c_ // 32
|
| 1611 |
+
self.m = SwinTransformerBlock(c_, c_, num_heads, n)
|
| 1612 |
+
#self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 1613 |
+
|
| 1614 |
+
def forward(self, x):
|
| 1615 |
+
y1 = self.m(self.cv1(x))
|
| 1616 |
+
y2 = self.cv2(x)
|
| 1617 |
+
return self.cv3(torch.cat((y1, y2), dim=1))
|
| 1618 |
+
|
| 1619 |
+
|
| 1620 |
+
class STCSPB(nn.Module):
|
| 1621 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 1622 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 1623 |
+
super(STCSPB, self).__init__()
|
| 1624 |
+
c_ = int(c2) # hidden channels
|
| 1625 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 1626 |
+
self.cv2 = Conv(c_, c_, 1, 1)
|
| 1627 |
+
self.cv3 = Conv(2 * c_, c2, 1, 1)
|
| 1628 |
+
num_heads = c_ // 32
|
| 1629 |
+
self.m = SwinTransformerBlock(c_, c_, num_heads, n)
|
| 1630 |
+
#self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 1631 |
+
|
| 1632 |
+
def forward(self, x):
|
| 1633 |
+
x1 = self.cv1(x)
|
| 1634 |
+
y1 = self.m(x1)
|
| 1635 |
+
y2 = self.cv2(x1)
|
| 1636 |
+
return self.cv3(torch.cat((y1, y2), dim=1))
|
| 1637 |
+
|
| 1638 |
+
|
| 1639 |
+
class STCSPC(nn.Module):
|
| 1640 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 1641 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 1642 |
+
super(STCSPC, self).__init__()
|
| 1643 |
+
c_ = int(c2 * e) # hidden channels
|
| 1644 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 1645 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 1646 |
+
self.cv3 = Conv(c_, c_, 1, 1)
|
| 1647 |
+
self.cv4 = Conv(2 * c_, c2, 1, 1)
|
| 1648 |
+
num_heads = c_ // 32
|
| 1649 |
+
self.m = SwinTransformerBlock(c_, c_, num_heads, n)
|
| 1650 |
+
#self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 1651 |
+
|
| 1652 |
+
def forward(self, x):
|
| 1653 |
+
y1 = self.cv3(self.m(self.cv1(x)))
|
| 1654 |
+
y2 = self.cv2(x)
|
| 1655 |
+
return self.cv4(torch.cat((y1, y2), dim=1))
|
| 1656 |
+
|
| 1657 |
+
##### end of swin transformer #####
|
| 1658 |
+
|
| 1659 |
+
|
| 1660 |
+
##### swin transformer v2 #####
|
| 1661 |
+
|
| 1662 |
+
class WindowAttention_v2(nn.Module):
|
| 1663 |
+
|
| 1664 |
+
def __init__(self, dim, window_size, num_heads, qkv_bias=True, attn_drop=0., proj_drop=0.,
|
| 1665 |
+
pretrained_window_size=[0, 0]):
|
| 1666 |
+
|
| 1667 |
+
super().__init__()
|
| 1668 |
+
self.dim = dim
|
| 1669 |
+
self.window_size = window_size # Wh, Ww
|
| 1670 |
+
self.pretrained_window_size = pretrained_window_size
|
| 1671 |
+
self.num_heads = num_heads
|
| 1672 |
+
|
| 1673 |
+
self.logit_scale = nn.Parameter(torch.log(10 * torch.ones((num_heads, 1, 1))), requires_grad=True)
|
| 1674 |
+
|
| 1675 |
+
# mlp to generate continuous relative position bias
|
| 1676 |
+
self.cpb_mlp = nn.Sequential(nn.Linear(2, 512, bias=True),
|
| 1677 |
+
nn.ReLU(inplace=True),
|
| 1678 |
+
nn.Linear(512, num_heads, bias=False))
|
| 1679 |
+
|
| 1680 |
+
# get relative_coords_table
|
| 1681 |
+
relative_coords_h = torch.arange(-(self.window_size[0] - 1), self.window_size[0], dtype=torch.float32)
|
| 1682 |
+
relative_coords_w = torch.arange(-(self.window_size[1] - 1), self.window_size[1], dtype=torch.float32)
|
| 1683 |
+
relative_coords_table = torch.stack(
|
| 1684 |
+
torch.meshgrid([relative_coords_h,
|
| 1685 |
+
relative_coords_w])).permute(1, 2, 0).contiguous().unsqueeze(0) # 1, 2*Wh-1, 2*Ww-1, 2
|
| 1686 |
+
if pretrained_window_size[0] > 0:
|
| 1687 |
+
relative_coords_table[:, :, :, 0] /= (pretrained_window_size[0] - 1)
|
| 1688 |
+
relative_coords_table[:, :, :, 1] /= (pretrained_window_size[1] - 1)
|
| 1689 |
+
else:
|
| 1690 |
+
relative_coords_table[:, :, :, 0] /= (self.window_size[0] - 1)
|
| 1691 |
+
relative_coords_table[:, :, :, 1] /= (self.window_size[1] - 1)
|
| 1692 |
+
relative_coords_table *= 8 # normalize to -8, 8
|
| 1693 |
+
relative_coords_table = torch.sign(relative_coords_table) * torch.log2(
|
| 1694 |
+
torch.abs(relative_coords_table) + 1.0) / np.log2(8)
|
| 1695 |
+
|
| 1696 |
+
self.register_buffer("relative_coords_table", relative_coords_table)
|
| 1697 |
+
|
| 1698 |
+
# get pair-wise relative position index for each token inside the window
|
| 1699 |
+
coords_h = torch.arange(self.window_size[0])
|
| 1700 |
+
coords_w = torch.arange(self.window_size[1])
|
| 1701 |
+
coords = torch.stack(torch.meshgrid([coords_h, coords_w])) # 2, Wh, Ww
|
| 1702 |
+
coords_flatten = torch.flatten(coords, 1) # 2, Wh*Ww
|
| 1703 |
+
relative_coords = coords_flatten[:, :, None] - coords_flatten[:, None, :] # 2, Wh*Ww, Wh*Ww
|
| 1704 |
+
relative_coords = relative_coords.permute(1, 2, 0).contiguous() # Wh*Ww, Wh*Ww, 2
|
| 1705 |
+
relative_coords[:, :, 0] += self.window_size[0] - 1 # shift to start from 0
|
| 1706 |
+
relative_coords[:, :, 1] += self.window_size[1] - 1
|
| 1707 |
+
relative_coords[:, :, 0] *= 2 * self.window_size[1] - 1
|
| 1708 |
+
relative_position_index = relative_coords.sum(-1) # Wh*Ww, Wh*Ww
|
| 1709 |
+
self.register_buffer("relative_position_index", relative_position_index)
|
| 1710 |
+
|
| 1711 |
+
self.qkv = nn.Linear(dim, dim * 3, bias=False)
|
| 1712 |
+
if qkv_bias:
|
| 1713 |
+
self.q_bias = nn.Parameter(torch.zeros(dim))
|
| 1714 |
+
self.v_bias = nn.Parameter(torch.zeros(dim))
|
| 1715 |
+
else:
|
| 1716 |
+
self.q_bias = None
|
| 1717 |
+
self.v_bias = None
|
| 1718 |
+
self.attn_drop = nn.Dropout(attn_drop)
|
| 1719 |
+
self.proj = nn.Linear(dim, dim)
|
| 1720 |
+
self.proj_drop = nn.Dropout(proj_drop)
|
| 1721 |
+
self.softmax = nn.Softmax(dim=-1)
|
| 1722 |
+
|
| 1723 |
+
def forward(self, x, mask=None):
|
| 1724 |
+
|
| 1725 |
+
B_, N, C = x.shape
|
| 1726 |
+
qkv_bias = None
|
| 1727 |
+
if self.q_bias is not None:
|
| 1728 |
+
qkv_bias = torch.cat((self.q_bias, torch.zeros_like(self.v_bias, requires_grad=False), self.v_bias))
|
| 1729 |
+
qkv = F.linear(input=x, weight=self.qkv.weight, bias=qkv_bias)
|
| 1730 |
+
qkv = qkv.reshape(B_, N, 3, self.num_heads, -1).permute(2, 0, 3, 1, 4)
|
| 1731 |
+
q, k, v = qkv[0], qkv[1], qkv[2] # make torchscript happy (cannot use tensor as tuple)
|
| 1732 |
+
|
| 1733 |
+
# cosine attention
|
| 1734 |
+
attn = (F.normalize(q, dim=-1) @ F.normalize(k, dim=-1).transpose(-2, -1))
|
| 1735 |
+
logit_scale = torch.clamp(self.logit_scale, max=torch.log(torch.tensor(1. / 0.01))).exp()
|
| 1736 |
+
attn = attn * logit_scale
|
| 1737 |
+
|
| 1738 |
+
relative_position_bias_table = self.cpb_mlp(self.relative_coords_table).view(-1, self.num_heads)
|
| 1739 |
+
relative_position_bias = relative_position_bias_table[self.relative_position_index.view(-1)].view(
|
| 1740 |
+
self.window_size[0] * self.window_size[1], self.window_size[0] * self.window_size[1], -1) # Wh*Ww,Wh*Ww,nH
|
| 1741 |
+
relative_position_bias = relative_position_bias.permute(2, 0, 1).contiguous() # nH, Wh*Ww, Wh*Ww
|
| 1742 |
+
relative_position_bias = 16 * torch.sigmoid(relative_position_bias)
|
| 1743 |
+
attn = attn + relative_position_bias.unsqueeze(0)
|
| 1744 |
+
|
| 1745 |
+
if mask is not None:
|
| 1746 |
+
nW = mask.shape[0]
|
| 1747 |
+
attn = attn.view(B_ // nW, nW, self.num_heads, N, N) + mask.unsqueeze(1).unsqueeze(0)
|
| 1748 |
+
attn = attn.view(-1, self.num_heads, N, N)
|
| 1749 |
+
attn = self.softmax(attn)
|
| 1750 |
+
else:
|
| 1751 |
+
attn = self.softmax(attn)
|
| 1752 |
+
|
| 1753 |
+
attn = self.attn_drop(attn)
|
| 1754 |
+
|
| 1755 |
+
try:
|
| 1756 |
+
x = (attn @ v).transpose(1, 2).reshape(B_, N, C)
|
| 1757 |
+
except:
|
| 1758 |
+
x = (attn.half() @ v).transpose(1, 2).reshape(B_, N, C)
|
| 1759 |
+
|
| 1760 |
+
x = self.proj(x)
|
| 1761 |
+
x = self.proj_drop(x)
|
| 1762 |
+
return x
|
| 1763 |
+
|
| 1764 |
+
def extra_repr(self) -> str:
|
| 1765 |
+
return f'dim={self.dim}, window_size={self.window_size}, ' \
|
| 1766 |
+
f'pretrained_window_size={self.pretrained_window_size}, num_heads={self.num_heads}'
|
| 1767 |
+
|
| 1768 |
+
def flops(self, N):
|
| 1769 |
+
# calculate flops for 1 window with token length of N
|
| 1770 |
+
flops = 0
|
| 1771 |
+
# qkv = self.qkv(x)
|
| 1772 |
+
flops += N * self.dim * 3 * self.dim
|
| 1773 |
+
# attn = (q @ k.transpose(-2, -1))
|
| 1774 |
+
flops += self.num_heads * N * (self.dim // self.num_heads) * N
|
| 1775 |
+
# x = (attn @ v)
|
| 1776 |
+
flops += self.num_heads * N * N * (self.dim // self.num_heads)
|
| 1777 |
+
# x = self.proj(x)
|
| 1778 |
+
flops += N * self.dim * self.dim
|
| 1779 |
+
return flops
|
| 1780 |
+
|
| 1781 |
+
class Mlp_v2(nn.Module):
|
| 1782 |
+
def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.SiLU, drop=0.):
|
| 1783 |
+
super().__init__()
|
| 1784 |
+
out_features = out_features or in_features
|
| 1785 |
+
hidden_features = hidden_features or in_features
|
| 1786 |
+
self.fc1 = nn.Linear(in_features, hidden_features)
|
| 1787 |
+
self.act = act_layer()
|
| 1788 |
+
self.fc2 = nn.Linear(hidden_features, out_features)
|
| 1789 |
+
self.drop = nn.Dropout(drop)
|
| 1790 |
+
|
| 1791 |
+
def forward(self, x):
|
| 1792 |
+
x = self.fc1(x)
|
| 1793 |
+
x = self.act(x)
|
| 1794 |
+
x = self.drop(x)
|
| 1795 |
+
x = self.fc2(x)
|
| 1796 |
+
x = self.drop(x)
|
| 1797 |
+
return x
|
| 1798 |
+
|
| 1799 |
+
|
| 1800 |
+
def window_partition_v2(x, window_size):
|
| 1801 |
+
|
| 1802 |
+
B, H, W, C = x.shape
|
| 1803 |
+
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
|
| 1804 |
+
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
|
| 1805 |
+
return windows
|
| 1806 |
+
|
| 1807 |
+
|
| 1808 |
+
def window_reverse_v2(windows, window_size, H, W):
|
| 1809 |
+
|
| 1810 |
+
B = int(windows.shape[0] / (H * W / window_size / window_size))
|
| 1811 |
+
x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
|
| 1812 |
+
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
|
| 1813 |
+
return x
|
| 1814 |
+
|
| 1815 |
+
|
| 1816 |
+
class SwinTransformerLayer_v2(nn.Module):
|
| 1817 |
+
|
| 1818 |
+
def __init__(self, dim, num_heads, window_size=7, shift_size=0,
|
| 1819 |
+
mlp_ratio=4., qkv_bias=True, drop=0., attn_drop=0., drop_path=0.,
|
| 1820 |
+
act_layer=nn.SiLU, norm_layer=nn.LayerNorm, pretrained_window_size=0):
|
| 1821 |
+
super().__init__()
|
| 1822 |
+
self.dim = dim
|
| 1823 |
+
#self.input_resolution = input_resolution
|
| 1824 |
+
self.num_heads = num_heads
|
| 1825 |
+
self.window_size = window_size
|
| 1826 |
+
self.shift_size = shift_size
|
| 1827 |
+
self.mlp_ratio = mlp_ratio
|
| 1828 |
+
#if min(self.input_resolution) <= self.window_size:
|
| 1829 |
+
# # if window size is larger than input resolution, we don't partition windows
|
| 1830 |
+
# self.shift_size = 0
|
| 1831 |
+
# self.window_size = min(self.input_resolution)
|
| 1832 |
+
assert 0 <= self.shift_size < self.window_size, "shift_size must in 0-window_size"
|
| 1833 |
+
|
| 1834 |
+
self.norm1 = norm_layer(dim)
|
| 1835 |
+
self.attn = WindowAttention_v2(
|
| 1836 |
+
dim, window_size=(self.window_size, self.window_size), num_heads=num_heads,
|
| 1837 |
+
qkv_bias=qkv_bias, attn_drop=attn_drop, proj_drop=drop,
|
| 1838 |
+
pretrained_window_size=(pretrained_window_size, pretrained_window_size))
|
| 1839 |
+
|
| 1840 |
+
self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
|
| 1841 |
+
self.norm2 = norm_layer(dim)
|
| 1842 |
+
mlp_hidden_dim = int(dim * mlp_ratio)
|
| 1843 |
+
self.mlp = Mlp_v2(in_features=dim, hidden_features=mlp_hidden_dim, act_layer=act_layer, drop=drop)
|
| 1844 |
+
|
| 1845 |
+
def create_mask(self, H, W):
|
| 1846 |
+
# calculate attention mask for SW-MSA
|
| 1847 |
+
img_mask = torch.zeros((1, H, W, 1)) # 1 H W 1
|
| 1848 |
+
h_slices = (slice(0, -self.window_size),
|
| 1849 |
+
slice(-self.window_size, -self.shift_size),
|
| 1850 |
+
slice(-self.shift_size, None))
|
| 1851 |
+
w_slices = (slice(0, -self.window_size),
|
| 1852 |
+
slice(-self.window_size, -self.shift_size),
|
| 1853 |
+
slice(-self.shift_size, None))
|
| 1854 |
+
cnt = 0
|
| 1855 |
+
for h in h_slices:
|
| 1856 |
+
for w in w_slices:
|
| 1857 |
+
img_mask[:, h, w, :] = cnt
|
| 1858 |
+
cnt += 1
|
| 1859 |
+
|
| 1860 |
+
mask_windows = window_partition(img_mask, self.window_size) # nW, window_size, window_size, 1
|
| 1861 |
+
mask_windows = mask_windows.view(-1, self.window_size * self.window_size)
|
| 1862 |
+
attn_mask = mask_windows.unsqueeze(1) - mask_windows.unsqueeze(2)
|
| 1863 |
+
attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(attn_mask == 0, float(0.0))
|
| 1864 |
+
|
| 1865 |
+
return attn_mask
|
| 1866 |
+
|
| 1867 |
+
def forward(self, x):
|
| 1868 |
+
# reshape x[b c h w] to x[b l c]
|
| 1869 |
+
_, _, H_, W_ = x.shape
|
| 1870 |
+
|
| 1871 |
+
Padding = False
|
| 1872 |
+
if min(H_, W_) < self.window_size or H_ % self.window_size!=0 or W_ % self.window_size!=0:
|
| 1873 |
+
Padding = True
|
| 1874 |
+
# print(f'img_size {min(H_, W_)} is less than (or not divided by) window_size {self.window_size}, Padding.')
|
| 1875 |
+
pad_r = (self.window_size - W_ % self.window_size) % self.window_size
|
| 1876 |
+
pad_b = (self.window_size - H_ % self.window_size) % self.window_size
|
| 1877 |
+
x = F.pad(x, (0, pad_r, 0, pad_b))
|
| 1878 |
+
|
| 1879 |
+
# print('2', x.shape)
|
| 1880 |
+
B, C, H, W = x.shape
|
| 1881 |
+
L = H * W
|
| 1882 |
+
x = x.permute(0, 2, 3, 1).contiguous().view(B, L, C) # b, L, c
|
| 1883 |
+
|
| 1884 |
+
# create mask from init to forward
|
| 1885 |
+
if self.shift_size > 0:
|
| 1886 |
+
attn_mask = self.create_mask(H, W).to(x.device)
|
| 1887 |
+
else:
|
| 1888 |
+
attn_mask = None
|
| 1889 |
+
|
| 1890 |
+
shortcut = x
|
| 1891 |
+
x = x.view(B, H, W, C)
|
| 1892 |
+
|
| 1893 |
+
# cyclic shift
|
| 1894 |
+
if self.shift_size > 0:
|
| 1895 |
+
shifted_x = torch.roll(x, shifts=(-self.shift_size, -self.shift_size), dims=(1, 2))
|
| 1896 |
+
else:
|
| 1897 |
+
shifted_x = x
|
| 1898 |
+
|
| 1899 |
+
# partition windows
|
| 1900 |
+
x_windows = window_partition_v2(shifted_x, self.window_size) # nW*B, window_size, window_size, C
|
| 1901 |
+
x_windows = x_windows.view(-1, self.window_size * self.window_size, C) # nW*B, window_size*window_size, C
|
| 1902 |
+
|
| 1903 |
+
# W-MSA/SW-MSA
|
| 1904 |
+
attn_windows = self.attn(x_windows, mask=attn_mask) # nW*B, window_size*window_size, C
|
| 1905 |
+
|
| 1906 |
+
# merge windows
|
| 1907 |
+
attn_windows = attn_windows.view(-1, self.window_size, self.window_size, C)
|
| 1908 |
+
shifted_x = window_reverse_v2(attn_windows, self.window_size, H, W) # B H' W' C
|
| 1909 |
+
|
| 1910 |
+
# reverse cyclic shift
|
| 1911 |
+
if self.shift_size > 0:
|
| 1912 |
+
x = torch.roll(shifted_x, shifts=(self.shift_size, self.shift_size), dims=(1, 2))
|
| 1913 |
+
else:
|
| 1914 |
+
x = shifted_x
|
| 1915 |
+
x = x.view(B, H * W, C)
|
| 1916 |
+
x = shortcut + self.drop_path(self.norm1(x))
|
| 1917 |
+
|
| 1918 |
+
# FFN
|
| 1919 |
+
x = x + self.drop_path(self.norm2(self.mlp(x)))
|
| 1920 |
+
x = x.permute(0, 2, 1).contiguous().view(-1, C, H, W) # b c h w
|
| 1921 |
+
|
| 1922 |
+
if Padding:
|
| 1923 |
+
x = x[:, :, :H_, :W_] # reverse padding
|
| 1924 |
+
|
| 1925 |
+
return x
|
| 1926 |
+
|
| 1927 |
+
def extra_repr(self) -> str:
|
| 1928 |
+
return f"dim={self.dim}, input_resolution={self.input_resolution}, num_heads={self.num_heads}, " \
|
| 1929 |
+
f"window_size={self.window_size}, shift_size={self.shift_size}, mlp_ratio={self.mlp_ratio}"
|
| 1930 |
+
|
| 1931 |
+
def flops(self):
|
| 1932 |
+
flops = 0
|
| 1933 |
+
H, W = self.input_resolution
|
| 1934 |
+
# norm1
|
| 1935 |
+
flops += self.dim * H * W
|
| 1936 |
+
# W-MSA/SW-MSA
|
| 1937 |
+
nW = H * W / self.window_size / self.window_size
|
| 1938 |
+
flops += nW * self.attn.flops(self.window_size * self.window_size)
|
| 1939 |
+
# mlp
|
| 1940 |
+
flops += 2 * H * W * self.dim * self.dim * self.mlp_ratio
|
| 1941 |
+
# norm2
|
| 1942 |
+
flops += self.dim * H * W
|
| 1943 |
+
return flops
|
| 1944 |
+
|
| 1945 |
+
|
| 1946 |
+
class SwinTransformer2Block(nn.Module):
|
| 1947 |
+
def __init__(self, c1, c2, num_heads, num_layers, window_size=7):
|
| 1948 |
+
super().__init__()
|
| 1949 |
+
self.conv = None
|
| 1950 |
+
if c1 != c2:
|
| 1951 |
+
self.conv = Conv(c1, c2)
|
| 1952 |
+
|
| 1953 |
+
# remove input_resolution
|
| 1954 |
+
self.blocks = nn.Sequential(*[SwinTransformerLayer_v2(dim=c2, num_heads=num_heads, window_size=window_size,
|
| 1955 |
+
shift_size=0 if (i % 2 == 0) else window_size // 2) for i in range(num_layers)])
|
| 1956 |
+
|
| 1957 |
+
def forward(self, x):
|
| 1958 |
+
if self.conv is not None:
|
| 1959 |
+
x = self.conv(x)
|
| 1960 |
+
x = self.blocks(x)
|
| 1961 |
+
return x
|
| 1962 |
+
|
| 1963 |
+
|
| 1964 |
+
class ST2CSPA(nn.Module):
|
| 1965 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 1966 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 1967 |
+
super(ST2CSPA, self).__init__()
|
| 1968 |
+
c_ = int(c2 * e) # hidden channels
|
| 1969 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 1970 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 1971 |
+
self.cv3 = Conv(2 * c_, c2, 1, 1)
|
| 1972 |
+
num_heads = c_ // 32
|
| 1973 |
+
self.m = SwinTransformer2Block(c_, c_, num_heads, n)
|
| 1974 |
+
#self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 1975 |
+
|
| 1976 |
+
def forward(self, x):
|
| 1977 |
+
y1 = self.m(self.cv1(x))
|
| 1978 |
+
y2 = self.cv2(x)
|
| 1979 |
+
return self.cv3(torch.cat((y1, y2), dim=1))
|
| 1980 |
+
|
| 1981 |
+
|
| 1982 |
+
class ST2CSPB(nn.Module):
|
| 1983 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 1984 |
+
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 1985 |
+
super(ST2CSPB, self).__init__()
|
| 1986 |
+
c_ = int(c2) # hidden channels
|
| 1987 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 1988 |
+
self.cv2 = Conv(c_, c_, 1, 1)
|
| 1989 |
+
self.cv3 = Conv(2 * c_, c2, 1, 1)
|
| 1990 |
+
num_heads = c_ // 32
|
| 1991 |
+
self.m = SwinTransformer2Block(c_, c_, num_heads, n)
|
| 1992 |
+
#self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 1993 |
+
|
| 1994 |
+
def forward(self, x):
|
| 1995 |
+
x1 = self.cv1(x)
|
| 1996 |
+
y1 = self.m(x1)
|
| 1997 |
+
y2 = self.cv2(x1)
|
| 1998 |
+
return self.cv3(torch.cat((y1, y2), dim=1))
|
| 1999 |
+
|
| 2000 |
+
|
| 2001 |
+
class ST2CSPC(nn.Module):
|
| 2002 |
+
# CSP Bottleneck https://github.com/WongKinYiu/CrossStagePartialNetworks
|
| 2003 |
+
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, number, shortcut, groups, expansion
|
| 2004 |
+
super(ST2CSPC, self).__init__()
|
| 2005 |
+
c_ = int(c2 * e) # hidden channels
|
| 2006 |
+
self.cv1 = Conv(c1, c_, 1, 1)
|
| 2007 |
+
self.cv2 = Conv(c1, c_, 1, 1)
|
| 2008 |
+
self.cv3 = Conv(c_, c_, 1, 1)
|
| 2009 |
+
self.cv4 = Conv(2 * c_, c2, 1, 1)
|
| 2010 |
+
num_heads = c_ // 32
|
| 2011 |
+
self.m = SwinTransformer2Block(c_, c_, num_heads, n)
|
| 2012 |
+
#self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])
|
| 2013 |
+
|
| 2014 |
+
def forward(self, x):
|
| 2015 |
+
y1 = self.cv3(self.m(self.cv1(x)))
|
| 2016 |
+
y2 = self.cv2(x)
|
| 2017 |
+
return self.cv4(torch.cat((y1, y2), dim=1))
|
| 2018 |
+
|
| 2019 |
+
##### end of swin transformer v2 #####
|
detection/models/experimental.py
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import random
|
| 3 |
+
import torch
|
| 4 |
+
import torch.nn as nn
|
| 5 |
+
|
| 6 |
+
from models.common import Conv, DWConv
|
| 7 |
+
from utils.google_utils import attempt_download
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class CrossConv(nn.Module):
|
| 11 |
+
# Cross Convolution Downsample
|
| 12 |
+
def __init__(self, c1, c2, k=3, s=1, g=1, e=1.0, shortcut=False):
|
| 13 |
+
# ch_in, ch_out, kernel, stride, groups, expansion, shortcut
|
| 14 |
+
super(CrossConv, self).__init__()
|
| 15 |
+
c_ = int(c2 * e) # hidden channels
|
| 16 |
+
self.cv1 = Conv(c1, c_, (1, k), (1, s))
|
| 17 |
+
self.cv2 = Conv(c_, c2, (k, 1), (s, 1), g=g)
|
| 18 |
+
self.add = shortcut and c1 == c2
|
| 19 |
+
|
| 20 |
+
def forward(self, x):
|
| 21 |
+
return x + self.cv2(self.cv1(x)) if self.add else self.cv2(self.cv1(x))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Sum(nn.Module):
|
| 25 |
+
# Weighted sum of 2 or more layers https://arxiv.org/abs/1911.09070
|
| 26 |
+
def __init__(self, n, weight=False): # n: number of inputs
|
| 27 |
+
super(Sum, self).__init__()
|
| 28 |
+
self.weight = weight # apply weights boolean
|
| 29 |
+
self.iter = range(n - 1) # iter object
|
| 30 |
+
if weight:
|
| 31 |
+
self.w = nn.Parameter(-torch.arange(1., n) / 2, requires_grad=True) # layer weights
|
| 32 |
+
|
| 33 |
+
def forward(self, x):
|
| 34 |
+
y = x[0] # no weight
|
| 35 |
+
if self.weight:
|
| 36 |
+
w = torch.sigmoid(self.w) * 2
|
| 37 |
+
for i in self.iter:
|
| 38 |
+
y = y + x[i + 1] * w[i]
|
| 39 |
+
else:
|
| 40 |
+
for i in self.iter:
|
| 41 |
+
y = y + x[i + 1]
|
| 42 |
+
return y
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class MixConv2d(nn.Module):
|
| 46 |
+
# Mixed Depthwise Conv https://arxiv.org/abs/1907.09595
|
| 47 |
+
def __init__(self, c1, c2, k=(1, 3), s=1, equal_ch=True):
|
| 48 |
+
super(MixConv2d, self).__init__()
|
| 49 |
+
groups = len(k)
|
| 50 |
+
if equal_ch: # equal c_ per group
|
| 51 |
+
i = torch.linspace(0, groups - 1E-6, c2).floor() # c2 indices
|
| 52 |
+
c_ = [(i == g).sum() for g in range(groups)] # intermediate channels
|
| 53 |
+
else: # equal weight.numel() per group
|
| 54 |
+
b = [c2] + [0] * groups
|
| 55 |
+
a = np.eye(groups + 1, groups, k=-1)
|
| 56 |
+
a -= np.roll(a, 1, axis=1)
|
| 57 |
+
a *= np.array(k) ** 2
|
| 58 |
+
a[0] = 1
|
| 59 |
+
c_ = np.linalg.lstsq(a, b, rcond=None)[0].round() # solve for equal weight indices, ax = b
|
| 60 |
+
|
| 61 |
+
self.m = nn.ModuleList([nn.Conv2d(c1, int(c_[g]), k[g], s, k[g] // 2, bias=False) for g in range(groups)])
|
| 62 |
+
self.bn = nn.BatchNorm2d(c2)
|
| 63 |
+
self.act = nn.LeakyReLU(0.1, inplace=True)
|
| 64 |
+
|
| 65 |
+
def forward(self, x):
|
| 66 |
+
return x + self.act(self.bn(torch.cat([m(x) for m in self.m], 1)))
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
class Ensemble(nn.ModuleList):
|
| 70 |
+
# Ensemble of models
|
| 71 |
+
def __init__(self):
|
| 72 |
+
super(Ensemble, self).__init__()
|
| 73 |
+
|
| 74 |
+
def forward(self, x, augment=False):
|
| 75 |
+
y = []
|
| 76 |
+
for module in self:
|
| 77 |
+
y.append(module(x, augment)[0])
|
| 78 |
+
# y = torch.stack(y).max(0)[0] # max ensemble
|
| 79 |
+
# y = torch.stack(y).mean(0) # mean ensemble
|
| 80 |
+
y = torch.cat(y, 1) # nms ensemble
|
| 81 |
+
return y, None # inference, train output
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class ORT_NMS(torch.autograd.Function):
|
| 88 |
+
'''ONNX-Runtime NMS operation'''
|
| 89 |
+
@staticmethod
|
| 90 |
+
def forward(ctx,
|
| 91 |
+
boxes,
|
| 92 |
+
scores,
|
| 93 |
+
max_output_boxes_per_class=torch.tensor([100]),
|
| 94 |
+
iou_threshold=torch.tensor([0.45]),
|
| 95 |
+
score_threshold=torch.tensor([0.25])):
|
| 96 |
+
device = boxes.device
|
| 97 |
+
batch = scores.shape[0]
|
| 98 |
+
num_det = random.randint(0, 100)
|
| 99 |
+
batches = torch.randint(0, batch, (num_det,)).sort()[0].to(device)
|
| 100 |
+
idxs = torch.arange(100, 100 + num_det).to(device)
|
| 101 |
+
zeros = torch.zeros((num_det,), dtype=torch.int64).to(device)
|
| 102 |
+
selected_indices = torch.cat([batches[None], zeros[None], idxs[None]], 0).T.contiguous()
|
| 103 |
+
selected_indices = selected_indices.to(torch.int64)
|
| 104 |
+
return selected_indices
|
| 105 |
+
|
| 106 |
+
@staticmethod
|
| 107 |
+
def symbolic(g, boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold):
|
| 108 |
+
return g.op("NonMaxSuppression", boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class TRT_NMS(torch.autograd.Function):
|
| 112 |
+
'''TensorRT NMS operation'''
|
| 113 |
+
@staticmethod
|
| 114 |
+
def forward(
|
| 115 |
+
ctx,
|
| 116 |
+
boxes,
|
| 117 |
+
scores,
|
| 118 |
+
background_class=-1,
|
| 119 |
+
box_coding=1,
|
| 120 |
+
iou_threshold=0.45,
|
| 121 |
+
max_output_boxes=100,
|
| 122 |
+
plugin_version="1",
|
| 123 |
+
score_activation=0,
|
| 124 |
+
score_threshold=0.25,
|
| 125 |
+
):
|
| 126 |
+
batch_size, num_boxes, num_classes = scores.shape
|
| 127 |
+
num_det = torch.randint(0, max_output_boxes, (batch_size, 1), dtype=torch.int32)
|
| 128 |
+
det_boxes = torch.randn(batch_size, max_output_boxes, 4)
|
| 129 |
+
det_scores = torch.randn(batch_size, max_output_boxes)
|
| 130 |
+
det_classes = torch.randint(0, num_classes, (batch_size, max_output_boxes), dtype=torch.int32)
|
| 131 |
+
return num_det, det_boxes, det_scores, det_classes
|
| 132 |
+
|
| 133 |
+
@staticmethod
|
| 134 |
+
def symbolic(g,
|
| 135 |
+
boxes,
|
| 136 |
+
scores,
|
| 137 |
+
background_class=-1,
|
| 138 |
+
box_coding=1,
|
| 139 |
+
iou_threshold=0.45,
|
| 140 |
+
max_output_boxes=100,
|
| 141 |
+
plugin_version="1",
|
| 142 |
+
score_activation=0,
|
| 143 |
+
score_threshold=0.25):
|
| 144 |
+
out = g.op("TRT::EfficientNMS_TRT",
|
| 145 |
+
boxes,
|
| 146 |
+
scores,
|
| 147 |
+
background_class_i=background_class,
|
| 148 |
+
box_coding_i=box_coding,
|
| 149 |
+
iou_threshold_f=iou_threshold,
|
| 150 |
+
max_output_boxes_i=max_output_boxes,
|
| 151 |
+
plugin_version_s=plugin_version,
|
| 152 |
+
score_activation_i=score_activation,
|
| 153 |
+
score_threshold_f=score_threshold,
|
| 154 |
+
outputs=4)
|
| 155 |
+
nums, boxes, scores, classes = out
|
| 156 |
+
return nums, boxes, scores, classes
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
class ONNX_ORT(nn.Module):
|
| 160 |
+
'''onnx module with ONNX-Runtime NMS operation.'''
|
| 161 |
+
def __init__(self, max_obj=100, iou_thres=0.45, score_thres=0.25, max_wh=640, device=None):
|
| 162 |
+
super().__init__()
|
| 163 |
+
self.device = device if device else torch.device("cpu")
|
| 164 |
+
self.max_obj = torch.tensor([max_obj]).to(device)
|
| 165 |
+
self.iou_threshold = torch.tensor([iou_thres]).to(device)
|
| 166 |
+
self.score_threshold = torch.tensor([score_thres]).to(device)
|
| 167 |
+
self.max_wh = max_wh # if max_wh != 0 : non-agnostic else : agnostic
|
| 168 |
+
self.convert_matrix = torch.tensor([[1, 0, 1, 0], [0, 1, 0, 1], [-0.5, 0, 0.5, 0], [0, -0.5, 0, 0.5]],
|
| 169 |
+
dtype=torch.float32,
|
| 170 |
+
device=self.device)
|
| 171 |
+
|
| 172 |
+
def forward(self, x):
|
| 173 |
+
boxes = x[:, :, :4]
|
| 174 |
+
conf = x[:, :, 4:5]
|
| 175 |
+
scores = x[:, :, 5:]
|
| 176 |
+
scores *= conf
|
| 177 |
+
boxes @= self.convert_matrix
|
| 178 |
+
max_score, category_id = scores.max(2, keepdim=True)
|
| 179 |
+
dis = category_id.float() * self.max_wh
|
| 180 |
+
nmsbox = boxes + dis
|
| 181 |
+
max_score_tp = max_score.transpose(1, 2).contiguous()
|
| 182 |
+
selected_indices = ORT_NMS.apply(nmsbox, max_score_tp, self.max_obj, self.iou_threshold, self.score_threshold)
|
| 183 |
+
X, Y = selected_indices[:, 0], selected_indices[:, 2]
|
| 184 |
+
selected_boxes = boxes[X, Y, :]
|
| 185 |
+
selected_categories = category_id[X, Y, :].float()
|
| 186 |
+
selected_scores = max_score[X, Y, :]
|
| 187 |
+
X = X.unsqueeze(1).float()
|
| 188 |
+
return torch.cat([X, selected_boxes, selected_categories, selected_scores], 1)
|
| 189 |
+
|
| 190 |
+
class ONNX_TRT(nn.Module):
|
| 191 |
+
'''onnx module with TensorRT NMS operation.'''
|
| 192 |
+
def __init__(self, max_obj=100, iou_thres=0.45, score_thres=0.25, max_wh=None ,device=None):
|
| 193 |
+
super().__init__()
|
| 194 |
+
assert max_wh is None
|
| 195 |
+
self.device = device if device else torch.device('cpu')
|
| 196 |
+
self.background_class = -1,
|
| 197 |
+
self.box_coding = 1,
|
| 198 |
+
self.iou_threshold = iou_thres
|
| 199 |
+
self.max_obj = max_obj
|
| 200 |
+
self.plugin_version = '1'
|
| 201 |
+
self.score_activation = 0
|
| 202 |
+
self.score_threshold = score_thres
|
| 203 |
+
|
| 204 |
+
def forward(self, x):
|
| 205 |
+
boxes = x[:, :, :4]
|
| 206 |
+
conf = x[:, :, 4:5]
|
| 207 |
+
scores = x[:, :, 5:]
|
| 208 |
+
scores *= conf
|
| 209 |
+
num_det, det_boxes, det_scores, det_classes = TRT_NMS.apply(boxes, scores, self.background_class, self.box_coding,
|
| 210 |
+
self.iou_threshold, self.max_obj,
|
| 211 |
+
self.plugin_version, self.score_activation,
|
| 212 |
+
self.score_threshold)
|
| 213 |
+
return num_det, det_boxes, det_scores, det_classes
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
class End2End(nn.Module):
|
| 217 |
+
'''export onnx or tensorrt model with NMS operation.'''
|
| 218 |
+
def __init__(self, model, max_obj=100, iou_thres=0.45, score_thres=0.25, max_wh=None, device=None):
|
| 219 |
+
super().__init__()
|
| 220 |
+
device = device if device else torch.device('cpu')
|
| 221 |
+
assert isinstance(max_wh,(int)) or max_wh is None
|
| 222 |
+
self.model = model.to(device)
|
| 223 |
+
self.model.model[-1].end2end = True
|
| 224 |
+
self.patch_model = ONNX_TRT if max_wh is None else ONNX_ORT
|
| 225 |
+
self.end2end = self.patch_model(max_obj, iou_thres, score_thres, max_wh, device)
|
| 226 |
+
self.end2end.eval()
|
| 227 |
+
|
| 228 |
+
def forward(self, x):
|
| 229 |
+
x = self.model(x)
|
| 230 |
+
x = self.end2end(x)
|
| 231 |
+
return x
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def attempt_load(weights, map_location=None):
|
| 238 |
+
# Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a
|
| 239 |
+
model = Ensemble()
|
| 240 |
+
for w in weights if isinstance(weights, list) else [weights]:
|
| 241 |
+
attempt_download(w)
|
| 242 |
+
ckpt = torch.load(w, map_location=map_location) # load
|
| 243 |
+
model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval()) # FP32 model
|
| 244 |
+
|
| 245 |
+
# Compatibility updates
|
| 246 |
+
for m in model.modules():
|
| 247 |
+
if type(m) in [nn.Hardswish, nn.LeakyReLU, nn.ReLU, nn.ReLU6, nn.SiLU]:
|
| 248 |
+
m.inplace = True # pytorch 1.7.0 compatibility
|
| 249 |
+
elif type(m) is nn.Upsample:
|
| 250 |
+
m.recompute_scale_factor = None # torch 1.11.0 compatibility
|
| 251 |
+
elif type(m) is Conv:
|
| 252 |
+
m._non_persistent_buffers_set = set() # pytorch 1.6.0 compatibility
|
| 253 |
+
|
| 254 |
+
if len(model) == 1:
|
| 255 |
+
return model[-1] # return model
|
| 256 |
+
else:
|
| 257 |
+
print('Ensemble created with %s\n' % weights)
|
| 258 |
+
for k in ['names', 'stride']:
|
| 259 |
+
setattr(model, k, getattr(model[-1], k))
|
| 260 |
+
return model # return ensemble
|
| 261 |
+
|
| 262 |
+
|
detection/models/yolo.py
ADDED
|
@@ -0,0 +1,843 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import logging
|
| 3 |
+
import sys
|
| 4 |
+
from copy import deepcopy
|
| 5 |
+
|
| 6 |
+
sys.path.append('./') # to run '$ python *.py' files in subdirectories
|
| 7 |
+
logger = logging.getLogger(__name__)
|
| 8 |
+
import torch
|
| 9 |
+
from models.common import *
|
| 10 |
+
from models.experimental import *
|
| 11 |
+
from utils.autoanchor import check_anchor_order
|
| 12 |
+
from utils.general import make_divisible, check_file, set_logging
|
| 13 |
+
from utils.torch_utils import time_synchronized, fuse_conv_and_bn, model_info, scale_img, initialize_weights, \
|
| 14 |
+
select_device, copy_attr
|
| 15 |
+
from utils.loss import SigmoidBin
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
import thop # for FLOPS computation
|
| 19 |
+
except ImportError:
|
| 20 |
+
thop = None
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Detect(nn.Module):
|
| 24 |
+
stride = None # strides computed during build
|
| 25 |
+
export = False # onnx export
|
| 26 |
+
end2end = False
|
| 27 |
+
include_nms = False
|
| 28 |
+
concat = False
|
| 29 |
+
|
| 30 |
+
def __init__(self, nc=80, anchors=(), ch=()): # detection layer
|
| 31 |
+
super(Detect, self).__init__()
|
| 32 |
+
self.nc = nc # number of classes
|
| 33 |
+
self.no = nc + 5 # number of outputs per anchor
|
| 34 |
+
self.nl = len(anchors) # number of detection layers
|
| 35 |
+
self.na = len(anchors[0]) // 2 # number of anchors
|
| 36 |
+
self.grid = [torch.zeros(1)] * self.nl # init grid
|
| 37 |
+
a = torch.tensor(anchors).float().view(self.nl, -1, 2)
|
| 38 |
+
self.register_buffer('anchors', a) # shape(nl,na,2)
|
| 39 |
+
self.register_buffer('anchor_grid', a.clone().view(self.nl, 1, -1, 1, 1, 2)) # shape(nl,1,na,1,1,2)
|
| 40 |
+
self.m = nn.ModuleList(nn.Conv2d(x, self.no * self.na, 1) for x in ch) # output conv
|
| 41 |
+
|
| 42 |
+
def forward(self, x):
|
| 43 |
+
# x = x.copy() # for profiling
|
| 44 |
+
z = [] # inference output
|
| 45 |
+
self.training |= self.export
|
| 46 |
+
for i in range(self.nl):
|
| 47 |
+
x[i] = self.m[i](x[i]) # conv
|
| 48 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 49 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 50 |
+
|
| 51 |
+
if not self.training: # inference
|
| 52 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 53 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 54 |
+
y = x[i].sigmoid()
|
| 55 |
+
if not torch.onnx.is_in_onnx_export():
|
| 56 |
+
y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 57 |
+
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 58 |
+
else:
|
| 59 |
+
xy, wh, conf = y.split((2, 2, self.nc + 1), 4) # y.tensor_split((2, 4, 5), 4) # torch 1.8.0
|
| 60 |
+
xy = xy * (2. * self.stride[i]) + (self.stride[i] * (self.grid[i] - 0.5)) # new xy
|
| 61 |
+
wh = wh ** 2 * (4 * self.anchor_grid[i].data) # new wh
|
| 62 |
+
y = torch.cat((xy, wh, conf), 4)
|
| 63 |
+
z.append(y.view(bs, -1, self.no))
|
| 64 |
+
|
| 65 |
+
if self.training:
|
| 66 |
+
out = x
|
| 67 |
+
elif self.end2end:
|
| 68 |
+
out = torch.cat(z, 1)
|
| 69 |
+
elif self.include_nms:
|
| 70 |
+
z = self.convert(z)
|
| 71 |
+
out = (z, )
|
| 72 |
+
elif self.concat:
|
| 73 |
+
out = torch.cat(z, 1)
|
| 74 |
+
else:
|
| 75 |
+
out = (torch.cat(z, 1), x)
|
| 76 |
+
|
| 77 |
+
return out
|
| 78 |
+
|
| 79 |
+
@staticmethod
|
| 80 |
+
def _make_grid(nx=20, ny=20):
|
| 81 |
+
yv, xv = torch.meshgrid([torch.arange(ny), torch.arange(nx)])
|
| 82 |
+
return torch.stack((xv, yv), 2).view((1, 1, ny, nx, 2)).float()
|
| 83 |
+
|
| 84 |
+
def convert(self, z):
|
| 85 |
+
z = torch.cat(z, 1)
|
| 86 |
+
box = z[:, :, :4]
|
| 87 |
+
conf = z[:, :, 4:5]
|
| 88 |
+
score = z[:, :, 5:]
|
| 89 |
+
score *= conf
|
| 90 |
+
convert_matrix = torch.tensor([[1, 0, 1, 0], [0, 1, 0, 1], [-0.5, 0, 0.5, 0], [0, -0.5, 0, 0.5]],
|
| 91 |
+
dtype=torch.float32,
|
| 92 |
+
device=z.device)
|
| 93 |
+
box @= convert_matrix
|
| 94 |
+
return (box, score)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
class IDetect(nn.Module):
|
| 98 |
+
stride = None # strides computed during build
|
| 99 |
+
export = False # onnx export
|
| 100 |
+
end2end = False
|
| 101 |
+
include_nms = False
|
| 102 |
+
concat = False
|
| 103 |
+
|
| 104 |
+
def __init__(self, nc=80, anchors=(), ch=()): # detection layer
|
| 105 |
+
super(IDetect, self).__init__()
|
| 106 |
+
self.nc = nc # number of classes
|
| 107 |
+
self.no = nc + 5 # number of outputs per anchor
|
| 108 |
+
self.nl = len(anchors) # number of detection layers
|
| 109 |
+
self.na = len(anchors[0]) // 2 # number of anchors
|
| 110 |
+
self.grid = [torch.zeros(1)] * self.nl # init grid
|
| 111 |
+
a = torch.tensor(anchors).float().view(self.nl, -1, 2)
|
| 112 |
+
self.register_buffer('anchors', a) # shape(nl,na,2)
|
| 113 |
+
self.register_buffer('anchor_grid', a.clone().view(self.nl, 1, -1, 1, 1, 2)) # shape(nl,1,na,1,1,2)
|
| 114 |
+
self.m = nn.ModuleList(nn.Conv2d(x, self.no * self.na, 1) for x in ch) # output conv
|
| 115 |
+
|
| 116 |
+
self.ia = nn.ModuleList(ImplicitA(x) for x in ch)
|
| 117 |
+
self.im = nn.ModuleList(ImplicitM(self.no * self.na) for _ in ch)
|
| 118 |
+
|
| 119 |
+
def forward(self, x):
|
| 120 |
+
# x = x.copy() # for profiling
|
| 121 |
+
z = [] # inference output
|
| 122 |
+
self.training |= self.export
|
| 123 |
+
for i in range(self.nl):
|
| 124 |
+
x[i] = self.m[i](self.ia[i](x[i])) # conv
|
| 125 |
+
x[i] = self.im[i](x[i])
|
| 126 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 127 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 128 |
+
|
| 129 |
+
if not self.training: # inference
|
| 130 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 131 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 132 |
+
|
| 133 |
+
y = x[i].sigmoid()
|
| 134 |
+
y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 135 |
+
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 136 |
+
z.append(y.view(bs, -1, self.no))
|
| 137 |
+
|
| 138 |
+
return x if self.training else (torch.cat(z, 1), x)
|
| 139 |
+
|
| 140 |
+
def fuseforward(self, x):
|
| 141 |
+
# x = x.copy() # for profiling
|
| 142 |
+
z = [] # inference output
|
| 143 |
+
self.training |= self.export
|
| 144 |
+
for i in range(self.nl):
|
| 145 |
+
x[i] = self.m[i](x[i]) # conv
|
| 146 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 147 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 148 |
+
|
| 149 |
+
if not self.training: # inference
|
| 150 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 151 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 152 |
+
|
| 153 |
+
y = x[i].sigmoid()
|
| 154 |
+
if not torch.onnx.is_in_onnx_export():
|
| 155 |
+
y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 156 |
+
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 157 |
+
else:
|
| 158 |
+
xy, wh, conf = y.split((2, 2, self.nc + 1), 4) # y.tensor_split((2, 4, 5), 4) # torch 1.8.0
|
| 159 |
+
xy = xy * (2. * self.stride[i]) + (self.stride[i] * (self.grid[i] - 0.5)) # new xy
|
| 160 |
+
wh = wh ** 2 * (4 * self.anchor_grid[i].data) # new wh
|
| 161 |
+
y = torch.cat((xy, wh, conf), 4)
|
| 162 |
+
z.append(y.view(bs, -1, self.no))
|
| 163 |
+
|
| 164 |
+
if self.training:
|
| 165 |
+
out = x
|
| 166 |
+
elif self.end2end:
|
| 167 |
+
out = torch.cat(z, 1)
|
| 168 |
+
elif self.include_nms:
|
| 169 |
+
z = self.convert(z)
|
| 170 |
+
out = (z, )
|
| 171 |
+
elif self.concat:
|
| 172 |
+
out = torch.cat(z, 1)
|
| 173 |
+
else:
|
| 174 |
+
out = (torch.cat(z, 1), x)
|
| 175 |
+
|
| 176 |
+
return out
|
| 177 |
+
|
| 178 |
+
def fuse(self):
|
| 179 |
+
print("IDetect.fuse")
|
| 180 |
+
# fuse ImplicitA and Convolution
|
| 181 |
+
for i in range(len(self.m)):
|
| 182 |
+
c1,c2,_,_ = self.m[i].weight.shape
|
| 183 |
+
c1_,c2_, _,_ = self.ia[i].implicit.shape
|
| 184 |
+
self.m[i].bias += torch.matmul(self.m[i].weight.reshape(c1,c2),self.ia[i].implicit.reshape(c2_,c1_)).squeeze(1)
|
| 185 |
+
|
| 186 |
+
# fuse ImplicitM and Convolution
|
| 187 |
+
for i in range(len(self.m)):
|
| 188 |
+
c1,c2, _,_ = self.im[i].implicit.shape
|
| 189 |
+
self.m[i].bias *= self.im[i].implicit.reshape(c2)
|
| 190 |
+
self.m[i].weight *= self.im[i].implicit.transpose(0,1)
|
| 191 |
+
|
| 192 |
+
@staticmethod
|
| 193 |
+
def _make_grid(nx=20, ny=20):
|
| 194 |
+
yv, xv = torch.meshgrid([torch.arange(ny), torch.arange(nx)])
|
| 195 |
+
return torch.stack((xv, yv), 2).view((1, 1, ny, nx, 2)).float()
|
| 196 |
+
|
| 197 |
+
def convert(self, z):
|
| 198 |
+
z = torch.cat(z, 1)
|
| 199 |
+
box = z[:, :, :4]
|
| 200 |
+
conf = z[:, :, 4:5]
|
| 201 |
+
score = z[:, :, 5:]
|
| 202 |
+
score *= conf
|
| 203 |
+
convert_matrix = torch.tensor([[1, 0, 1, 0], [0, 1, 0, 1], [-0.5, 0, 0.5, 0], [0, -0.5, 0, 0.5]],
|
| 204 |
+
dtype=torch.float32,
|
| 205 |
+
device=z.device)
|
| 206 |
+
box @= convert_matrix
|
| 207 |
+
return (box, score)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
class IKeypoint(nn.Module):
|
| 211 |
+
stride = None # strides computed during build
|
| 212 |
+
export = False # onnx export
|
| 213 |
+
|
| 214 |
+
def __init__(self, nc=80, anchors=(), nkpt=17, ch=(), inplace=True, dw_conv_kpt=False): # detection layer
|
| 215 |
+
super(IKeypoint, self).__init__()
|
| 216 |
+
self.nc = nc # number of classes
|
| 217 |
+
self.nkpt = nkpt
|
| 218 |
+
self.dw_conv_kpt = dw_conv_kpt
|
| 219 |
+
self.no_det=(nc + 5) # number of outputs per anchor for box and class
|
| 220 |
+
self.no_kpt = 3*self.nkpt ## number of outputs per anchor for keypoints
|
| 221 |
+
self.no = self.no_det+self.no_kpt
|
| 222 |
+
self.nl = len(anchors) # number of detection layers
|
| 223 |
+
self.na = len(anchors[0]) // 2 # number of anchors
|
| 224 |
+
self.grid = [torch.zeros(1)] * self.nl # init grid
|
| 225 |
+
self.flip_test = False
|
| 226 |
+
a = torch.tensor(anchors).float().view(self.nl, -1, 2)
|
| 227 |
+
self.register_buffer('anchors', a) # shape(nl,na,2)
|
| 228 |
+
self.register_buffer('anchor_grid', a.clone().view(self.nl, 1, -1, 1, 1, 2)) # shape(nl,1,na,1,1,2)
|
| 229 |
+
self.m = nn.ModuleList(nn.Conv2d(x, self.no_det * self.na, 1) for x in ch) # output conv
|
| 230 |
+
|
| 231 |
+
self.ia = nn.ModuleList(ImplicitA(x) for x in ch)
|
| 232 |
+
self.im = nn.ModuleList(ImplicitM(self.no_det * self.na) for _ in ch)
|
| 233 |
+
|
| 234 |
+
if self.nkpt is not None:
|
| 235 |
+
if self.dw_conv_kpt: #keypoint head is slightly more complex
|
| 236 |
+
self.m_kpt = nn.ModuleList(
|
| 237 |
+
nn.Sequential(DWConv(x, x, k=3), Conv(x,x),
|
| 238 |
+
DWConv(x, x, k=3), Conv(x, x),
|
| 239 |
+
DWConv(x, x, k=3), Conv(x,x),
|
| 240 |
+
DWConv(x, x, k=3), Conv(x, x),
|
| 241 |
+
DWConv(x, x, k=3), Conv(x, x),
|
| 242 |
+
DWConv(x, x, k=3), nn.Conv2d(x, self.no_kpt * self.na, 1)) for x in ch)
|
| 243 |
+
else: #keypoint head is a single convolution
|
| 244 |
+
self.m_kpt = nn.ModuleList(nn.Conv2d(x, self.no_kpt * self.na, 1) for x in ch)
|
| 245 |
+
|
| 246 |
+
self.inplace = inplace # use in-place ops (e.g. slice assignment)
|
| 247 |
+
|
| 248 |
+
def forward(self, x):
|
| 249 |
+
# x = x.copy() # for profiling
|
| 250 |
+
z = [] # inference output
|
| 251 |
+
self.training |= self.export
|
| 252 |
+
for i in range(self.nl):
|
| 253 |
+
if self.nkpt is None or self.nkpt==0:
|
| 254 |
+
x[i] = self.im[i](self.m[i](self.ia[i](x[i]))) # conv
|
| 255 |
+
else :
|
| 256 |
+
x[i] = torch.cat((self.im[i](self.m[i](self.ia[i](x[i]))), self.m_kpt[i](x[i])), axis=1)
|
| 257 |
+
|
| 258 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 259 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 260 |
+
x_det = x[i][..., :6]
|
| 261 |
+
x_kpt = x[i][..., 6:]
|
| 262 |
+
|
| 263 |
+
if not self.training: # inference
|
| 264 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 265 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 266 |
+
kpt_grid_x = self.grid[i][..., 0:1]
|
| 267 |
+
kpt_grid_y = self.grid[i][..., 1:2]
|
| 268 |
+
|
| 269 |
+
if self.nkpt == 0:
|
| 270 |
+
y = x[i].sigmoid()
|
| 271 |
+
else:
|
| 272 |
+
y = x_det.sigmoid()
|
| 273 |
+
|
| 274 |
+
if self.inplace:
|
| 275 |
+
xy = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 276 |
+
wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i].view(1, self.na, 1, 1, 2) # wh
|
| 277 |
+
if self.nkpt != 0:
|
| 278 |
+
x_kpt[..., 0::3] = (x_kpt[..., ::3] * 2. - 0.5 + kpt_grid_x.repeat(1,1,1,1,17)) * self.stride[i] # xy
|
| 279 |
+
x_kpt[..., 1::3] = (x_kpt[..., 1::3] * 2. - 0.5 + kpt_grid_y.repeat(1,1,1,1,17)) * self.stride[i] # xy
|
| 280 |
+
#x_kpt[..., 0::3] = (x_kpt[..., ::3] + kpt_grid_x.repeat(1,1,1,1,17)) * self.stride[i] # xy
|
| 281 |
+
#x_kpt[..., 1::3] = (x_kpt[..., 1::3] + kpt_grid_y.repeat(1,1,1,1,17)) * self.stride[i] # xy
|
| 282 |
+
#print('=============')
|
| 283 |
+
#print(self.anchor_grid[i].shape)
|
| 284 |
+
#print(self.anchor_grid[i][...,0].unsqueeze(4).shape)
|
| 285 |
+
#print(x_kpt[..., 0::3].shape)
|
| 286 |
+
#x_kpt[..., 0::3] = ((x_kpt[..., 0::3].tanh() * 2.) ** 3 * self.anchor_grid[i][...,0].unsqueeze(4).repeat(1,1,1,1,self.nkpt)) + kpt_grid_x.repeat(1,1,1,1,17) * self.stride[i] # xy
|
| 287 |
+
#x_kpt[..., 1::3] = ((x_kpt[..., 1::3].tanh() * 2.) ** 3 * self.anchor_grid[i][...,1].unsqueeze(4).repeat(1,1,1,1,self.nkpt)) + kpt_grid_y.repeat(1,1,1,1,17) * self.stride[i] # xy
|
| 288 |
+
#x_kpt[..., 0::3] = (((x_kpt[..., 0::3].sigmoid() * 4.) ** 2 - 8.) * self.anchor_grid[i][...,0].unsqueeze(4).repeat(1,1,1,1,self.nkpt)) + kpt_grid_x.repeat(1,1,1,1,17) * self.stride[i] # xy
|
| 289 |
+
#x_kpt[..., 1::3] = (((x_kpt[..., 1::3].sigmoid() * 4.) ** 2 - 8.) * self.anchor_grid[i][...,1].unsqueeze(4).repeat(1,1,1,1,self.nkpt)) + kpt_grid_y.repeat(1,1,1,1,17) * self.stride[i] # xy
|
| 290 |
+
x_kpt[..., 2::3] = x_kpt[..., 2::3].sigmoid()
|
| 291 |
+
|
| 292 |
+
y = torch.cat((xy, wh, y[..., 4:], x_kpt), dim = -1)
|
| 293 |
+
|
| 294 |
+
else: # for YOLOv5 on AWS Inferentia https://github.com/ultralytics/yolov5/pull/2953
|
| 295 |
+
xy = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 296 |
+
wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 297 |
+
if self.nkpt != 0:
|
| 298 |
+
y[..., 6:] = (y[..., 6:] * 2. - 0.5 + self.grid[i].repeat((1,1,1,1,self.nkpt))) * self.stride[i] # xy
|
| 299 |
+
y = torch.cat((xy, wh, y[..., 4:]), -1)
|
| 300 |
+
|
| 301 |
+
z.append(y.view(bs, -1, self.no))
|
| 302 |
+
|
| 303 |
+
return x if self.training else (torch.cat(z, 1), x)
|
| 304 |
+
|
| 305 |
+
@staticmethod
|
| 306 |
+
def _make_grid(nx=20, ny=20):
|
| 307 |
+
yv, xv = torch.meshgrid([torch.arange(ny), torch.arange(nx)])
|
| 308 |
+
return torch.stack((xv, yv), 2).view((1, 1, ny, nx, 2)).float()
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
class IAuxDetect(nn.Module):
|
| 312 |
+
stride = None # strides computed during build
|
| 313 |
+
export = False # onnx export
|
| 314 |
+
end2end = False
|
| 315 |
+
include_nms = False
|
| 316 |
+
concat = False
|
| 317 |
+
|
| 318 |
+
def __init__(self, nc=80, anchors=(), ch=()): # detection layer
|
| 319 |
+
super(IAuxDetect, self).__init__()
|
| 320 |
+
self.nc = nc # number of classes
|
| 321 |
+
self.no = nc + 5 # number of outputs per anchor
|
| 322 |
+
self.nl = len(anchors) # number of detection layers
|
| 323 |
+
self.na = len(anchors[0]) // 2 # number of anchors
|
| 324 |
+
self.grid = [torch.zeros(1)] * self.nl # init grid
|
| 325 |
+
a = torch.tensor(anchors).float().view(self.nl, -1, 2)
|
| 326 |
+
self.register_buffer('anchors', a) # shape(nl,na,2)
|
| 327 |
+
self.register_buffer('anchor_grid', a.clone().view(self.nl, 1, -1, 1, 1, 2)) # shape(nl,1,na,1,1,2)
|
| 328 |
+
self.m = nn.ModuleList(nn.Conv2d(x, self.no * self.na, 1) for x in ch[:self.nl]) # output conv
|
| 329 |
+
self.m2 = nn.ModuleList(nn.Conv2d(x, self.no * self.na, 1) for x in ch[self.nl:]) # output conv
|
| 330 |
+
|
| 331 |
+
self.ia = nn.ModuleList(ImplicitA(x) for x in ch[:self.nl])
|
| 332 |
+
self.im = nn.ModuleList(ImplicitM(self.no * self.na) for _ in ch[:self.nl])
|
| 333 |
+
|
| 334 |
+
def forward(self, x):
|
| 335 |
+
# x = x.copy() # for profiling
|
| 336 |
+
z = [] # inference output
|
| 337 |
+
self.training |= self.export
|
| 338 |
+
for i in range(self.nl):
|
| 339 |
+
x[i] = self.m[i](self.ia[i](x[i])) # conv
|
| 340 |
+
x[i] = self.im[i](x[i])
|
| 341 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 342 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 343 |
+
|
| 344 |
+
x[i+self.nl] = self.m2[i](x[i+self.nl])
|
| 345 |
+
x[i+self.nl] = x[i+self.nl].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 346 |
+
|
| 347 |
+
if not self.training: # inference
|
| 348 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 349 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 350 |
+
|
| 351 |
+
y = x[i].sigmoid()
|
| 352 |
+
if not torch.onnx.is_in_onnx_export():
|
| 353 |
+
y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 354 |
+
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 355 |
+
else:
|
| 356 |
+
xy, wh, conf = y.split((2, 2, self.nc + 1), 4) # y.tensor_split((2, 4, 5), 4) # torch 1.8.0
|
| 357 |
+
xy = xy * (2. * self.stride[i]) + (self.stride[i] * (self.grid[i] - 0.5)) # new xy
|
| 358 |
+
wh = wh ** 2 * (4 * self.anchor_grid[i].data) # new wh
|
| 359 |
+
y = torch.cat((xy, wh, conf), 4)
|
| 360 |
+
z.append(y.view(bs, -1, self.no))
|
| 361 |
+
|
| 362 |
+
return x if self.training else (torch.cat(z, 1), x[:self.nl])
|
| 363 |
+
|
| 364 |
+
def fuseforward(self, x):
|
| 365 |
+
# x = x.copy() # for profiling
|
| 366 |
+
z = [] # inference output
|
| 367 |
+
self.training |= self.export
|
| 368 |
+
for i in range(self.nl):
|
| 369 |
+
x[i] = self.m[i](x[i]) # conv
|
| 370 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 371 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 372 |
+
|
| 373 |
+
if not self.training: # inference
|
| 374 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 375 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 376 |
+
|
| 377 |
+
y = x[i].sigmoid()
|
| 378 |
+
if not torch.onnx.is_in_onnx_export():
|
| 379 |
+
y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 380 |
+
y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 381 |
+
else:
|
| 382 |
+
xy = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 383 |
+
wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i].data # wh
|
| 384 |
+
y = torch.cat((xy, wh, y[..., 4:]), -1)
|
| 385 |
+
z.append(y.view(bs, -1, self.no))
|
| 386 |
+
|
| 387 |
+
if self.training:
|
| 388 |
+
out = x
|
| 389 |
+
elif self.end2end:
|
| 390 |
+
out = torch.cat(z, 1)
|
| 391 |
+
elif self.include_nms:
|
| 392 |
+
z = self.convert(z)
|
| 393 |
+
out = (z, )
|
| 394 |
+
elif self.concat:
|
| 395 |
+
out = torch.cat(z, 1)
|
| 396 |
+
else:
|
| 397 |
+
out = (torch.cat(z, 1), x)
|
| 398 |
+
|
| 399 |
+
return out
|
| 400 |
+
|
| 401 |
+
def fuse(self):
|
| 402 |
+
print("IAuxDetect.fuse")
|
| 403 |
+
# fuse ImplicitA and Convolution
|
| 404 |
+
for i in range(len(self.m)):
|
| 405 |
+
c1,c2,_,_ = self.m[i].weight.shape
|
| 406 |
+
c1_,c2_, _,_ = self.ia[i].implicit.shape
|
| 407 |
+
self.m[i].bias += torch.matmul(self.m[i].weight.reshape(c1,c2),self.ia[i].implicit.reshape(c2_,c1_)).squeeze(1)
|
| 408 |
+
|
| 409 |
+
# fuse ImplicitM and Convolution
|
| 410 |
+
for i in range(len(self.m)):
|
| 411 |
+
c1,c2, _,_ = self.im[i].implicit.shape
|
| 412 |
+
self.m[i].bias *= self.im[i].implicit.reshape(c2)
|
| 413 |
+
self.m[i].weight *= self.im[i].implicit.transpose(0,1)
|
| 414 |
+
|
| 415 |
+
@staticmethod
|
| 416 |
+
def _make_grid(nx=20, ny=20):
|
| 417 |
+
yv, xv = torch.meshgrid([torch.arange(ny), torch.arange(nx)])
|
| 418 |
+
return torch.stack((xv, yv), 2).view((1, 1, ny, nx, 2)).float()
|
| 419 |
+
|
| 420 |
+
def convert(self, z):
|
| 421 |
+
z = torch.cat(z, 1)
|
| 422 |
+
box = z[:, :, :4]
|
| 423 |
+
conf = z[:, :, 4:5]
|
| 424 |
+
score = z[:, :, 5:]
|
| 425 |
+
score *= conf
|
| 426 |
+
convert_matrix = torch.tensor([[1, 0, 1, 0], [0, 1, 0, 1], [-0.5, 0, 0.5, 0], [0, -0.5, 0, 0.5]],
|
| 427 |
+
dtype=torch.float32,
|
| 428 |
+
device=z.device)
|
| 429 |
+
box @= convert_matrix
|
| 430 |
+
return (box, score)
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
class IBin(nn.Module):
|
| 434 |
+
stride = None # strides computed during build
|
| 435 |
+
export = False # onnx export
|
| 436 |
+
|
| 437 |
+
def __init__(self, nc=80, anchors=(), ch=(), bin_count=21): # detection layer
|
| 438 |
+
super(IBin, self).__init__()
|
| 439 |
+
self.nc = nc # number of classes
|
| 440 |
+
self.bin_count = bin_count
|
| 441 |
+
|
| 442 |
+
self.w_bin_sigmoid = SigmoidBin(bin_count=self.bin_count, min=0.0, max=4.0)
|
| 443 |
+
self.h_bin_sigmoid = SigmoidBin(bin_count=self.bin_count, min=0.0, max=4.0)
|
| 444 |
+
# classes, x,y,obj
|
| 445 |
+
self.no = nc + 3 + \
|
| 446 |
+
self.w_bin_sigmoid.get_length() + self.h_bin_sigmoid.get_length() # w-bce, h-bce
|
| 447 |
+
# + self.x_bin_sigmoid.get_length() + self.y_bin_sigmoid.get_length()
|
| 448 |
+
|
| 449 |
+
self.nl = len(anchors) # number of detection layers
|
| 450 |
+
self.na = len(anchors[0]) // 2 # number of anchors
|
| 451 |
+
self.grid = [torch.zeros(1)] * self.nl # init grid
|
| 452 |
+
a = torch.tensor(anchors).float().view(self.nl, -1, 2)
|
| 453 |
+
self.register_buffer('anchors', a) # shape(nl,na,2)
|
| 454 |
+
self.register_buffer('anchor_grid', a.clone().view(self.nl, 1, -1, 1, 1, 2)) # shape(nl,1,na,1,1,2)
|
| 455 |
+
self.m = nn.ModuleList(nn.Conv2d(x, self.no * self.na, 1) for x in ch) # output conv
|
| 456 |
+
|
| 457 |
+
self.ia = nn.ModuleList(ImplicitA(x) for x in ch)
|
| 458 |
+
self.im = nn.ModuleList(ImplicitM(self.no * self.na) for _ in ch)
|
| 459 |
+
|
| 460 |
+
def forward(self, x):
|
| 461 |
+
|
| 462 |
+
#self.x_bin_sigmoid.use_fw_regression = True
|
| 463 |
+
#self.y_bin_sigmoid.use_fw_regression = True
|
| 464 |
+
self.w_bin_sigmoid.use_fw_regression = True
|
| 465 |
+
self.h_bin_sigmoid.use_fw_regression = True
|
| 466 |
+
|
| 467 |
+
# x = x.copy() # for profiling
|
| 468 |
+
z = [] # inference output
|
| 469 |
+
self.training |= self.export
|
| 470 |
+
for i in range(self.nl):
|
| 471 |
+
x[i] = self.m[i](self.ia[i](x[i])) # conv
|
| 472 |
+
x[i] = self.im[i](x[i])
|
| 473 |
+
bs, _, ny, nx = x[i].shape # x(bs,255,20,20) to x(bs,3,20,20,85)
|
| 474 |
+
x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()
|
| 475 |
+
|
| 476 |
+
if not self.training: # inference
|
| 477 |
+
if self.grid[i].shape[2:4] != x[i].shape[2:4]:
|
| 478 |
+
self.grid[i] = self._make_grid(nx, ny).to(x[i].device)
|
| 479 |
+
|
| 480 |
+
y = x[i].sigmoid()
|
| 481 |
+
y[..., 0:2] = (y[..., 0:2] * 2. - 0.5 + self.grid[i]) * self.stride[i] # xy
|
| 482 |
+
#y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i] # wh
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
#px = (self.x_bin_sigmoid.forward(y[..., 0:12]) + self.grid[i][..., 0]) * self.stride[i]
|
| 486 |
+
#py = (self.y_bin_sigmoid.forward(y[..., 12:24]) + self.grid[i][..., 1]) * self.stride[i]
|
| 487 |
+
|
| 488 |
+
pw = self.w_bin_sigmoid.forward(y[..., 2:24]) * self.anchor_grid[i][..., 0]
|
| 489 |
+
ph = self.h_bin_sigmoid.forward(y[..., 24:46]) * self.anchor_grid[i][..., 1]
|
| 490 |
+
|
| 491 |
+
#y[..., 0] = px
|
| 492 |
+
#y[..., 1] = py
|
| 493 |
+
y[..., 2] = pw
|
| 494 |
+
y[..., 3] = ph
|
| 495 |
+
|
| 496 |
+
y = torch.cat((y[..., 0:4], y[..., 46:]), dim=-1)
|
| 497 |
+
|
| 498 |
+
z.append(y.view(bs, -1, y.shape[-1]))
|
| 499 |
+
|
| 500 |
+
return x if self.training else (torch.cat(z, 1), x)
|
| 501 |
+
|
| 502 |
+
@staticmethod
|
| 503 |
+
def _make_grid(nx=20, ny=20):
|
| 504 |
+
yv, xv = torch.meshgrid([torch.arange(ny), torch.arange(nx)])
|
| 505 |
+
return torch.stack((xv, yv), 2).view((1, 1, ny, nx, 2)).float()
|
| 506 |
+
|
| 507 |
+
|
| 508 |
+
class Model(nn.Module):
|
| 509 |
+
def __init__(self, cfg='yolor-csp-c.yaml', ch=3, nc=None, anchors=None): # model, input channels, number of classes
|
| 510 |
+
super(Model, self).__init__()
|
| 511 |
+
self.traced = False
|
| 512 |
+
if isinstance(cfg, dict):
|
| 513 |
+
self.yaml = cfg # model dict
|
| 514 |
+
else: # is *.yaml
|
| 515 |
+
import yaml # for torch hub
|
| 516 |
+
self.yaml_file = Path(cfg).name
|
| 517 |
+
with open(cfg) as f:
|
| 518 |
+
self.yaml = yaml.load(f, Loader=yaml.SafeLoader) # model dict
|
| 519 |
+
|
| 520 |
+
# Define model
|
| 521 |
+
ch = self.yaml['ch'] = self.yaml.get('ch', ch) # input channels
|
| 522 |
+
if nc and nc != self.yaml['nc']:
|
| 523 |
+
logger.info(f"Overriding model.yaml nc={self.yaml['nc']} with nc={nc}")
|
| 524 |
+
self.yaml['nc'] = nc # override yaml value
|
| 525 |
+
if anchors:
|
| 526 |
+
logger.info(f'Overriding model.yaml anchors with anchors={anchors}')
|
| 527 |
+
self.yaml['anchors'] = round(anchors) # override yaml value
|
| 528 |
+
self.model, self.save = parse_model(deepcopy(self.yaml), ch=[ch]) # model, savelist
|
| 529 |
+
self.names = [str(i) for i in range(self.yaml['nc'])] # default names
|
| 530 |
+
# print([x.shape for x in self.forward(torch.zeros(1, ch, 64, 64))])
|
| 531 |
+
|
| 532 |
+
# Build strides, anchors
|
| 533 |
+
m = self.model[-1] # Detect()
|
| 534 |
+
if isinstance(m, Detect):
|
| 535 |
+
s = 256 # 2x min stride
|
| 536 |
+
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
|
| 537 |
+
check_anchor_order(m)
|
| 538 |
+
m.anchors /= m.stride.view(-1, 1, 1)
|
| 539 |
+
self.stride = m.stride
|
| 540 |
+
self._initialize_biases() # only run once
|
| 541 |
+
# print('Strides: %s' % m.stride.tolist())
|
| 542 |
+
if isinstance(m, IDetect):
|
| 543 |
+
s = 256 # 2x min stride
|
| 544 |
+
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
|
| 545 |
+
check_anchor_order(m)
|
| 546 |
+
m.anchors /= m.stride.view(-1, 1, 1)
|
| 547 |
+
self.stride = m.stride
|
| 548 |
+
self._initialize_biases() # only run once
|
| 549 |
+
# print('Strides: %s' % m.stride.tolist())
|
| 550 |
+
if isinstance(m, IAuxDetect):
|
| 551 |
+
s = 256 # 2x min stride
|
| 552 |
+
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))[:4]]) # forward
|
| 553 |
+
#print(m.stride)
|
| 554 |
+
check_anchor_order(m)
|
| 555 |
+
m.anchors /= m.stride.view(-1, 1, 1)
|
| 556 |
+
self.stride = m.stride
|
| 557 |
+
self._initialize_aux_biases() # only run once
|
| 558 |
+
# print('Strides: %s' % m.stride.tolist())
|
| 559 |
+
if isinstance(m, IBin):
|
| 560 |
+
s = 256 # 2x min stride
|
| 561 |
+
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
|
| 562 |
+
check_anchor_order(m)
|
| 563 |
+
m.anchors /= m.stride.view(-1, 1, 1)
|
| 564 |
+
self.stride = m.stride
|
| 565 |
+
self._initialize_biases_bin() # only run once
|
| 566 |
+
# print('Strides: %s' % m.stride.tolist())
|
| 567 |
+
if isinstance(m, IKeypoint):
|
| 568 |
+
s = 256 # 2x min stride
|
| 569 |
+
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
|
| 570 |
+
check_anchor_order(m)
|
| 571 |
+
m.anchors /= m.stride.view(-1, 1, 1)
|
| 572 |
+
self.stride = m.stride
|
| 573 |
+
self._initialize_biases_kpt() # only run once
|
| 574 |
+
# print('Strides: %s' % m.stride.tolist())
|
| 575 |
+
|
| 576 |
+
# Init weights, biases
|
| 577 |
+
initialize_weights(self)
|
| 578 |
+
self.info()
|
| 579 |
+
logger.info('')
|
| 580 |
+
|
| 581 |
+
def forward(self, x, augment=False, profile=False):
|
| 582 |
+
if augment:
|
| 583 |
+
img_size = x.shape[-2:] # height, width
|
| 584 |
+
s = [1, 0.83, 0.67] # scales
|
| 585 |
+
f = [None, 3, None] # flips (2-ud, 3-lr)
|
| 586 |
+
y = [] # outputs
|
| 587 |
+
for si, fi in zip(s, f):
|
| 588 |
+
xi = scale_img(x.flip(fi) if fi else x, si, gs=int(self.stride.max()))
|
| 589 |
+
yi = self.forward_once(xi)[0] # forward
|
| 590 |
+
# cv2.imwrite(f'img_{si}.jpg', 255 * xi[0].cpu().numpy().transpose((1, 2, 0))[:, :, ::-1]) # save
|
| 591 |
+
yi[..., :4] /= si # de-scale
|
| 592 |
+
if fi == 2:
|
| 593 |
+
yi[..., 1] = img_size[0] - yi[..., 1] # de-flip ud
|
| 594 |
+
elif fi == 3:
|
| 595 |
+
yi[..., 0] = img_size[1] - yi[..., 0] # de-flip lr
|
| 596 |
+
y.append(yi)
|
| 597 |
+
return torch.cat(y, 1), None # augmented inference, train
|
| 598 |
+
else:
|
| 599 |
+
return self.forward_once(x, profile) # single-scale inference, train
|
| 600 |
+
|
| 601 |
+
def forward_once(self, x, profile=False):
|
| 602 |
+
y, dt = [], [] # outputs
|
| 603 |
+
for m in self.model:
|
| 604 |
+
if m.f != -1: # if not from previous layer
|
| 605 |
+
x = y[m.f] if isinstance(m.f, int) else [x if j == -1 else y[j] for j in m.f] # from earlier layers
|
| 606 |
+
|
| 607 |
+
if not hasattr(self, 'traced'):
|
| 608 |
+
self.traced=False
|
| 609 |
+
|
| 610 |
+
if self.traced:
|
| 611 |
+
if isinstance(m, Detect) or isinstance(m, IDetect) or isinstance(m, IAuxDetect) or isinstance(m, IKeypoint):
|
| 612 |
+
break
|
| 613 |
+
|
| 614 |
+
if profile:
|
| 615 |
+
c = isinstance(m, (Detect, IDetect, IAuxDetect, IBin))
|
| 616 |
+
o = thop.profile(m, inputs=(x.copy() if c else x,), verbose=False)[0] / 1E9 * 2 if thop else 0 # FLOPS
|
| 617 |
+
for _ in range(10):
|
| 618 |
+
m(x.copy() if c else x)
|
| 619 |
+
t = time_synchronized()
|
| 620 |
+
for _ in range(10):
|
| 621 |
+
m(x.copy() if c else x)
|
| 622 |
+
dt.append((time_synchronized() - t) * 100)
|
| 623 |
+
print('%10.1f%10.0f%10.1fms %-40s' % (o, m.np, dt[-1], m.type))
|
| 624 |
+
|
| 625 |
+
x = m(x) # run
|
| 626 |
+
|
| 627 |
+
y.append(x if m.i in self.save else None) # save output
|
| 628 |
+
|
| 629 |
+
if profile:
|
| 630 |
+
print('%.1fms total' % sum(dt))
|
| 631 |
+
return x
|
| 632 |
+
|
| 633 |
+
def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is class frequency
|
| 634 |
+
# https://arxiv.org/abs/1708.02002 section 3.3
|
| 635 |
+
# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
|
| 636 |
+
m = self.model[-1] # Detect() module
|
| 637 |
+
for mi, s in zip(m.m, m.stride): # from
|
| 638 |
+
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
|
| 639 |
+
b.data[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
|
| 640 |
+
b.data[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
|
| 641 |
+
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)
|
| 642 |
+
|
| 643 |
+
def _initialize_aux_biases(self, cf=None): # initialize biases into Detect(), cf is class frequency
|
| 644 |
+
# https://arxiv.org/abs/1708.02002 section 3.3
|
| 645 |
+
# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
|
| 646 |
+
m = self.model[-1] # Detect() module
|
| 647 |
+
for mi, mi2, s in zip(m.m, m.m2, m.stride): # from
|
| 648 |
+
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
|
| 649 |
+
b.data[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
|
| 650 |
+
b.data[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
|
| 651 |
+
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)
|
| 652 |
+
b2 = mi2.bias.view(m.na, -1) # conv.bias(255) to (3,85)
|
| 653 |
+
b2.data[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
|
| 654 |
+
b2.data[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
|
| 655 |
+
mi2.bias = torch.nn.Parameter(b2.view(-1), requires_grad=True)
|
| 656 |
+
|
| 657 |
+
def _initialize_biases_bin(self, cf=None): # initialize biases into Detect(), cf is class frequency
|
| 658 |
+
# https://arxiv.org/abs/1708.02002 section 3.3
|
| 659 |
+
# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
|
| 660 |
+
m = self.model[-1] # Bin() module
|
| 661 |
+
bc = m.bin_count
|
| 662 |
+
for mi, s in zip(m.m, m.stride): # from
|
| 663 |
+
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
|
| 664 |
+
old = b[:, (0,1,2,bc+3)].data
|
| 665 |
+
obj_idx = 2*bc+4
|
| 666 |
+
b[:, :obj_idx].data += math.log(0.6 / (bc + 1 - 0.99))
|
| 667 |
+
b[:, obj_idx].data += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
|
| 668 |
+
b[:, (obj_idx+1):].data += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
|
| 669 |
+
b[:, (0,1,2,bc+3)].data = old
|
| 670 |
+
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)
|
| 671 |
+
|
| 672 |
+
def _initialize_biases_kpt(self, cf=None): # initialize biases into Detect(), cf is class frequency
|
| 673 |
+
# https://arxiv.org/abs/1708.02002 section 3.3
|
| 674 |
+
# cf = torch.bincount(torch.tensor(np.concatenate(dataset.labels, 0)[:, 0]).long(), minlength=nc) + 1.
|
| 675 |
+
m = self.model[-1] # Detect() module
|
| 676 |
+
for mi, s in zip(m.m, m.stride): # from
|
| 677 |
+
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
|
| 678 |
+
b.data[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
|
| 679 |
+
b.data[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
|
| 680 |
+
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)
|
| 681 |
+
|
| 682 |
+
def _print_biases(self):
|
| 683 |
+
m = self.model[-1] # Detect() module
|
| 684 |
+
for mi in m.m: # from
|
| 685 |
+
b = mi.bias.detach().view(m.na, -1).T # conv.bias(255) to (3,85)
|
| 686 |
+
print(('%6g Conv2d.bias:' + '%10.3g' * 6) % (mi.weight.shape[1], *b[:5].mean(1).tolist(), b[5:].mean()))
|
| 687 |
+
|
| 688 |
+
# def _print_weights(self):
|
| 689 |
+
# for m in self.model.modules():
|
| 690 |
+
# if type(m) is Bottleneck:
|
| 691 |
+
# print('%10.3g' % (m.w.detach().sigmoid() * 2)) # shortcut weights
|
| 692 |
+
|
| 693 |
+
def fuse(self): # fuse model Conv2d() + BatchNorm2d() layers
|
| 694 |
+
print('Fusing layers... ')
|
| 695 |
+
for m in self.model.modules():
|
| 696 |
+
if isinstance(m, RepConv):
|
| 697 |
+
#print(f" fuse_repvgg_block")
|
| 698 |
+
m.fuse_repvgg_block()
|
| 699 |
+
elif isinstance(m, RepConv_OREPA):
|
| 700 |
+
#print(f" switch_to_deploy")
|
| 701 |
+
m.switch_to_deploy()
|
| 702 |
+
elif type(m) is Conv and hasattr(m, 'bn'):
|
| 703 |
+
m.conv = fuse_conv_and_bn(m.conv, m.bn) # update conv
|
| 704 |
+
delattr(m, 'bn') # remove batchnorm
|
| 705 |
+
m.forward = m.fuseforward # update forward
|
| 706 |
+
elif isinstance(m, (IDetect, IAuxDetect)):
|
| 707 |
+
m.fuse()
|
| 708 |
+
m.forward = m.fuseforward
|
| 709 |
+
self.info()
|
| 710 |
+
return self
|
| 711 |
+
|
| 712 |
+
def nms(self, mode=True): # add or remove NMS module
|
| 713 |
+
present = type(self.model[-1]) is NMS # last layer is NMS
|
| 714 |
+
if mode and not present:
|
| 715 |
+
print('Adding NMS... ')
|
| 716 |
+
m = NMS() # module
|
| 717 |
+
m.f = -1 # from
|
| 718 |
+
m.i = self.model[-1].i + 1 # index
|
| 719 |
+
self.model.add_module(name='%s' % m.i, module=m) # add
|
| 720 |
+
self.eval()
|
| 721 |
+
elif not mode and present:
|
| 722 |
+
print('Removing NMS... ')
|
| 723 |
+
self.model = self.model[:-1] # remove
|
| 724 |
+
return self
|
| 725 |
+
|
| 726 |
+
def autoshape(self): # add autoShape module
|
| 727 |
+
print('Adding autoShape... ')
|
| 728 |
+
m = autoShape(self) # wrap model
|
| 729 |
+
copy_attr(m, self, include=('yaml', 'nc', 'hyp', 'names', 'stride'), exclude=()) # copy attributes
|
| 730 |
+
return m
|
| 731 |
+
|
| 732 |
+
def info(self, verbose=False, img_size=640): # print model information
|
| 733 |
+
model_info(self, verbose, img_size)
|
| 734 |
+
|
| 735 |
+
|
| 736 |
+
def parse_model(d, ch): # model_dict, input_channels(3)
|
| 737 |
+
logger.info('\n%3s%18s%3s%10s %-40s%-30s' % ('', 'from', 'n', 'params', 'module', 'arguments'))
|
| 738 |
+
anchors, nc, gd, gw = d['anchors'], d['nc'], d['depth_multiple'], d['width_multiple']
|
| 739 |
+
na = (len(anchors[0]) // 2) if isinstance(anchors, list) else anchors # number of anchors
|
| 740 |
+
no = na * (nc + 5) # number of outputs = anchors * (classes + 5)
|
| 741 |
+
|
| 742 |
+
layers, save, c2 = [], [], ch[-1] # layers, savelist, ch out
|
| 743 |
+
for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']): # from, number, module, args
|
| 744 |
+
m = eval(m) if isinstance(m, str) else m # eval strings
|
| 745 |
+
for j, a in enumerate(args):
|
| 746 |
+
try:
|
| 747 |
+
args[j] = eval(a) if isinstance(a, str) else a # eval strings
|
| 748 |
+
except:
|
| 749 |
+
pass
|
| 750 |
+
|
| 751 |
+
n = max(round(n * gd), 1) if n > 1 else n # depth gain
|
| 752 |
+
if m in [nn.Conv2d, Conv, RobustConv, RobustConv2, DWConv, GhostConv, RepConv, RepConv_OREPA, DownC,
|
| 753 |
+
SPP, SPPF, SPPCSPC, GhostSPPCSPC, MixConv2d, Focus, Stem, GhostStem, CrossConv,
|
| 754 |
+
Bottleneck, BottleneckCSPA, BottleneckCSPB, BottleneckCSPC,
|
| 755 |
+
RepBottleneck, RepBottleneckCSPA, RepBottleneckCSPB, RepBottleneckCSPC,
|
| 756 |
+
Res, ResCSPA, ResCSPB, ResCSPC,
|
| 757 |
+
RepRes, RepResCSPA, RepResCSPB, RepResCSPC,
|
| 758 |
+
ResX, ResXCSPA, ResXCSPB, ResXCSPC,
|
| 759 |
+
RepResX, RepResXCSPA, RepResXCSPB, RepResXCSPC,
|
| 760 |
+
Ghost, GhostCSPA, GhostCSPB, GhostCSPC,
|
| 761 |
+
SwinTransformerBlock, STCSPA, STCSPB, STCSPC,
|
| 762 |
+
SwinTransformer2Block, ST2CSPA, ST2CSPB, ST2CSPC]:
|
| 763 |
+
c1, c2 = ch[f], args[0]
|
| 764 |
+
if c2 != no: # if not output
|
| 765 |
+
c2 = make_divisible(c2 * gw, 8)
|
| 766 |
+
|
| 767 |
+
args = [c1, c2, *args[1:]]
|
| 768 |
+
if m in [DownC, SPPCSPC, GhostSPPCSPC,
|
| 769 |
+
BottleneckCSPA, BottleneckCSPB, BottleneckCSPC,
|
| 770 |
+
RepBottleneckCSPA, RepBottleneckCSPB, RepBottleneckCSPC,
|
| 771 |
+
ResCSPA, ResCSPB, ResCSPC,
|
| 772 |
+
RepResCSPA, RepResCSPB, RepResCSPC,
|
| 773 |
+
ResXCSPA, ResXCSPB, ResXCSPC,
|
| 774 |
+
RepResXCSPA, RepResXCSPB, RepResXCSPC,
|
| 775 |
+
GhostCSPA, GhostCSPB, GhostCSPC,
|
| 776 |
+
STCSPA, STCSPB, STCSPC,
|
| 777 |
+
ST2CSPA, ST2CSPB, ST2CSPC]:
|
| 778 |
+
args.insert(2, n) # number of repeats
|
| 779 |
+
n = 1
|
| 780 |
+
elif m is nn.BatchNorm2d:
|
| 781 |
+
args = [ch[f]]
|
| 782 |
+
elif m is Concat:
|
| 783 |
+
c2 = sum([ch[x] for x in f])
|
| 784 |
+
elif m is Chuncat:
|
| 785 |
+
c2 = sum([ch[x] for x in f])
|
| 786 |
+
elif m is Shortcut:
|
| 787 |
+
c2 = ch[f[0]]
|
| 788 |
+
elif m is Foldcut:
|
| 789 |
+
c2 = ch[f] // 2
|
| 790 |
+
elif m in [Detect, IDetect, IAuxDetect, IBin, IKeypoint]:
|
| 791 |
+
args.append([ch[x] for x in f])
|
| 792 |
+
if isinstance(args[1], int): # number of anchors
|
| 793 |
+
args[1] = [list(range(args[1] * 2))] * len(f)
|
| 794 |
+
elif m is ReOrg:
|
| 795 |
+
c2 = ch[f] * 4
|
| 796 |
+
elif m is Contract:
|
| 797 |
+
c2 = ch[f] * args[0] ** 2
|
| 798 |
+
elif m is Expand:
|
| 799 |
+
c2 = ch[f] // args[0] ** 2
|
| 800 |
+
else:
|
| 801 |
+
c2 = ch[f]
|
| 802 |
+
|
| 803 |
+
m_ = nn.Sequential(*[m(*args) for _ in range(n)]) if n > 1 else m(*args) # module
|
| 804 |
+
t = str(m)[8:-2].replace('__main__.', '') # module type
|
| 805 |
+
np = sum([x.numel() for x in m_.parameters()]) # number params
|
| 806 |
+
m_.i, m_.f, m_.type, m_.np = i, f, t, np # attach index, 'from' index, type, number params
|
| 807 |
+
logger.info('%3s%18s%3s%10.0f %-40s%-30s' % (i, f, n, np, t, args)) # print
|
| 808 |
+
save.extend(x % i for x in ([f] if isinstance(f, int) else f) if x != -1) # append to savelist
|
| 809 |
+
layers.append(m_)
|
| 810 |
+
if i == 0:
|
| 811 |
+
ch = []
|
| 812 |
+
ch.append(c2)
|
| 813 |
+
return nn.Sequential(*layers), sorted(save)
|
| 814 |
+
|
| 815 |
+
|
| 816 |
+
if __name__ == '__main__':
|
| 817 |
+
parser = argparse.ArgumentParser()
|
| 818 |
+
parser.add_argument('--cfg', type=str, default='yolor-csp-c.yaml', help='model.yaml')
|
| 819 |
+
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
| 820 |
+
parser.add_argument('--profile', action='store_true', help='profile model speed')
|
| 821 |
+
opt = parser.parse_args()
|
| 822 |
+
opt.cfg = check_file(opt.cfg) # check file
|
| 823 |
+
set_logging()
|
| 824 |
+
device = select_device(opt.device)
|
| 825 |
+
|
| 826 |
+
# Create model
|
| 827 |
+
model = Model(opt.cfg).to(device)
|
| 828 |
+
model.train()
|
| 829 |
+
|
| 830 |
+
if opt.profile:
|
| 831 |
+
img = torch.rand(1, 3, 640, 640).to(device)
|
| 832 |
+
y = model(img, profile=True)
|
| 833 |
+
|
| 834 |
+
# Profile
|
| 835 |
+
# img = torch.rand(8 if torch.cuda.is_available() else 1, 3, 640, 640).to(device)
|
| 836 |
+
# y = model(img, profile=True)
|
| 837 |
+
|
| 838 |
+
# Tensorboard
|
| 839 |
+
# from torch.utils.tensorboard import SummaryWriter
|
| 840 |
+
# tb_writer = SummaryWriter()
|
| 841 |
+
# print("Run 'tensorboard --logdir=models/runs' to view tensorboard at http://localhost:6006/")
|
| 842 |
+
# tb_writer.add_graph(model.model, img) # add model to tensorboard
|
| 843 |
+
# tb_writer.add_image('test', img[0], dataformats='CWH') # add model to tensorboard
|
detection/requirements.txt
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Usage: pip install -r requirements.txt
|
| 2 |
+
|
| 3 |
+
# Base ----------------------------------------
|
| 4 |
+
matplotlib>=3.2.2
|
| 5 |
+
numpy>=1.18.5
|
| 6 |
+
opencv-python>=4.1.1
|
| 7 |
+
Pillow>=7.1.2
|
| 8 |
+
PyYAML>=5.3.1
|
| 9 |
+
requests>=2.23.0
|
| 10 |
+
scipy>=1.4.1
|
| 11 |
+
torch>=1.7.0,!=1.12.0
|
| 12 |
+
torchvision>=0.8.1,!=0.13.0
|
| 13 |
+
tqdm>=4.41.0
|
| 14 |
+
protobuf<4.21.3
|
| 15 |
+
|
| 16 |
+
# Logging -------------------------------------
|
| 17 |
+
tensorboard>=2.4.1
|
| 18 |
+
# wandb
|
| 19 |
+
|
| 20 |
+
# Plotting ------------------------------------
|
| 21 |
+
pandas>=1.1.4
|
| 22 |
+
seaborn>=0.11.0
|
| 23 |
+
|
| 24 |
+
# Export --------------------------------------
|
| 25 |
+
# coremltools>=4.1 # CoreML export
|
| 26 |
+
# onnx>=1.9.0 # ONNX export
|
| 27 |
+
# onnx-simplifier>=0.3.6 # ONNX simplifier
|
| 28 |
+
# scikit-learn==0.19.2 # CoreML quantization
|
| 29 |
+
# tensorflow>=2.4.1 # TFLite export
|
| 30 |
+
# tensorflowjs>=3.9.0 # TF.js export
|
| 31 |
+
# openvino-dev # OpenVINO export
|
| 32 |
+
|
| 33 |
+
# Extras --------------------------------------
|
| 34 |
+
ipython # interactive notebook
|
| 35 |
+
psutil # system utilization
|
| 36 |
+
thop # FLOPs computation
|
| 37 |
+
# albumentations>=1.0.3
|
| 38 |
+
# pycocotools>=2.0 # COCO mAP
|
| 39 |
+
# roboflow
|
detection/scripts/get_coco.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# COCO 2017 dataset http://cocodataset.org
|
| 3 |
+
# Download command: bash ./scripts/get_coco.sh
|
| 4 |
+
|
| 5 |
+
# Download/unzip labels
|
| 6 |
+
d='./' # unzip directory
|
| 7 |
+
url=https://github.com/ultralytics/yolov5/releases/download/v1.0/
|
| 8 |
+
f='coco2017labels-segments.zip' # or 'coco2017labels.zip', 68 MB
|
| 9 |
+
echo 'Downloading' $url$f ' ...'
|
| 10 |
+
curl -L $url$f -o $f && unzip -q $f -d $d && rm $f & # download, unzip, remove in background
|
| 11 |
+
|
| 12 |
+
# Download/unzip images
|
| 13 |
+
d='./coco/images' # unzip directory
|
| 14 |
+
url=http://images.cocodataset.org/zips/
|
| 15 |
+
f1='train2017.zip' # 19G, 118k images
|
| 16 |
+
f2='val2017.zip' # 1G, 5k images
|
| 17 |
+
f3='test2017.zip' # 7G, 41k images (optional)
|
| 18 |
+
for f in $f1 $f2 $f3; do
|
| 19 |
+
echo 'Downloading' $url$f '...'
|
| 20 |
+
curl -L $url$f -o $f && unzip -q $f -d $d && rm $f & # download, unzip, remove in background
|
| 21 |
+
done
|
| 22 |
+
wait # finish background tasks
|
detection/test.py
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from threading import Thread
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
import torch
|
| 9 |
+
import yaml
|
| 10 |
+
from tqdm import tqdm
|
| 11 |
+
|
| 12 |
+
from models.experimental import attempt_load
|
| 13 |
+
from utils.datasets import create_dataloader
|
| 14 |
+
from utils.general import coco80_to_coco91_class, check_dataset, check_file, check_img_size, check_requirements, \
|
| 15 |
+
box_iou, non_max_suppression, scale_coords, xyxy2xywh, xywh2xyxy, set_logging, increment_path, colorstr
|
| 16 |
+
from utils.metrics import ap_per_class, ConfusionMatrix
|
| 17 |
+
from utils.plots import plot_images, output_to_target, plot_study_txt
|
| 18 |
+
from utils.torch_utils import select_device, time_synchronized, TracedModel
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def test(data,
|
| 22 |
+
weights=None,
|
| 23 |
+
batch_size=32,
|
| 24 |
+
imgsz=640,
|
| 25 |
+
conf_thres=0.001,
|
| 26 |
+
iou_thres=0.6, # for NMS
|
| 27 |
+
save_json=False,
|
| 28 |
+
single_cls=False,
|
| 29 |
+
augment=False,
|
| 30 |
+
verbose=False,
|
| 31 |
+
model=None,
|
| 32 |
+
dataloader=None,
|
| 33 |
+
save_dir=Path(''), # for saving images
|
| 34 |
+
save_txt=False, # for auto-labelling
|
| 35 |
+
save_hybrid=False, # for hybrid auto-labelling
|
| 36 |
+
save_conf=False, # save auto-label confidences
|
| 37 |
+
plots=True,
|
| 38 |
+
wandb_logger=None,
|
| 39 |
+
compute_loss=None,
|
| 40 |
+
half_precision=True,
|
| 41 |
+
trace=False,
|
| 42 |
+
is_coco=False):
|
| 43 |
+
# Initialize/load model and set device
|
| 44 |
+
training = model is not None
|
| 45 |
+
if training: # called by train.py
|
| 46 |
+
device = next(model.parameters()).device # get model device
|
| 47 |
+
|
| 48 |
+
else: # called directly
|
| 49 |
+
set_logging()
|
| 50 |
+
device = select_device(opt.device, batch_size=batch_size)
|
| 51 |
+
|
| 52 |
+
# Directories
|
| 53 |
+
save_dir = Path(increment_path(Path(opt.project) / opt.name, exist_ok=opt.exist_ok)) # increment run
|
| 54 |
+
(save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True) # make dir
|
| 55 |
+
|
| 56 |
+
# Load model
|
| 57 |
+
model = attempt_load(weights, map_location=device) # load FP32 model
|
| 58 |
+
gs = max(int(model.stride.max()), 32) # grid size (max stride)
|
| 59 |
+
imgsz = check_img_size(imgsz, s=gs) # check img_size
|
| 60 |
+
|
| 61 |
+
if trace:
|
| 62 |
+
model = TracedModel(model, device, opt.img_size)
|
| 63 |
+
|
| 64 |
+
# Half
|
| 65 |
+
half = device.type != 'cpu' and half_precision # half precision only supported on CUDA
|
| 66 |
+
if half:
|
| 67 |
+
model.half()
|
| 68 |
+
|
| 69 |
+
# Configure
|
| 70 |
+
model.eval()
|
| 71 |
+
if isinstance(data, str):
|
| 72 |
+
is_coco = data.endswith('coco.yaml')
|
| 73 |
+
with open(data) as f:
|
| 74 |
+
data = yaml.load(f, Loader=yaml.SafeLoader)
|
| 75 |
+
check_dataset(data) # check
|
| 76 |
+
nc = 1 if single_cls else int(data['nc']) # number of classes
|
| 77 |
+
iouv = torch.linspace(0.5, 0.95, 10).to(device) # iou vector for mAP@0.5:0.95
|
| 78 |
+
niou = iouv.numel()
|
| 79 |
+
|
| 80 |
+
# Logging
|
| 81 |
+
log_imgs = 0
|
| 82 |
+
if wandb_logger and wandb_logger.wandb:
|
| 83 |
+
log_imgs = min(wandb_logger.log_imgs, 100)
|
| 84 |
+
# Dataloader
|
| 85 |
+
if not training:
|
| 86 |
+
if device.type != 'cpu':
|
| 87 |
+
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
|
| 88 |
+
task = opt.task if opt.task in ('train', 'val', 'test') else 'val' # path to train/val/test images
|
| 89 |
+
dataloader = create_dataloader(data[task], imgsz, batch_size, gs, opt, pad=0.5, rect=True,
|
| 90 |
+
prefix=colorstr(f'{task}: '))[0]
|
| 91 |
+
|
| 92 |
+
seen = 0
|
| 93 |
+
confusion_matrix = ConfusionMatrix(nc=nc)
|
| 94 |
+
names = {k: v for k, v in enumerate(model.names if hasattr(model, 'names') else model.module.names)}
|
| 95 |
+
coco91class = coco80_to_coco91_class()
|
| 96 |
+
s = ('%20s' + '%12s' * 6) % ('Class', 'Images', 'Labels', 'P', 'R', 'mAP@.5', 'mAP@.5:.95')
|
| 97 |
+
p, r, f1, mp, mr, map50, map, t0, t1 = 0., 0., 0., 0., 0., 0., 0., 0., 0.
|
| 98 |
+
loss = torch.zeros(3, device=device)
|
| 99 |
+
jdict, stats, ap, ap_class, wandb_images = [], [], [], [], []
|
| 100 |
+
for batch_i, (img, targets, paths, shapes) in enumerate(tqdm(dataloader, desc=s)):
|
| 101 |
+
img = img.to(device, non_blocking=True)
|
| 102 |
+
img = img.half() if half else img.float() # uint8 to fp16/32
|
| 103 |
+
img /= 255.0 # 0 - 255 to 0.0 - 1.0
|
| 104 |
+
targets = targets.to(device)
|
| 105 |
+
nb, _, height, width = img.shape # batch size, channels, height, width
|
| 106 |
+
|
| 107 |
+
with torch.no_grad():
|
| 108 |
+
# Run model
|
| 109 |
+
t = time_synchronized()
|
| 110 |
+
out, train_out = model(img, augment=augment) # inference and training outputs
|
| 111 |
+
t0 += time_synchronized() - t
|
| 112 |
+
|
| 113 |
+
# Compute loss
|
| 114 |
+
if compute_loss:
|
| 115 |
+
loss += compute_loss([x.float() for x in train_out], targets)[1][:3] # box, obj, cls
|
| 116 |
+
|
| 117 |
+
# Run NMS
|
| 118 |
+
targets[:, 2:] *= torch.Tensor([width, height, width, height]).to(device) # to pixels
|
| 119 |
+
lb = [targets[targets[:, 0] == i, 1:] for i in range(nb)] if save_hybrid else [] # for autolabelling
|
| 120 |
+
t = time_synchronized()
|
| 121 |
+
out = non_max_suppression(out, conf_thres=conf_thres, iou_thres=iou_thres, labels=lb, multi_label=True)
|
| 122 |
+
t1 += time_synchronized() - t
|
| 123 |
+
|
| 124 |
+
# Statistics per image
|
| 125 |
+
for si, pred in enumerate(out):
|
| 126 |
+
labels = targets[targets[:, 0] == si, 1:]
|
| 127 |
+
nl = len(labels)
|
| 128 |
+
tcls = labels[:, 0].tolist() if nl else [] # target class
|
| 129 |
+
path = Path(paths[si])
|
| 130 |
+
seen += 1
|
| 131 |
+
|
| 132 |
+
if len(pred) == 0:
|
| 133 |
+
if nl:
|
| 134 |
+
stats.append((torch.zeros(0, niou, dtype=torch.bool), torch.Tensor(), torch.Tensor(), tcls))
|
| 135 |
+
continue
|
| 136 |
+
|
| 137 |
+
# Predictions
|
| 138 |
+
predn = pred.clone()
|
| 139 |
+
scale_coords(img[si].shape[1:], predn[:, :4], shapes[si][0], shapes[si][1]) # native-space pred
|
| 140 |
+
|
| 141 |
+
# Append to text file
|
| 142 |
+
if save_txt:
|
| 143 |
+
gn = torch.tensor(shapes[si][0])[[1, 0, 1, 0]] # normalization gain whwh
|
| 144 |
+
for *xyxy, conf, cls in predn.tolist():
|
| 145 |
+
xywh = (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywh
|
| 146 |
+
line = (cls, *xywh, conf) if save_conf else (cls, *xywh) # label format
|
| 147 |
+
with open(save_dir / 'labels' / (path.stem + '.txt'), 'a') as f:
|
| 148 |
+
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
| 149 |
+
|
| 150 |
+
# W&B logging - Media Panel Plots
|
| 151 |
+
if len(wandb_images) < log_imgs and wandb_logger.current_epoch > 0: # Check for test operation
|
| 152 |
+
if wandb_logger.current_epoch % wandb_logger.bbox_interval == 0:
|
| 153 |
+
box_data = [{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]},
|
| 154 |
+
"class_id": int(cls),
|
| 155 |
+
"box_caption": "%s %.3f" % (names[cls], conf),
|
| 156 |
+
"scores": {"class_score": conf},
|
| 157 |
+
"domain": "pixel"} for *xyxy, conf, cls in pred.tolist()]
|
| 158 |
+
boxes = {"predictions": {"box_data": box_data, "class_labels": names}} # inference-space
|
| 159 |
+
wandb_images.append(wandb_logger.wandb.Image(img[si], boxes=boxes, caption=path.name))
|
| 160 |
+
wandb_logger.log_training_progress(predn, path, names) if wandb_logger and wandb_logger.wandb_run else None
|
| 161 |
+
|
| 162 |
+
# Append to pycocotools JSON dictionary
|
| 163 |
+
if save_json:
|
| 164 |
+
# [{"image_id": 42, "category_id": 18, "bbox": [258.15, 41.29, 348.26, 243.78], "score": 0.236}, ...
|
| 165 |
+
image_id = int(path.stem) if path.stem.isnumeric() else path.stem
|
| 166 |
+
box = xyxy2xywh(predn[:, :4]) # xywh
|
| 167 |
+
box[:, :2] -= box[:, 2:] / 2 # xy center to top-left corner
|
| 168 |
+
for p, b in zip(pred.tolist(), box.tolist()):
|
| 169 |
+
jdict.append({'image_id': image_id,
|
| 170 |
+
'category_id': coco91class[int(p[5])] if is_coco else int(p[5]),
|
| 171 |
+
'bbox': [round(x, 3) for x in b],
|
| 172 |
+
'score': round(p[4], 5)})
|
| 173 |
+
|
| 174 |
+
# Assign all predictions as incorrect
|
| 175 |
+
correct = torch.zeros(pred.shape[0], niou, dtype=torch.bool, device=device)
|
| 176 |
+
if nl:
|
| 177 |
+
detected = [] # target indices
|
| 178 |
+
tcls_tensor = labels[:, 0]
|
| 179 |
+
|
| 180 |
+
# target boxes
|
| 181 |
+
tbox = xywh2xyxy(labels[:, 1:5])
|
| 182 |
+
scale_coords(img[si].shape[1:], tbox, shapes[si][0], shapes[si][1]) # native-space labels
|
| 183 |
+
if plots:
|
| 184 |
+
confusion_matrix.process_batch(predn, torch.cat((labels[:, 0:1], tbox), 1))
|
| 185 |
+
|
| 186 |
+
# Per target class
|
| 187 |
+
for cls in torch.unique(tcls_tensor):
|
| 188 |
+
ti = (cls == tcls_tensor).nonzero(as_tuple=False).view(-1) # prediction indices
|
| 189 |
+
pi = (cls == pred[:, 5]).nonzero(as_tuple=False).view(-1) # target indices
|
| 190 |
+
|
| 191 |
+
# Search for detections
|
| 192 |
+
if pi.shape[0]:
|
| 193 |
+
# Prediction to target ious
|
| 194 |
+
ious, i = box_iou(predn[pi, :4], tbox[ti]).max(1) # best ious, indices
|
| 195 |
+
|
| 196 |
+
# Append detections
|
| 197 |
+
detected_set = set()
|
| 198 |
+
for j in (ious > iouv[0]).nonzero(as_tuple=False):
|
| 199 |
+
d = ti[i[j]] # detected target
|
| 200 |
+
if d.item() not in detected_set:
|
| 201 |
+
detected_set.add(d.item())
|
| 202 |
+
detected.append(d)
|
| 203 |
+
correct[pi[j]] = ious[j] > iouv # iou_thres is 1xn
|
| 204 |
+
if len(detected) == nl: # all targets already located in image
|
| 205 |
+
break
|
| 206 |
+
|
| 207 |
+
# Append statistics (correct, conf, pcls, tcls)
|
| 208 |
+
stats.append((correct.cpu(), pred[:, 4].cpu(), pred[:, 5].cpu(), tcls))
|
| 209 |
+
|
| 210 |
+
# Plot images
|
| 211 |
+
if plots and batch_i < 3:
|
| 212 |
+
f = save_dir / f'test_batch{batch_i}_labels.jpg' # labels
|
| 213 |
+
Thread(target=plot_images, args=(img, targets, paths, f, names), daemon=True).start()
|
| 214 |
+
f = save_dir / f'test_batch{batch_i}_pred.jpg' # predictions
|
| 215 |
+
Thread(target=plot_images, args=(img, output_to_target(out), paths, f, names), daemon=True).start()
|
| 216 |
+
|
| 217 |
+
# Compute statistics
|
| 218 |
+
stats = [np.concatenate(x, 0) for x in zip(*stats)] # to numpy
|
| 219 |
+
if len(stats) and stats[0].any():
|
| 220 |
+
p, r, ap, f1, ap_class = ap_per_class(*stats, plot=plots, save_dir=save_dir, names=names)
|
| 221 |
+
ap50, ap = ap[:, 0], ap.mean(1) # AP@0.5, AP@0.5:0.95
|
| 222 |
+
mp, mr, map50, map = p.mean(), r.mean(), ap50.mean(), ap.mean()
|
| 223 |
+
nt = np.bincount(stats[3].astype(np.int64), minlength=nc) # number of targets per class
|
| 224 |
+
else:
|
| 225 |
+
nt = torch.zeros(1)
|
| 226 |
+
|
| 227 |
+
# Print results
|
| 228 |
+
pf = '%20s' + '%12i' * 2 + '%12.3g' * 4 # print format
|
| 229 |
+
print(pf % ('all', seen, nt.sum(), mp, mr, map50, map))
|
| 230 |
+
|
| 231 |
+
# Print results per class
|
| 232 |
+
if (verbose or (nc < 50 and not training)) and nc > 1 and len(stats):
|
| 233 |
+
for i, c in enumerate(ap_class):
|
| 234 |
+
print(pf % (names[c], seen, nt[c], p[i], r[i], ap50[i], ap[i]))
|
| 235 |
+
|
| 236 |
+
# Print speeds
|
| 237 |
+
t = tuple(x / seen * 1E3 for x in (t0, t1, t0 + t1)) + (imgsz, imgsz, batch_size) # tuple
|
| 238 |
+
if not training:
|
| 239 |
+
print('Speed: %.1f/%.1f/%.1f ms inference/NMS/total per %gx%g image at batch-size %g' % t)
|
| 240 |
+
|
| 241 |
+
# Plots
|
| 242 |
+
if plots:
|
| 243 |
+
confusion_matrix.plot(save_dir=save_dir, names=list(names.values()))
|
| 244 |
+
if wandb_logger and wandb_logger.wandb:
|
| 245 |
+
val_batches = [wandb_logger.wandb.Image(str(f), caption=f.name) for f in sorted(save_dir.glob('test*.jpg'))]
|
| 246 |
+
wandb_logger.log({"Validation": val_batches})
|
| 247 |
+
if wandb_images:
|
| 248 |
+
wandb_logger.log({"Bounding Box Debugger/Images": wandb_images})
|
| 249 |
+
|
| 250 |
+
# Save JSON
|
| 251 |
+
if save_json and len(jdict):
|
| 252 |
+
w = Path(weights[0] if isinstance(weights, list) else weights).stem if weights is not None else '' # weights
|
| 253 |
+
anno_json = './coco/annotations/instances_val2017.json' # annotations json
|
| 254 |
+
pred_json = str(save_dir / f"{w}_predictions.json") # predictions json
|
| 255 |
+
print('\nEvaluating pycocotools mAP... saving %s...' % pred_json)
|
| 256 |
+
with open(pred_json, 'w') as f:
|
| 257 |
+
json.dump(jdict, f)
|
| 258 |
+
|
| 259 |
+
try: # https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
|
| 260 |
+
from pycocotools.coco import COCO
|
| 261 |
+
from pycocotools.cocoeval import COCOeval
|
| 262 |
+
|
| 263 |
+
anno = COCO(anno_json) # init annotations api
|
| 264 |
+
pred = anno.loadRes(pred_json) # init predictions api
|
| 265 |
+
eval = COCOeval(anno, pred, 'bbox')
|
| 266 |
+
if is_coco:
|
| 267 |
+
eval.params.imgIds = [int(Path(x).stem) for x in dataloader.dataset.img_files] # image IDs to evaluate
|
| 268 |
+
eval.evaluate()
|
| 269 |
+
eval.accumulate()
|
| 270 |
+
eval.summarize()
|
| 271 |
+
map, map50 = eval.stats[:2] # update results (mAP@0.5:0.95, mAP@0.5)
|
| 272 |
+
except Exception as e:
|
| 273 |
+
print(f'pycocotools unable to run: {e}')
|
| 274 |
+
|
| 275 |
+
# Return results
|
| 276 |
+
model.float() # for training
|
| 277 |
+
if not training:
|
| 278 |
+
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
|
| 279 |
+
print(f"Results saved to {save_dir}{s}")
|
| 280 |
+
maps = np.zeros(nc) + map
|
| 281 |
+
for i, c in enumerate(ap_class):
|
| 282 |
+
maps[c] = ap[i]
|
| 283 |
+
return (mp, mr, map50, map, *(loss.cpu() / len(dataloader)).tolist()), maps, t
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
if __name__ == '__main__':
|
| 287 |
+
parser = argparse.ArgumentParser(prog='test.py')
|
| 288 |
+
parser.add_argument('--weights', nargs='+', type=str, default='yolov7.pt', help='model.pt path(s)')
|
| 289 |
+
parser.add_argument('--data', type=str, default='data/coco.yaml', help='*.data path')
|
| 290 |
+
parser.add_argument('--batch-size', type=int, default=32, help='size of each image batch')
|
| 291 |
+
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
|
| 292 |
+
parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold')
|
| 293 |
+
parser.add_argument('--iou-thres', type=float, default=0.65, help='IOU threshold for NMS')
|
| 294 |
+
parser.add_argument('--task', default='val', help='train, val, test, speed or study')
|
| 295 |
+
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
| 296 |
+
parser.add_argument('--single-cls', action='store_true', help='treat as single-class dataset')
|
| 297 |
+
parser.add_argument('--augment', action='store_true', help='augmented inference')
|
| 298 |
+
parser.add_argument('--verbose', action='store_true', help='report mAP by class')
|
| 299 |
+
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
|
| 300 |
+
parser.add_argument('--save-hybrid', action='store_true', help='save label+prediction hybrid results to *.txt')
|
| 301 |
+
parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
|
| 302 |
+
parser.add_argument('--save-json', action='store_true', help='save a cocoapi-compatible JSON results file')
|
| 303 |
+
parser.add_argument('--project', default='runs/test', help='save to project/name')
|
| 304 |
+
parser.add_argument('--name', default='exp', help='save to project/name')
|
| 305 |
+
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
|
| 306 |
+
parser.add_argument('--no-trace', action='store_true', help='don`t trace model')
|
| 307 |
+
opt = parser.parse_args()
|
| 308 |
+
opt.save_json |= opt.data.endswith('coco.yaml')
|
| 309 |
+
opt.data = check_file(opt.data) # check file
|
| 310 |
+
print(opt)
|
| 311 |
+
#check_requirements()
|
| 312 |
+
|
| 313 |
+
if opt.task in ('train', 'val', 'test'): # run normally
|
| 314 |
+
test(opt.data,
|
| 315 |
+
opt.weights,
|
| 316 |
+
opt.batch_size,
|
| 317 |
+
opt.img_size,
|
| 318 |
+
opt.conf_thres,
|
| 319 |
+
opt.iou_thres,
|
| 320 |
+
opt.save_json,
|
| 321 |
+
opt.single_cls,
|
| 322 |
+
opt.augment,
|
| 323 |
+
opt.verbose,
|
| 324 |
+
save_txt=opt.save_txt | opt.save_hybrid,
|
| 325 |
+
save_hybrid=opt.save_hybrid,
|
| 326 |
+
save_conf=opt.save_conf,
|
| 327 |
+
trace=not opt.no_trace,
|
| 328 |
+
)
|
| 329 |
+
|
| 330 |
+
elif opt.task == 'speed': # speed benchmarks
|
| 331 |
+
for w in opt.weights:
|
| 332 |
+
test(opt.data, w, opt.batch_size, opt.img_size, 0.25, 0.45, save_json=False, plots=False)
|
| 333 |
+
|
| 334 |
+
elif opt.task == 'study': # run over a range of settings and save/plot
|
| 335 |
+
# python test.py --task study --data coco.yaml --iou 0.65 --weights yolov7.pt
|
| 336 |
+
x = list(range(256, 1536 + 128, 128)) # x axis (image sizes)
|
| 337 |
+
for w in opt.weights:
|
| 338 |
+
f = f'study_{Path(opt.data).stem}_{Path(w).stem}.txt' # filename to save to
|
| 339 |
+
y = [] # y axis
|
| 340 |
+
for i in x: # img-size
|
| 341 |
+
print(f'\nRunning {f} point {i}...')
|
| 342 |
+
r, _, t = test(opt.data, w, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json,
|
| 343 |
+
plots=False)
|
| 344 |
+
y.append(r + t) # results and times
|
| 345 |
+
np.savetxt(f, y, fmt='%10.4g') # save
|
| 346 |
+
os.system('zip -r study.zip study_*.txt')
|
| 347 |
+
plot_study_txt(x=x) # plot
|