이현규

Revert to difference code

......@@ -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))
......
......@@ -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 = []
......