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

Question about pipeline for Inference with InferEngine #18

Open
connor-john opened this issue Jan 24, 2022 · 0 comments
Open

Question about pipeline for Inference with InferEngine #18

connor-john opened this issue Jan 24, 2022 · 0 comments

Comments

@connor-john
Copy link

connor-john commented Jan 24, 2022

How is data needed to be prepared for using InferEngine
If my inference was something like

def read_video(video):
    '''Read video prepare video_metas'''
    pass

def prepare(cfg, checkpoint):
    engine = build_engine(cfg.infer_engine)
    load_weights(engine.model, checkpoint, map_location='cpu')

    device = torch.cuda.current_device()
    engine = MMDataParallel(
        engine.to(device), device_ids=[torch.cuda.current_device()])

    data_pipeline = Compose(cfg.data_pipeline)

    return engine, data_pipeline

def main():
    args = parse_args()
    cfg = Config.fromfile(args.config)

    engine, data_pipeline = prepare(cfg, args.checkpoint)

    imgs, video_metas = read_video(args.video)

    data = data_pipeline(imgs)
    
    # scatter here

    results = engine.infer(data['imgs'], video_metas)

    print(results)

I will likely need to change the pipeline from the default but to what

data_pipeline=[
    dict(typename='LoadMetaInfo'), # probably dont need
    dict(typename='Time2Frame'), # probably dont need
    dict(
        typename='OverlapCropAug',
        num_frames=num_frames,
        overlap_ratio=overlap_ratio,
        transforms=[
            dict(typename='TemporalCrop'),
            dict(typename='LoadFrames', to_float32=True), # probably dont need 
            dict(typename='SpatialCenterCrop', crop_size=img_shape),
            dict(typename='Normalize', **img_norm_cfg),
            dict(typename='Pad', size=(num_frames, *img_shape)),
            dict(typename='DefaultFormatBundle'),
            dict(typename='Collect', keys=['imgs'])
    ])
]

I imagine ImageToTensor is needed as a last step before Collect and loading the frame will need to be different
Any clues or help is appreciated

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