<jupyter_start><jupyter_text>Generate files for End2You Here we provide an example on how to generate the required label files and the `input_file.csv` for the AffWild database in order to run End2You.The AffWild folder is structured as follows:```AffWild|─── annotations|   |─── train|   |   |─── arousal|   |   |   |─── 105.txt|   |   |   |─── 106.txt|   |   |   |─── ...|   |   |─── valence|   |   |   |─── 105.txt|   |   |   |─── 106.txt|   |   |   |─── ...|   |─── test|   |   |─── arousal|   |   |─── valence|─── bboxes|─── landmarks|─── videos|   |─── train|   |   |─── 105.avi|   |   |─── 106.avi|   |   |─── ...|   |─── test```  Set Paths<jupyter_code>import numpy as np
from pathlib import Path

root_dir = Path('/path/to/AffWild/')
save_path = Path('/path/to/save/end2you_files')

split = 'test'

videos_dir = root_dir / 'videos' / split
annotations = root_dir / 'annotations'

arousal_path = annotations / split / 'arousal'
valence_path = annotations / split / 'valence'<jupyter_output><empty_output><jupyter_text>Write `input_file.csv`<jupyter_code>from moviepy.editor import VideoFileClip

videos, annots = [], []
for video_path in list(videos_dir.glob('*')):
    
    video_name = video_path.name[:-4]
    clip = VideoFileClip(str(video_path))
    fps = np.ceil(clip.fps).astype(int)
    
    arousal_file = arousal_path / (video_name + '.txt')
    valence_file = valence_path / (video_name + '.txt')
    
    # Load arousal/valence annotation values
    arousal_annot = np.loadtxt(arousal_file, dtype=np.float32).reshape(-1,1)
    valence_annot = np.loadtxt(valence_file, dtype=np.float32).reshape(-1,1)
    annotations = np.hstack([arousal_annot, valence_annot])
    
    # Find the time of each frame based on FPS
    time = [0.0]
    for t in range(annotations.shape[0]):
        time.append(time[-1] + 1/clip.fps)
    time = np.array(time).reshape(-1,1)
    
    # Save time/arousal/valence for each video in a csv file
    data = np.hstack([time[:-1], annotations]).astype(np.float32)
    save_annot = save_path / 'video_annot' / (video_name + '.csv')
    np.savetxt(str(save_annot), data, fmt='%.4e', delimiter=',', header = 'time,arousal,valence')
    
    # Store videos and annotations paths to write `input_file.csv` file
    videos.append(str(video_path))
    annots.append(str(save_annot))
vs = np.array(videos).reshape(-1, 1)
annts = np.array(annots).reshape(-1, 1)
# Save `input_file.csv`
input_file_path = save_path / 'input_file_test.csv'
np.savetxt(str(input_file_path), np.hstack([vs, annts]), fmt='%s', delimiter=',', header='video_file,annotation_file')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16838487972508592, 'fraction_numerical': 0.01718213058419244, 'mean_word_length': 3.6785714285714284, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '567343', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1028, 'n_tokens_neox': 950, 'n_words': 207, 'path': 'docs/pretrained_models/AffWild/1. Generate files for End2You.ipynb', 'repo_name': 'tfyd/myEnd2you', 'size': '2619'}