이현규

Remove warning messages

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))
......