<jupyter_start><jupyter_text>News<jupyter_code>cap = cv2.VideoCapture('news.mpg')
dist_dict = calc_hist(cap)
for metrics, dist in dist_dict.items():
    print(metrics, len(dist))<jupyter_output>L2 1379
Cosine 1379<jupyter_text>演算法時間<jupyter_code>cap = cv2.VideoCapture('news.mpg')
%timeit dist_dict = calc_hist(cap)
fps = cap.get(cv2.CAP_PROP_FPS)
frame_idx_to_seconds = [0]
for frame_idx in range(1, 1379):
    frame_idx_to_seconds.append(frame_idx_to_seconds[frame_idx - 1] + 1 / fps)
plot_dist(dist_dict['L2'], 'L2', frame_idx_to_seconds)
change_idx = calc_shot_change_idx(dist_dict['L2'], num_var=10)
plot_shot_change_idx(dist_dict['L2'], change_idx)
change_seconds = []
for i in change_idx:
    change_seconds.append(int(frame_idx_to_seconds[i]) + 1)
change_seconds
precisions = []
recalls = []
distance = [3500, 3000, 2500, 2000, 1500, 1000, 500, 200, 100, 50, 10]
shot_change_groundtruth = [3, 8, 10, 12, 15, 29, 43]
for dist in distance:
    change_idx = calc_shot_change_idx(dist_dict['L2'], num_var=None, distance=dist)
    change_seconds = []
    for i in change_idx:
        change_seconds.append(int(frame_idx_to_seconds[i]) + 1)
    if len(change_seconds) == 0:
        recalls = [1.0] + recalls
        precisions = [0] + precisions
        break
    p = precision(shot_change_groundtruth, change_seconds)
    r = recall(shot_change_groundtruth, change_seconds)
    if r < 1:
        precisions.append(p)
        recalls.append(r)
    elif r == 1.0 and len(recalls) > 0:
        recalls.append(1.0)
        precisions.append(p)
        break
    else:
        continue
precisions, recalls
plt.figure(figsize=(16, 10))
plt.xlabel("Recall")
plt.ylabel("Pecision")
plt.plot(recalls, precisions)<jupyter_output><empty_output><jupyter_text>FTFM<jupyter_code>cap = cv2.VideoCapture('ftfm.mp4')
dist_dict = calc_hist(cap)
for metrics, dist in dist_dict.items():
    print(metrics, len(dist))
cap = cv2.VideoCapture('ftfm.mp4')
%timeit dist_dict = calc_hist(cap)
fps = cap.get(cv2.CAP_PROP_FPS)
frame_idx_to_seconds = [0]
for frame_idx in range(1, 769):
    frame_idx_to_seconds.append(frame_idx_to_seconds[frame_idx - 1] + 1 / fps)
plot_dist(dist_dict['Cosine'], 'Cosine', frame_idx_to_seconds)
change_idx = calc_shot_change_idx(dist_dict['Cosine'], num_var=1)
plot_shot_change_idx(dist_dict['Cosine'], change_idx)
change_seconds = []
for i in change_idx:
    change_seconds.append(int(frame_idx_to_seconds[i]) + 1)
change_seconds
precisions = []
recalls = []
shot_change_groundtruth = [1, 2, 3, 4, 6, 6, 7, 9, 9, 12, 14, 15, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30]
for r in range(100):
    change_idx = calc_shot_change_idx(dist_dict['Cosine'], num_var=r)
    change_seconds = []
    for i in change_idx:
        change_seconds.append(int(frame_idx_to_seconds[i]) + 1)
    if len(change_seconds) == 0:
        print('No predictions break')
        recalls = [1.0] + recalls
        precisions = [0] + precisions
        break
    p = precision(shot_change_groundtruth, change_seconds)
    r = recall(shot_change_groundtruth, change_seconds)
    if r < 1:
        precisions.append(p)
        recalls.append(r)
    elif r == 1.0 and len(recalls) > 0:
        recalls.append(1.0)
        precisions.append(p)
        break
    else:
        continue
plt.figure(figsize=(16, 10))
plt.xlabel("Recall")
plt.ylabel("Pecision")
plt.plot(recalls, precisions)<jupyter_output><empty_output><jupyter_text>NGC<jupyter_code>cap = cv2.VideoCapture('ngc.mpeg')
dist_dict = calc_hist(cap)
for metrics, dist in dist_dict.items():
    print(metrics, len(dist))<jupyter_output>L2 1948
Cosine 1948<jupyter_text>演算法時間<jupyter_code>cap = cv2.VideoCapture('ngc.mpeg')
%timeit dist_dict = calc_hist(cap)
fps = cap.get(cv2.CAP_PROP_FPS)
frame_idx_to_seconds = [0]
for frame_idx in range(1, 1948):
    frame_idx_to_seconds.append(frame_idx_to_seconds[frame_idx - 1] + 1 / fps)
plot_dist(dist_dict['L2'], 'L2', frame_idx_to_seconds)
change_idx = calc_shot_change_idx(dist_dict['L2'], num_var=20)
plot_shot_change_idx(dist_dict['L2'], change_idx)
change_seconds = []
for i in change_idx:
    change_seconds.append(int(frame_idx_to_seconds[i]) + 1)
change_seconds<jupyter_output><empty_output><jupyter_text>演算法 Precision 和 Recall<jupyter_code>precisions = []
recalls = []
shot_change_groundtruth = [4,7,10,11,13,13,15,17,18,19,21,23,23,24,26,27,28,29,29,29,30,30,30,31,31,32,32,32,32,32,33,33,34,35,35,36,37,38,38,39,39,40,40,41,41,42,42,43,43,44,45,45,46,46,47,48,50,51,53,54,55,55,56,58]
for r in range(0, 500):
    change_idx = calc_shot_change_idx(dist_dict['L2'], num_var=r)
    change_seconds = []
    for i in change_idx:
        change_seconds.append(int(frame_idx_to_seconds[i]) + 1)
    if len(change_seconds) == 0:
        print('No predictions break')
        recalls = [1.0] + recalls
        precisions = [0] + precisions
        break
    p = precision(shot_change_groundtruth, change_seconds)
    r = recall(shot_change_groundtruth, change_seconds)
    if r < 1:
        precisions.append(p)
        recalls.append(r)
    elif r == 1.0 and len(recalls) > 0:
        recalls.append(1.0)
        precisions.append(p)
        break
    else:
        break
plt.figure(figsize=(16, 10))
plt.xlabel("Recall")
plt.ylabel("Pecision")
plt.plot(recalls, precisions)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1372474985841042, 'fraction_numerical': 0.06418727581649991, 'mean_word_length': 4.721382289416846, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '313090', 'license': 'MIT', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2062, 'n_words': 360, 'path': 'hw2/hw2_color_hist.ipynb', 'repo_name': 'Kuanch/office_hour', 'size': '5297'}