How to modify the code to simply output PPG predictions without ground truth labels
Closed this issue · 3 comments
I am trying to use one of the models to take raw video data (from a MacBook Pro 17 camera) and output PPG signal predictions. However, I don't have ground truth data for the PPG signals, and I know that is part of the current required structure for the data. I don't really care what model I test, as I simply want to get it working for now. How can I modify the code for my purpose? Is there something in the config files I can change for that?
Assuming you're adding your own custom dataloader for this captured data, you can just omit loading a ground truth signal there and then modify metrics.py
so that you only save the reformed predictions. For example, you can write a function like:
def extract_and_save_ppg_signals(predictions, save_path):
"""Extract PPG signals from predictions and save them as .npy file."""
ppg_signals = []
print("Extracting PPG signals!")
for index in tqdm(predictions.keys(), ncols=80):
prediction = _reform_data_from_dict(predictions[index])
ppg_signals.append(prediction)
# Convert to a numpy array and save to a file
ppg_signals = np.array(ppg_signals)
np.save(save_path, ppg_signals)
print(f"PPG signals saved to {save_path}")
And then call that function instead of calculate_metrics()
from any of the trainer files (e.g., TscanTrainer
).
How would I modify and implement the functions preprocess_dataset, read_video, and read_wave to be able to take my raw videos as input and be compatible with the models for output? Like, what parts of the code would change when compared to something like the UBFCrPPGLoader.py methods, and how would I know what to change?
Your best bet is to look at the functions already implemented themselves, understand the existing code, and then try implementing your own custom dataloader. Depending on how you save your videos recorded from video, this should be pretty straightforward (for example, note how .avi
videos are loaded in the case of UBFC-rPPG). The code is all open source, so if you run into specific errors trying to implement things, let us know.