Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate .h5 Files for eval_goldfish_movie_chat.py #43

Open
prote376 opened this issue Nov 21, 2024 · 0 comments
Open

How to generate .h5 Files for eval_goldfish_movie_chat.py #43

prote376 opened this issue Nov 21, 2024 · 0 comments

Comments

@prote376
Copy link

def load_frames(self, movie_name):
    filenames = sorted(os.listdir(os.path.join(self.dataset_path, movie_name)))
    
    filenames.sort(key=numerical_sort_key)
    # define torch tensor to store the frames of size(0,0,0)
    data = []
    for filename_number in tqdm(filenames,desc="Loading frames"):
        file_path = os.path.join(self.dataset_path, movie_name, filename_number)

        if not os.path.isfile(file_path):
            print(f"Did not find file: {filename_number}")
        try:
            with h5py.File(file_path, 'r') as h5_file:
                image_embeds=torch.tensor(h5_file[f"frames_{filename_number[:-3]}"][:])
                image_embeds = image_embeds[:,1:,:] # remove the first token (CLS) (200,256,1408)
                # concate each 4 neighbours image tokens 
                bs, pn, hs = image_embeds.shape
                image_embeds = image_embeds.view(bs, int(pn/4), int(hs*4)) 
                data.extend(image_embeds)

        except Exception as e:  
            print(f"Failed to process {filename_number}: {e}")
        
            
    frames=torch.stack(data)
    return frames

I was testing the code in eval_goldfish_movie_chat.py.
In the load_frames function of MovieChatDataset (Lines 112–137), it appears that the code expects .h5 files corresponding to each video file.
Could you please provide more details on how these .h5 files are generated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant