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 extract RGB frames from Physionv1.5? #63

Open
duxiaodan opened this issue Apr 8, 2024 · 4 comments
Open

How to extract RGB frames from Physionv1.5? #63

duxiaodan opened this issue Apr 8, 2024 · 4 comments

Comments

@duxiaodan
Copy link

duxiaodan commented Apr 8, 2024

Hello authors of Physion dataset,

There isn't a documentation for Physionv1.5(https://physion-benchmark.github.io/physion_v15) data structure yet. Could you please share a code snippet on how to extract mp4 videos or RGB frames from the hdf5 file? Thank you very much

Best,

Xiaodan Du

@duxiaodan duxiaodan changed the title How to extract RGB frames from Physionv1.5 How to extract RGB frames from Physionv1.5? Apr 8, 2024
@rahulvenkk
Copy link

Hi Xiaodan, sorry for the delay in response.

Here's some code to extract frames from the hdf5 files:

import h5py as h5
import io
from PIL import Image
import numpy as np

def get_image(raw_img, pil=False):
    '''
    raw_img: binary image to be read by PIL
    returns: HxWx3 image
    '''
    img = Image.open(io.BytesIO(raw_img))

    if pil:
        return img
    
    return np.array(img)

def index_img(h5_file, index, suffix='', pil=False):

    # print(index)
    if index > len(h5_file['frames']) - 1:
        #set index to last frame
        # print("inside if")
        index = len(h5_file['frames']) - 1

    img0 = h5_file['frames'][str(index).zfill(4)]['images']
    
    rgb_img = get_image(img0['_img' + suffix][:], pil=pil)

    return rgb_img


h5file = '<path to hdf5 file>'

with h5.File(h5file) as hf:
    rgb_image = index_img(hf, 10, suffix='_cam0')

We will also be releasing the pipeline for model evaluations on PhysionV1.5 soon. We will notify you when that is ready.

@duxiaodan
Copy link
Author

duxiaodan commented Apr 26, 2024

Thank you very much. Looking forward to checking out how to get the binary GT labels from the hdf5 etc.

@rahulvenkk
Copy link

Hi Xiaodan, we released our evaluation pipeline for Physion1.5 recently: https://github.com/neuroailab/physion_evaluator/tree/main

We also have a colab notebook that simplifies the evaluation process: https://github.com/neuroailab/cwm_dynamics?tab=readme-ov-file#colab-notebook

@duxiaodan
Copy link
Author

Thank you for letting me know about the update! Will check it out.

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

2 participants