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-06-14 05:00:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d70b373dc57889b45d6663cd51e1d75d701967f7
d70b373d
1 parent
9d044057
Revert to difference code
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
src/inference_pb.py
src/video_recommender.py
src/inference_pb.py
View file @
d70b373
...
...
@@ -10,17 +10,15 @@ import src.video_util as videoutil
import
json
import
urllib3
# Erase logs
logging
.
disable
(
logging
.
WARNING
)
os
.
environ
[
"TF_CPP_MIN_LOG_LEVEL"
]
=
"3"
urllib3
.
disable_warnings
(
urllib3
.
exceptions
.
InsecureRequestWarning
)
# Define model paths.
MODEL_PATH
=
"./new_model/inference_model/segment_inference_model"
# TAG_VECTOR_MODEL_PATH = "./new_model/twitter100_tag_vectors.gz"
TAG_VECTOR_MODEL_PATH
=
"glove-wiki-gigaword-100"
VIDEO_VECTOR_MODEL_PATH
=
"./new_model/gigaword100_video_vectors.model"
VIDEO_TAGS_PATH
=
"./statics/new_kaggle_solution_40k.csv"
# Old model
MODEL_PATH
=
"./model/inference_model/segment_inference_model"
TAG_VECTOR_MODEL_PATH
=
"./model/tag_vectors.model"
VIDEO_VECTOR_MODEL_PATH
=
"./model/video_vectors.model"
VIDEO_TAGS_PATH
=
"./statics/kaggle_solution_40k.csv"
# Define static file paths.
SEGMENT_LABEL_PATH
=
"./statics/segment_label_ids.csv"
...
...
@@ -28,11 +26,10 @@ VOCAB_PATH = "./statics/vocabulary.csv"
# Define parameters.
TAG_TOP_K
=
5
VIDEO_TOP_K
=
5
VIDEO_TOP_K
=
10
# Target featuremap.
FEATUREMAP_PATH
=
"./featuremaps/toy-3-features.pb"
FEATUREMAP_PATH
=
"./featuremaps/concert-1-features.pb"
def
get_segments
(
batch_video_mtx
,
batch_num_frames
,
segment_size
):
"""Get segment-level inputs from frame-level features."""
...
...
@@ -235,5 +232,17 @@ def inference_pb(file_path, threshold):
if
__name__
==
'__main__'
:
result
=
inference_pb
(
FEATUREMAP_PATH
,
VIDEO_TOP_K
)
print
(
json
.
dumps
(
result
,
sort_keys
=
True
,
indent
=
2
))
result
=
inference_pb
(
FEATUREMAP_PATH
,
5
)
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
(
FEATUREMAP_PATH
,
5
)
print
(
"=============== New Model ==============="
)
print
(
result
[
"tag_result"
])
print
(
json
.
dumps
(
result
[
"video_result"
],
sort_keys
=
True
,
indent
=
2
))
...
...
src/video_recommender.py
View file @
d70b373
...
...
@@ -4,9 +4,9 @@ import numpy as np
def
recommend_videos
(
tags
,
tag_model_path
,
video_model_path
,
top_k
):
#
tag_vectors = Word2Vec.load(tag_model_path).wv
tag_vectors
=
Word2Vec
.
load
(
tag_model_path
)
.
wv
# tag_vectors = KeyedVectors.load_word2vec_format(tag_model_path, binary=True)
tag_vectors
=
api
.
load
(
tag_model_path
)
#
tag_vectors = api.load(tag_model_path)
video_vectors
=
Word2Vec
()
.
wv
.
load
(
video_model_path
)
error_tags
=
[]
...
...
Please
register
or
login
to post a comment