healthonrails / annolid

An annotation and instance segmentation-based multiple animal tracking and behavior analysis package.
Other
41 stars 9 forks source link

Testing another .pth file on the same video #15

Closed Hatem-Jr closed 3 years ago

Hatem-Jr commented 3 years ago

Hi, (this forum has been very helpful so here I am XD) I want to test the time it takes to process frames from the same video using lesser trained models using the colab notebook but I'm not sure from which cell do I run and in which order since we need a different .pth file like: model_0001999.pth

healthonrails commented 3 years ago

You can replace model_final.pth to model_0001999.pth in the following line cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final.pth") # path to the model we just trained .

Hatem-Jr commented 3 years ago

can I manually write the cfg.OUTPUT_DIR my self ? you know since it's on my drive ? and my guess is that we don't need a .config file but only the .pth one (sorry I have been doing other tests so I forgot how this one works thanks :D)

healthonrails commented 3 years ago

can I manually write the cfg.OUTPUT_DIR my self ? you know since it's on my drive ? and my guess is that we don't need a .config file but only the .pth one (sorry I have been doing other tests so I forgot how this one works thanks :D)

Yes, you can replace it with the file path on your local drive for example cfg.MODEL.WEIGHTS = "/path/to/my_model.pth"

Hatem-Jr commented 3 years ago

Hi so I ran this cell: cfg = get_cfg() #I added this to avoid an error in the next line cfg.MODEL.WEIGHTS = os.path.join("/content/drive/MyDrive/Test Vids/", "model_0001999.pth") # path to the model we just trained cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.15 # set a custom testing threshold predictor = DefaultPredictor(cfg)

Then I ran each cell in the "Please change the VIDEO_INPUT to the path of your inference video" subsection until this cell: class_names = _dataset_metadata.thing_classes print(class_names) but this happened:"NameError: name '_dataset_metadata' is not defined"

so I ignored it so I tried to run the cell after that which begins processing the frames and this error happened: "NameError: name '_dataset_metadata' is not defined" again

I only ran until cell number 4 at the beginning of the installing and then went straight to the cfg.Model line

healthonrails commented 3 years ago

'_dataset_metadata' NameError means that you did not register a dataset in the previous cells. You don't need to run this cell for your video inference. You can just skip it.

Hatem-Jr commented 3 years ago

but in the cell that begins with : frame_number = 0 tracking_results = []

has this in it: v = Visualizer(im[:, :, ::-1], metadata=_dataset_metadata, scale=0.5, instance_mode=ColorMode.IMAGE_BW # remove the colors of unsegmented pixels. This option is only available for segmentation models ) and brings the same error and v is used in the very next line which will produce another error for sure

healthonrails commented 3 years ago

but in the cell that begins with : frame_number = 0 tracking_results = []

has this in it: v = Visualizer(im[:, :, ::-1], metadata=_dataset_metadata, scale=0.5, instance_mode=ColorMode.IMAGE_BW # remove the colors of unsegmented pixels. This option is only available for segmentation models ) and brings the same error and v is used in the very next line which will produce another error for sure

This is for visualization. You can remove it or you need to upload your dataset and run the previous cells but don't run the training cell.

Hatem-Jr commented 3 years ago

It started processing until this happened: Screenshot 2021-07-10 154505

healthonrails commented 3 years ago

That means some masks are missing in this frame. You can try to remove this line assert len(rles) == len(boxes).

Hatem-Jr commented 3 years ago

It kept running for 32 minutes and then produced an empty csv file, can you tell me the steps on how to process frames on a less trained ".pth" file exactly because that was the most nerve racking half hour ? or any ".pth" file for that matter ?

healthonrails commented 3 years ago

cess frames on a less trained ".pth" file exactly because that was the most nerve racking half hour ? or any ".pth" file for that matter ? The easiest way is to run all the cells from start expect trainer.train() and change model_final.pth to model_xxxxxx.pth. in the following line cfg.MODEL.WEIGHTS = os.path.join(cfg.OUTPUT_DIR, "model_final.pth") # path to the model we just trained.