Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
PET_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김성주
2020-05-17 02:44:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
033f47434772f686f88777fb406c6834848ba834
033f4743
1 parent
71958c29
fixed errors for evaluation
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletions
code/yolov3/eval.py
code/yolov3/train.py
code/yolov3/yolov3.ipynb
code/yolov3/eval.py
View file @
033f474
...
...
@@ -60,7 +60,7 @@ args = parser.parse_args()
args
.
anchors
=
parse_anchors
(
args
.
anchor_path
)
args
.
classes
=
read_class_names
(
args
.
class_name_path
)
args
.
class_num
=
len
(
args
.
classes
)
args
.
img_cnt
=
len
(
open
(
args
.
eval_file
,
'r'
)
.
readlines
()
)
args
.
img_cnt
=
TFRecordIterator
(
args
.
eval_file
,
'GZIP'
)
.
count
(
)
# setting placeholders
is_training
=
tf
.
placeholder
(
dtype
=
tf
.
bool
,
name
=
"phase_train"
)
...
...
code/yolov3/train.py
View file @
033f474
...
...
@@ -184,3 +184,47 @@ with tf.Session() as sess:
best_mAP
=
mAP
saver_best
.
save
(
sess
,
args
.
save_dir
+
'best_model_Epoch_{}_step_{}_mAP_{:.4f}_loss_{:.4f}_lr_{:.7g}'
.
format
(
epoch
,
int
(
__global_step
),
best_mAP
,
val_loss_total
.
average
,
__lr
))
saver_to_restore
.
save
(
sess
,
restore_path
)
## all epoches end
sess
.
run
(
val_init_op
)
val_loss_total
,
val_loss_xy
,
val_loss_wh
,
val_loss_conf
,
val_loss_class
=
AverageMeter
(),
AverageMeter
(),
AverageMeter
(),
AverageMeter
(),
AverageMeter
()
val_preds
=
[]
for
j
in
trange
(
val_img_cnt
):
__image_ids
,
__y_pred
,
__loss
=
sess
.
run
([
image_ids
,
y_pred
,
loss
],
feed_dict
=
{
is_training
:
False
})
pred_content
=
get_preds_gpu
(
sess
,
gpu_nms_op
,
pred_boxes_flag
,
pred_scores_flag
,
__image_ids
,
__y_pred
)
val_preds
.
extend
(
pred_content
)
val_loss_total
.
update
(
__loss
[
0
])
val_loss_xy
.
update
(
__loss
[
1
])
val_loss_wh
.
update
(
__loss
[
2
])
val_loss_conf
.
update
(
__loss
[
3
])
val_loss_class
.
update
(
__loss
[
4
])
# calc mAP
rec_total
,
prec_total
,
ap_total
=
AverageMeter
(),
AverageMeter
(),
AverageMeter
()
gt_dict
=
parse_gt_rec
(
val_file
,
'GZIP'
,
img_size
,
letterbox_resize
)
info
=
'======> Epoch: {}, global_step: {}, lr: {:.6g} <======
\n
'
.
format
(
epoch
,
__global_step
,
__lr
)
for
ii
in
range
(
class_num
):
npos
,
nd
,
rec
,
prec
,
ap
=
voc_eval
(
gt_dict
,
val_preds
,
ii
,
iou_thres
=
eval_threshold
,
use_07_metric
=
use_voc_07_metric
)
info
+=
'EVAL: Class {}: Recall: {:.4f}, Precision: {:.4f}, AP: {:.4f}
\n
'
.
format
(
ii
,
rec
,
prec
,
ap
)
rec_total
.
update
(
rec
,
npos
)
prec_total
.
update
(
prec
,
nd
)
ap_total
.
update
(
ap
,
1
)
mAP
=
ap_total
.
average
info
+=
'EVAL: Recall: {:.4f}, Precison: {:.4f}, mAP: {:.4f}
\n
'
.
format
(
rec_total
.
average
,
prec_total
.
average
,
mAP
)
info
+=
'EVAL: loss: total: {:.2f}, xy: {:.2f}, wh: {:.2f}, conf: {:.2f}, class: {:.2f}
\n
'
.
format
(
val_loss_total
.
average
,
val_loss_xy
.
average
,
val_loss_wh
.
average
,
val_loss_conf
.
average
,
val_loss_class
.
average
)
print
(
info
)
if
save_optimizer
and
mAP
>
best_mAP
:
best_mAP
=
mAP
saver_best
.
save
(
sess
,
save_dir
+
'best_model_Epoch_{}_step_{}_mAP_{:.4f}_loss_{:.4f}_lr_{:.7g}'
.
format
(
epoch
,
int
(
__global_step
),
best_mAP
,
val_loss_total
.
average
,
__lr
))
saver_to_restore
.
save
(
sess
,
restore_path
)
\ No newline at end of file
...
...
code/yolov3/yolov3.ipynb
View file @
033f474
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment