Showing
7 changed files
with
16 additions
and
7 deletions
... | @@ -31,10 +31,13 @@ def normalize(arrs): | ... | @@ -31,10 +31,13 @@ def normalize(arrs): |
31 | normalized_arr = [] | 31 | normalized_arr = [] |
32 | for x in arrs: | 32 | for x in arrs: |
33 | normalized_arr.append(float(x)) | 33 | normalized_arr.append(float(x)) |
34 | - | 34 | + |
35 | - maximum = max(normalized_arr) | 35 | + if len(normalized_arr) > 0: |
36 | - minimum = min(normalized_arr) | 36 | + maximum = max(normalized_arr) |
37 | - denom = float(maximum) - float(minimum) | 37 | + minimum = min(normalized_arr) |
38 | - for i in range(0,len(normalized_arr)): | 38 | + denom = float(maximum) - float(minimum) |
39 | - normalized_arr[i] = ((normalized_arr[i] - minimum)/ denom) * 2 - 1 | 39 | + if denom == 0: |
40 | + denom = 1 | ||
41 | + for i in range(0,len(normalized_arr)): | ||
42 | + normalized_arr[i] = ((normalized_arr[i] - minimum)/ denom) * 2 - 1 | ||
40 | return normalized_arr | 43 | return normalized_arr |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -230,7 +230,7 @@ def inference_pb(file_path, threshold): | ... | @@ -230,7 +230,7 @@ def inference_pb(file_path, threshold): |
230 | 230 | ||
231 | # 5. Create recommend videos info, Combine results. | 231 | # 5. Create recommend videos info, Combine results. |
232 | recommend_video_ids = recommender.recommend_videos(tag_result, inputVideoTagResults, TAG_VECTOR_MODEL_PATH, | 232 | recommend_video_ids = recommender.recommend_videos(tag_result, inputVideoTagResults, TAG_VECTOR_MODEL_PATH, |
233 | - VIDEO_VECTOR_MODEL_PATH, VIDEO_ID_MODEL_PATH, VIDEO_TOP_K) | 233 | + VIDEO_VECTOR_MODEL_PATH, VIDEO_ID_MODEL_PATH, VIDEO_TOP_K,True) |
234 | video_result = [videoutil.getVideoInfo(ids, VIDEO_TAGS_PATH, TAG_TOP_K,False) for ids in recommend_video_ids] | 234 | video_result = [videoutil.getVideoInfo(ids, VIDEO_TAGS_PATH, TAG_TOP_K,False) for ids in recommend_video_ids] |
235 | 235 | ||
236 | inference_result = { | 236 | inference_result = { | ... | ... |
This diff could not be displayed because it is too large.
File moved
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment