윤영빈

tmep

# 내용 기반 유튜브 영상 추천 시스템 개선안
# Video vector list를 이용한 내용 기반 유튜브 영상 추천 시스템 개선안
## Research field
* Video Understanding
......
......@@ -5,6 +5,7 @@ from numpy.linalg import norm
import pandas as pd
import math
import activation as ac
import time
def recommend_videos(tags, segments, tag_model_path, video_model_path, video_id_model, top_k, isPerSegment = True):
# 이 함수에서 모든걸 다 함
......@@ -108,18 +109,15 @@ def recommend_videos(tags, segments, tag_model_path, video_model_path, video_id_
error_tags.append(tag)
kernel[k] = segment_vector
for t in tagKernel:
print(t)
#여기에서 유사한 벡터들을 뽑아냄
#현재는 비디오id로 영상을 얻을 수 없으므로 반환값으로 비디오 아이디와 태그들, 확률 사용
video_tags = pd.read_csv('/mnt/e/khuhub/2015104192/web/backend/yt8m/esot3ria/segment_tags.csv', encoding='utf8',error_bad_lines=False)
video_tags_per_id = pd.read_csv('/mnt/e/khuhub/2015104192/web/backend/yt8m/esot3ria/videoIds.csv', encoding='utf8',error_bad_lines=False)
videoId_index = 0
videoVectorList = []
segmentTagList = []
prevVideoId = ""
minimunVideoIds = [["",-1.0] for i in range(0,top_k)]
prev_sev = time.time()
for i, row in video_tags.iterrows():
video_id = row[0]
if video_id == "vid_id":
......@@ -129,16 +127,6 @@ def recommend_videos(tags, segments, tag_model_path, video_model_path, video_id_
if video_id[0:4] != prevVideoId[0:4]:
currentComparingVideoTags = video_tags_per_id.loc[videoId_index]
videoId_index += 1
print(videoTagList)
print(currentComparingVideoTags)
if (currentComparingVideoTags['segment1'].split(':')[0] not in videoTagList and
currentComparingVideoTags['segment2'].split(':')[0] not in videoTagList and
currentComparingVideoTags['segment3'].split(':')[0] not in videoTagList and
currentComparingVideoTags['segment4'].split(':')[0] not in videoTagList and
currentComparingVideoTags['segment5'].split(':')[0] not in videoTagList):
continue
#여기서 모다진걸로 컨볼루션 연산
#convmaxima, convidx = convolution(videoVectorList,kernel,prevVideoId)
maxima, idx = differenceMax(segmentTagList,tagKernel,tag_vectors,videoTagList)
......@@ -167,11 +155,13 @@ def recommend_videos(tags, segments, tag_model_path, video_model_path, video_id_
for i in range(1,top_k+1):
tagList.append([row[i].split(":")[0],row[i].split(":")[1]])
segmentTagList.append(tagList)
print(time.time() - prev_sev)
for i in range(0,top_k):
similar_ids.append(minimunVideoIds[i][0])
else:
similar_ids = [x[0] for x in video_ids.similar_by_vector(video_vector, top_k)]
print(similar_ids)
return similar_ids
......@@ -379,7 +369,7 @@ VIDEO_ID_MODEL_PATH = "/mnt/e/khuhub/2015104192/web/backend/yt8m/esot3ria/videoI
TEST_TAGS_PATH = "/mnt/e/khuhub/2015104192/web/backend/yt8m/esot3ria/test_segement_tags.csv"
'''
test(TAG_VECTOR_MODEL_PATH,
VIDEO_VECTOR_MODEL_PATH,
VIDEO_ID_MODEL_PATH,
......@@ -387,4 +377,4 @@ test(TAG_VECTOR_MODEL_PATH,
VIDEO_TAGS_PATH,
TEST_TAGS_PATH,
5)
\ No newline at end of file
'''
\ No newline at end of file
......