Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2015104209
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
이현규
2021-05-29 18:51:20 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e8be6ace4794b364ccddf8bb92428027897f4019
e8be6ace
1 parent
a0030f38
Remove warning messages
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
src/inference_pb.py
src/inference_pb.py
View file @
e8be6ac
import
logging
import
os
import
numpy
as
np
import
tensorflow
as
tf
from
tensorflow
import
logging
from
tensorflow
import
gfile
import
operator
import
src.pb_util
as
pbutil
import
src.video_recommender
as
recommender
import
src.video_util
as
videoutil
import
json
import
urllib3
logging
.
disable
(
logging
.
WARNING
)
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
"3"
urllib3
.
disable_warnings
(
urllib3
.
exceptions
.
InsecureRequestWarning
)
# Old model
MODEL_PATH
=
"./model/inference_model/segment_inference_model"
...
...
@@ -13,12 +20,6 @@ TAG_VECTOR_MODEL_PATH = "./model/tag_vectors.model"
VIDEO_VECTOR_MODEL_PATH
=
"./model/video_vectors.model"
VIDEO_TAGS_PATH
=
"./statics/kaggle_solution_40k.csv"
# New model
# MODEL_PATH = "./new_model/inference_model/segment_inference_model"
# TAG_VECTOR_MODEL_PATH = "./new_model/tag_vectors.model"
# VIDEO_VECTOR_MODEL_PATH = "./new_model/video_vectors.model"
# VIDEO_TAGS_PATH = "./statics/new_kaggle_solution_40k.csv"
# Define static file paths.
SEGMENT_LABEL_PATH
=
"./statics/segment_label_ids.csv"
VOCAB_PATH
=
"./statics/vocabulary.csv"
...
...
@@ -27,7 +28,6 @@ VOCAB_PATH = "./statics/vocabulary.csv"
TAG_TOP_K
=
5
VIDEO_TOP_K
=
10
def
get_segments
(
batch_video_mtx
,
batch_num_frames
,
segment_size
):
"""Get segment-level inputs from frame-level features."""
video_batch_size
=
batch_video_mtx
.
shape
[
0
]
...
...
@@ -95,7 +95,9 @@ def normalize_tag(tag):
def
inference_pb
(
file_path
,
threshold
):
VIDEO_TOP_K
=
int
(
threshold
)
inference_result
=
{}
with
tf
.
Session
(
config
=
tf
.
ConfigProto
(
allow_soft_placement
=
True
))
as
sess
:
graph
=
tf
.
Graph
()
with
tf
.
Session
(
graph
=
graph
,
config
=
tf
.
ConfigProto
(
allow_soft_placement
=
True
))
as
sess
:
# 0. Import SequenceExample type target from pb.
target_video
=
pbutil
.
convert_pb
(
file_path
)
...
...
@@ -222,10 +224,22 @@ def inference_pb(file_path, threshold):
# 6. Dispose instances.
sess
.
close
()
tf
.
reset_default_graph
()
return
inference_result
if
__name__
==
'__main__'
:
filepath
=
"./featuremaps/features.pb"
result
=
inference_pb
(
filepath
,
5
)
print
(
result
)
print
(
"=============== Old Model ==============="
)
print
(
result
[
"tag_result"
])
print
(
json
.
dumps
(
result
[
"video_result"
],
sort_keys
=
True
,
indent
=
2
))
# New model
MODEL_PATH
=
"./new_model/inference_model/segment_inference_model"
TAG_VECTOR_MODEL_PATH
=
"./new_model/tag_vectors.model"
VIDEO_VECTOR_MODEL_PATH
=
"./new_model/video_vectors.model"
VIDEO_TAGS_PATH
=
"./statics/new_kaggle_solution_40k.csv"
result
=
inference_pb
(
filepath
,
5
)
print
(
"=============== New Model ==============="
)
print
(
json
.
dumps
(
result
,
sort_keys
=
True
,
indent
=
2
))
...
...
Please
register
or
login
to post a comment