megvii-research / video_analyst

A series of basic algorithms that are useful for video understanding, including Single Object Tracking (SOT), Video Object Segmentation (VOS) and so on.
MIT License
832 stars 176 forks source link

why does this code is required? #206

Closed zxyyxzz closed 2 years ago

zxyyxzz commented 3 years ago

if task in ["track", "vos"]:
         # build dummy dataset for purpose of dataset setup (e.g. caching path list)
         logger.info("Build dummy AdaptorDataset")
         dummy_py_dataset = AdaptorDataset(
            task,
            cfg,
            num_epochs=cfg.num_epochs,
            nr_image_per_epoch=cfg.nr_image_per_epoch,
            seed=seed,
        )
        logger.info("Read dummy training sample")
        dummy_sample = dummy_py_dataset[0]  # read dummy sample
        del dummy_py_dataset, dummy_sample

Hi, i read your code, but i can't understand the code here, Isn't it redundant here?

Hope you can reply me,  thank you!~~ :-)
zxyyxzz commented 3 years ago

@lzx1413,@MARMOTatZJU Hi, i read your code, but i can't understand the code here, Isn't it redundant here?

Hope you can reply me, thank you!~~ :-)

lzx1413 commented 3 years ago

Because we want to load the data items in class static vars to avoid load data items repeatedly.

zxyyxzz commented 3 years ago

Because we want to load the data items in class static vars to avoid load data items repeatedly.

But why does this code can avoid load data items? it just build AdaptorDataset, then you delete it

MARMOTatZJU commented 2 years ago

@zxyyxzz Please paste the link to starting line here so that I can trace to the context of this block easily.

From this stage, I can only guess that some static class members will be initialized when the first object is instantiated, and this is required before the instantiation of the first real dataset. So a dummy object is built here just for initialization.

Specifically, the following comment line in the code explains the using purpose: build dummy dataset for purpose of dataset setup (e.g. caching path list)

MARMOTatZJU commented 2 years ago

Closed as no further discussion. Feel free to reopen it again.