Yoonjunhyeon

model과 백엔드 연결

......@@ -17,6 +17,9 @@ import subprocess
import shlex
import json
# Create your views here.
import sys
sys.path.insert(0, "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/esot3ria")
import inference_pb
def with_ffprobe(filename):
......@@ -75,11 +78,14 @@ class VideoFileUploadView(APIView):
# 동영상 길이 출력
runTime = with_ffprobe('/'+file_serializer.data['file_save_name'])
print(runTime)
print(threshold)
process = subprocess.Popen(['./runMediaPipe.sh %s %s' %(file_serializer.data['file_save_name'],runTime,)], shell = True)
process.wait()
return Response(True, status=status.HTTP_201_CREATED)
result = inference_pb.inference_pb('/tmp/mediapipe/features.pb', threshold)
return Response(result, status=status.HTTP_201_CREATED)
else:
return Response(file_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
......
......@@ -3,16 +3,17 @@ import tensorflow as tf
from tensorflow import logging
from tensorflow import gfile
import operator
import esot3ria.pb_util as pbutil
import esot3ria.video_recommender as recommender
import esot3ria.video_util as videoutil
import pb_util as pbutil
import video_recommender as recommender
import video_util as videoutil
# Define file paths.
MODEL_PATH = "/Users/esot3ria/PycharmProjects/yt8m/models/frame/refined_model/inference_model/segment_inference_model"
VOCAB_PATH = "../vocabulary.csv"
VIDEO_TAGS_PATH = "./kaggle_solution_40k.csv"
TAG_VECTOR_MODEL_PATH = "./tag_vectors.model"
VIDEO_VECTOR_MODEL_PATH = "./video_vectors.model"
MODEL_PATH = "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/esot3ria/model/inference_model/segment_inference_model"
VOCAB_PATH = "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/vocabulary.csv"
VIDEO_TAGS_PATH = "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/esot3ria/kaggle_solution_40k.csv"
TAG_VECTOR_MODEL_PATH = "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/esot3ria/tag_vectors.model"
VIDEO_VECTOR_MODEL_PATH = "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/esot3ria/video_vectors.model"
SEGMENT_LABEL_PATH = "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/segment_label_ids.csv"
# Define parameters.
TAG_TOP_K = 5
......@@ -83,7 +84,8 @@ def normalize_tag(tag):
return tag
def inference_pb(file_path):
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:
......@@ -135,8 +137,7 @@ def inference_pb(file_path):
whitelisted_cls_mask = np.zeros((predictions_tensor.get_shape()[-1],),
dtype=np.float32)
segment_label_ids_file = '../segment_label_ids.csv'
with tf.io.gfile.GFile(segment_label_ids_file) as fobj:
with tf.io.gfile.GFile(SEGMENT_LABEL_PATH) as fobj:
for line in fobj:
try:
cls_id = int(line)
......@@ -217,6 +218,6 @@ def inference_pb(file_path):
if __name__ == '__main__':
filepath = "../featuremaps/features(yorusika).pb"
filepath = "/tmp/mediapipe/features.pb"
result = inference_pb(filepath)
print(result)
......
model_checkpoint_path: "/root/volume/youtube-8m/saved_model/inference_model/segment_inference_model"
all_model_checkpoint_paths: "/root/volume/youtube-8m/saved_model/inference_model/segment_inference_model"
{"model": "FrameLevelLogisticModel", "feature_sizes": "1024,128", "feature_names": "rgb,audio", "frame_features": true, "label_loss": "CrossEntropyLoss"}
\ No newline at end of file