ubicomplab / rPPG-Toolbox

rPPG-Toolbox: Deep Remote PPG Toolbox (NeurIPS 2023)
https://arxiv.org/abs/2210.00716
Other
449 stars 107 forks source link

Problems encountered in learning BaseLoader.py #312

Closed trainee0111 closed 4 days ago

trainee0111 commented 6 days ago

Thank you very much for the excellent toolbox your team has provided. While learning to use this toolbox, I encountered some issues that I haven't fully understood. In BaseLoader.py, I noticed some spelling errors in function definitions, such as "generate_pos_psuedo_labels()" and "Hilbert envlope." Of course, these errors do not affect function calls.

 def chunk(self, frames, bvps, chunk_length):
        """Chunk the data into small chunks.

        Args:
            frames(np.array): video frames.
            bvps(np.array): blood volumne pulse (PPG) labels.
            chunk_length(int): the length of each chunk.
        Returns:
            frames_clips: all chunks of face cropped frames
            bvp_clips: all chunks of bvp frames
        """

        clip_num = frames.shape[0] // chunk_length
        frames_clips = [frames[i * chunk_length:(i + 1) * chunk_length] for i in range(clip_num)]
        bvps_clips = [bvps[i * chunk_length:(i + 1) * chunk_length] for i in range(clip_num)]
        return np.array(frames_clips), np.array(bvps_clips)

    def save(self, frames_clips, bvps_clips, filename):
        """Save all the chunked data.

        Args:
            frames_clips(np.array): blood volumne pulse (PPG) labels.
            bvps_clips(np.array): the length of each chunk.
            filename: name the filename
        Returns:
            count: count of preprocessed data
        """

        if not os.path.exists(self.cached_path):
            os.makedirs(self.cached_path, exist_ok=True)
        count = 0
        for i in range(len(bvps_clips)):
            assert (len(self.inputs) == len(self.labels))
            input_path_name = self.cached_path + os.sep + "{0}_input{1}.npy".format(filename, str(count))
            label_path_name = self.cached_path + os.sep + "{0}_label{1}.npy".format(filename, str(count))
            self.inputs.append(input_path_name)
            self.labels.append(label_path_name)
            np.save(input_path_name, frames_clips[i])
            np.save(label_path_name, bvps_clips[i])
            count += 1
        return count

I have a question about the chunk() function. The returned values, frames_clips and bvp_clips, seem to be parameters passed to the save() function. However, the descriptions of these two arrays appear to differ. This might be due to my limited experience and first encounter with the relevant theories and methods. Could you please clarify the reason for this? Thank you!

girishvn commented 4 days ago

hi @trainee0111 Thanks for brings those up, I'll make sure to fix those in my next PR.

You're right, the documentation around chunk and save seems like it could use a re-write. Here's an updated description.

For chunk: frames(np.array): video frames (the full length of the video) bvps(np.array): blood volumne pulse (PPG) labels. (the full length of the video)

chunk takes both frames and bvps and splits them into N non-overlapping segments of chunk_length frames and samples.

For save: The length og the frames_clips list and the bvps_clips list is the same Args: frames_clips(np.array): video frame clips. Each clip is of chunk_length bvps_clips(np.array): bvp signal clips, each of length chunk_length Returns: count: count of preprocessed data

Hope that helps!

trainee0111 commented 4 days ago

hi @trainee0111 Thanks for brings those up, I'll make sure to fix those in my next PR.

You're right, the documentation around chunk and save seems like it could use a re-write. Here's an updated description.

For : frames(np.array): video frames (the full length of the video) bvps(np.array): blood volumne pulse (PPG) labels. (the full length of the video)chunk

chunk takes both frames and bvps and splits them into N non-overlapping segments of frames and samples.chunk_length

For : The length og the frames_clips list and the bvps_clips list is the same Args: frames_clips(np.array): video frame clips. Each clip is of bvps_clips(np.array): bvp signal clips, each of length Returns: count: count of preprocessed datasave``chunk_length``chunk_length

Hope that helps!

Thank you very much for your detailed reply, it has been very helpful for me!