윤영빈

run the inference

......@@ -18,7 +18,7 @@ import shlex
import json
# Create your views here.
import sys
sys.path.insert(0, "/home/jun/documents/univ/PKH_Project1/web/backend/yt8m/esot3ria")
sys.path.insert(0, "/khuhub/2015104192/web/backend/yt8m/esot3ria")
import inference_pb
def with_ffprobe(filename):
......@@ -76,14 +76,17 @@ class VideoFileUploadView(APIView):
if file_serializer.is_valid():
file_serializer.save()
# 동영상 길이 출력
runTime = with_ffprobe('/'+file_serializer.data['file_save_name'])
print(runTime)
fileFullName = file_serializer.data['file_save_name']
fileProcessedName = fileFullName.replace("%3A",":")
runTime = with_ffprobe(fileProcessedName)
print('RUNTIME ::::==== ' + str(runTime))
print(threshold)
process = subprocess.Popen(['./runMediaPipe.sh %s %s' %(file_serializer.data['file_save_name'],runTime,)], shell = True)
print('CURR DIR = ' + os.getcwd())
process = subprocess.Popen(['./runMediaPipe.sh %s %s' %(fileProcessedName,runTime,)], shell = True)
process.wait()
result = inference_pb.inference_pb('/tmp/mediapipe/features.pb', threshold)
result = inference_pb.inference_pb('E:/khuhub/2015104192/web/backend/yt8m/featuremaps/features(baby_samoyed).pb', threshold)
return Response(result, status=status.HTTP_201_CREATED)
else:
......
This diff could not be displayed because it is too large.
Django==3.0.5
django-cors-headers==3.2.1
djangorestframework==3.11.0
tensorflow==1.15
tensorflow==1.14
pandas==1.0.4
gensim==3.8.3
\ No newline at end of file
......
#!/bin/bash
cd ../../../mediapipe
cd ../../../../mediapipe
. venv/bin/activate
echo "STEP1"
bazel version && \
alias bazel='bazel'
/usr/local/bazel/2.0.0/lib/bazel/bin/bazel version && \
alias bazel='/usr/local/bazel/2.0.0/lib/bazel/bin/bazel'
echo "STEP2"
python -m mediapipe.examples.desktop.youtube8m.generate_input_sequence_example \
--path_to_input_video=/$1 \
--clip_end_time_sec=$2
GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/youtube8m/extract_yt8m_features \
echo "STEP3"
GLOG_logtostderr=1 /mediapipe/examples/desktop/youtube8m/extract_yt8m_features \
--calculator_graph_config_file=mediapipe/graphs/youtube8m/feature_extraction.pbtxt \
--input_side_packets=input_sequence_example=/tmp/mediapipe/metadata.pb \
--output_side_packets=output_sequence_example=/tmp/mediapipe/features.pb
\ No newline at end of file
--output_side_packets=output_sequence_example=/tmp/mediapipe/features.pb
echo "COMPLETED"
sleep 5
\ No newline at end of file
......
#-*- coding: utf-8 -*-
import numpy as np
import tensorflow as tf
from tensorflow import logging
......@@ -8,12 +9,12 @@ import video_recommender as recommender
import video_util as videoutil
# Define file paths.
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"
MODEL_PATH = "E:/khuhub/2015104192/web/backend/yt8m/esot3ria/model/inference_model/segment_inference_model"
VOCAB_PATH = "E:/khuhub/2015104192/web/backend/yt8m/vocabulary.csv"
VIDEO_TAGS_PATH = "E:/khuhub/2015104192/web/backend/yt8m/esot3ria/kaggle_solution_40k.csv"
TAG_VECTOR_MODEL_PATH = "E:/khuhub/2015104192/web/backend/yt8m/esot3ria/tag_vectors.model"
VIDEO_VECTOR_MODEL_PATH = "E:/khuhub/2015104192/web/backend/yt8m/esot3ria/video_vectors.model"
SEGMENT_LABEL_PATH = "E:/khuhub/2015104192/web/backend/yt8m/segment_label_ids.csv"
# Define parameters.
TAG_TOP_K = 5
......@@ -85,6 +86,7 @@ def normalize_tag(tag):
def inference_pb(file_path, threshold):
print("started step 1")
VIDEO_TOP_K = int(threshold)
inference_result = {}
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
......@@ -168,7 +170,7 @@ def inference_pb(file_path, threshold):
# 3. Make vocabularies.
voca_dict = {}
vocabs = open(VOCAB_PATH, 'r')
vocabs = open(VOCAB_PATH, 'r', encoding='UTF8')
while True:
line = vocabs.readline()
if not line: break
......@@ -176,7 +178,7 @@ def inference_pb(file_path, threshold):
if vocab_dict_item[0] != "Index":
voca_dict[vocab_dict_item[0]] = vocab_dict_item[3]
vocabs.close()
print("made vocabs")
# 4. Make combined scores.
combined_scores = {}
for line in format_predictions(video_id_batch_val, predictions_val, TAG_TOP_K, whitelisted_cls_mask):
......
......@@ -113,7 +113,6 @@ def make_exmp(id, audio, rgb):
def convert_pb(filename):
sequence_example = open(filename, 'rb').read()
audio, rgb = parse_exmp(sequence_example)
tmp_example = make_exmp('video', audio, rgb)
......
This file is too large to display.
......@@ -8,6 +8,7 @@ FLAGS = flags.FLAGS
def main(unused_argv):
print("start mediapipe")
# Get the input tensor names to be replaced.
tf.reset_default_graph()
meta_graph_location = FLAGS.checkpoint_file + ".meta"
......
......@@ -17,5 +17,6 @@ module.exports = {
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'linebreak-style': 0,
'max-len': ['error', { code: 200 }],
'import/no-extraneous-dependencies': ["error", {"devDependencies": true}],
},
};
......
This diff could not be displayed because it is too large.
......@@ -11,12 +11,12 @@
"@mdi/font": "^3.6.95",
"axios": "^0.19.2",
"core-js": "^3.6.5",
"moment": "^2.24.0",
"moment": "^2.29.1",
"roboto-fontface": "*",
"vue": "^2.6.12",
"vue-router": "^3.1.6",
"vuetify": "^2.2.11",
"vuex": "^3.1.3"
"vue-router": "^3.4.7",
"vuetify": "^2.3.15",
"vuex": "^3.5.1",
"yarn": "^1.22.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.3.0",
......@@ -24,16 +24,17 @@
"@vue/cli-plugin-router": "~4.3.0",
"@vue/cli-plugin-vuex": "~4.3.0",
"@vue/cli-service": "~4.3.0",
"@vue/eslint-config-airbnb": "^5.0.2",
"@vue/eslint-config-airbnb": "^5.1.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.12.0",
"sass": "^1.19.0",
"sass": "^1.27.0",
"sass-loader": "^8.0.2",
"vue-cli-plugin-vuetify": "~2.0.5",
"vue": "^2.6.12",
"vue-cli-plugin-vuetify": "^2.0.7",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.3.0"
"vuetify-loader": "^1.6.0"
}
}
......