Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DL Object Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Bjørn Hyldgaard
DL Object Detection
Commits
d974a9be
Commit
d974a9be
authored
2 years ago
by
Jakob
Browse files
Options
Downloads
Patches
Plain Diff
added sigmoid to last layer
parent
a6656f63
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
MobileNetV1.py
+11
-2
11 additions, 2 deletions
MobileNetV1.py
Yolo_v1_fcs.py
+30
-0
30 additions, 0 deletions
Yolo_v1_fcs.py
with
41 additions
and
2 deletions
MobileNetV1.py
+
11
−
2
View file @
d974a9be
import
torch
from
functools
import
reduce
import
torch.nn
as
nn
import
torch.nn.functional
as
F
...
...
@@ -11,6 +12,8 @@ import numpy as np
from
coco_utils
import
get_image
from
Yolo_v1_fcs
import
Yolo_v1_fcs
model
=
torch
.
hub
.
load
(
'
pytorch/vision:v0.10.0
'
,
'
mobilenet_v2
'
,
pretrained
=
True
)
#Enable following to only get CNN part:
...
...
@@ -44,5 +47,11 @@ if __name__=="__main__":
input_image
=
get_image
(
"
http://images.cocodataset.org/val2017/000000148783.jpg
"
)
output
=
runCNN
(
input_image
)
print
(
output
.
shape
)
#Shape of output:
#torch.Size([1, 1280, 7, 7])
\ No newline at end of file
size
=
reduce
(
lambda
x
,
y
:
x
*
y
,
output
.
shape
)
model
=
Yolo_v1_fcs
(
size
)
output
=
model
(
output
)
print
(
output
.
shape
);
#torch.Size([1, 1280, 7, 7])
This diff is collapsed.
Click to expand it.
Yolo_v1_fcs.py
0 → 100644
+
30
−
0
View file @
d974a9be
import
torch
from
torch
import
nn
import
numpy
as
np
class
Yolo_v1_fcs
(
nn
.
Module
):
def
__init__
(
self
,
input_size
):
super
(
Yolo_v1_fcs
,
self
).
__init__
()
layers
=
[]
layers
.
append
(
nn
.
Flatten
())
layers
.
append
(
nn
.
Linear
(
input_size
,
496
))
layers
.
append
(
nn
.
Dropout
(
0
,
0
))
layers
.
append
(
nn
.
LeakyReLU
(
0.1
))
layers
.
append
(
nn
.
Linear
(
496
,
7
*
7
*
10
))
self
.
fcs
=
nn
.
Sequential
(
*
layers
)
def
forward
(
self
,
x
):
# Run through decoder
output
=
self
.
fcs
(
x
)
# Run sigmoid on p, x, y for ever bb
output
=
torch
.
reshape
(
output
,
(
-
1
,
5
))
output
[:,
:
3
]
=
torch
.
sigmoid
(
output
[:,
:
3
])
return
output
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment