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

Memory issues after auto-annotating for a few objects #150

Open
renyiyu opened this issue Aug 7, 2023 · 2 comments
Open

Memory issues after auto-annotating for a few objects #150

renyiyu opened this issue Aug 7, 2023 · 2 comments

Comments

@renyiyu
Copy link

renyiyu commented Aug 7, 2023

Label Studio X SAM seems to have memory issues after auto annotating for about 20-30 objects in the same image. The auto annotating process is getting slower and slower even I use vit_b/mobile sam model on gpu setup.

My average image size is around 640 * 640 and my GPU is 3090. Since my use case has around 100 small objects to annotate per image. It makes me really difficult to annotate all the objects for the entire image, especially last 50 objects.

@JimmyMa99
Copy link
Contributor

This issue was also mentioned, and I'm guessing it's a label studio issue, the exact problem needs further troubleshooting.

@halqadasi
Copy link

halqadasi commented Mar 29, 2024

I solved this issue by loading the model only one time if it has not been loaded before rather than loading the model by labeling each image.

Open /playground/label_anything/sam and open the mmdetection.py and go to the class MMDetection and change it as follows:


class MMDetection(LabelStudioMLBase):
    """Object detector based on https://github.com/open-mmlab/mmdetection."""
    _predictor = None                  # ----------> add this private variable
    def __init__(self,
                 config_file=None,
                 checkpoint_file=None,
                 sam_config='vit_b',
                 sam_checkpoint_file=None,
                 image_dir=None,
                 labels_file=None,
                 out_mask=True,
                 out_bbox=False,
                 out_poly=False,
                 score_threshold=0.5,
                 device='cpu',
                 **kwargs):

        super(MMDetection, self).__init__(**kwargs)

        #************************Add the following two lines*******************
        # Only load the model if it hasn't been loaded before   
        if MMDetection._predictor is None:
            MMDetection._predictor = load_my_model(device, sam_config, sam_checkpoint_file)

        self.PREDICTOR = MMDetection._predictor

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

3 participants