segment-anything icon indicating copy to clipboard operation
segment-anything copied to clipboard

Finetuning

Open kdcd opened this issue 1 year ago • 81 comments

Is there any plans to release scripts for finetuning the model?

Also you did such a great work! Thank you very much!

kdcd avatar Apr 05 '23 15:04 kdcd

Information on fine tuning would be great.

codybum avatar Apr 05 '23 19:04 codybum

+1, I'd love to be able to fine tune to improve performance on extremely difficult tiny-object tasks, for example segmenting vehicles in geospatial images:

3CYVS3OSCFVCC4VHCCGRGRUT2Y

austinmw avatar Apr 06 '23 16:04 austinmw

this thread is referenced as the answer for similar questions, but I don't think there is an answer here for transfer learning?

penguingiraffe2 avatar Apr 07 '23 01:04 penguingiraffe2

Look forward to finetuning

jindameias avatar Apr 07 '23 03:04 jindameias

I would love to be able to fine tune the model for specific datasets as well.

BenSpex avatar Apr 07 '23 12:04 BenSpex

Do we wait for Meta to provide a training/fine-tuning script? Or should the open source hivemind write it?

hu-po avatar Apr 07 '23 15:04 hu-po

Has anyone tried the idea of what may be called "point prompt engineering"? i.e. training a separate model that learns how to put positive prompt points and negative prompt points, such that these points prompt SAM to select target objects from a custom dataset.

Or we can just summarize strategies and best practices in terms of placing positive and negative prompt points/prompt boxes, similar to how GPT/DALLE users summarize the best ways to write prompts.

Wonder if this could be one way to fine-tune the SAM model when only a limited amount of annotations are available. Happy to discuss more if anyone wants to work together and try it out.

TimWGY avatar Apr 08 '23 04:04 TimWGY

+1, Looking forward to fine-tuning the SAM model on the custom dataset.:)

openvino-book avatar Apr 08 '23 13:04 openvino-book

I am attempting some fine tuning in this repo. Perhaps people can find use in it. The biggest thing I figured out is that you have to break up the Sam model into its components in order for there to be a gradient path for fine-tuning.

hu-po avatar Apr 08 '23 13:04 hu-po

After some messing around I have gotten preliminary fine-tuning to work on my fork. The code is still super messy and early, but perhaps people can find use in it. The biggest thing I figured out is that you have to break up the Sam model into its components in order for there to be a gradient path for fine-tuning.

Could you please recommend the minimum hardware configuration for fine-tuning the SAM? eg. 4090 x 4?

dlod-openvino avatar Apr 08 '23 13:04 dlod-openvino

Could you please recommend the minimum hardware configuration for fine-tuning the SAM? eg. 4090 x 4?

I can get the smallest pre-trained model (vit_b) with a batch size of 1 in <5GB of GPU memory, but I think fine tuning with those settings would take forever.

hu-po avatar Apr 08 '23 14:04 hu-po

I have access to a 4 x A100 /w 80G if you want me to test something.

codybum avatar Apr 08 '23 17:04 codybum

hi @hu-po ,

Thanks for sharing the fine-tuning code very much. Would it be possible for you to give guidance on how to prepare the customized dataset (e.g., data format and folder structures)?

JunMa11 avatar Apr 09 '23 19:04 JunMa11

hi @hu-po ,

Thanks for sharing the fine-tuning code very much. Would it be possible for you to give guidance on how to prepare the customized dataset (e.g., data format and folder structures)?

Thank me when I get it to work 😭 this is more complicated than anticipated.

hu-po avatar Apr 09 '23 20:04 hu-po

+1, interested in fine-tuning it for coral reef images.

shakesBeardZ avatar Apr 10 '23 08:04 shakesBeardZ

+1 interested in fine-tuning it for cracking on roads.

AMInnovationTeam avatar Apr 11 '23 02:04 AMInnovationTeam

+1 🙌

maskani-moh avatar Apr 11 '23 12:04 maskani-moh

+1 interested in fine-tuning!

ariannaravera avatar Apr 11 '23 15:04 ariannaravera

+1, I'd like to do some vehicle detection on low quality images!

harry-s-grewal avatar Apr 11 '23 18:04 harry-s-grewal

+1 interested in fine tunning prompt encoder or mask decoder!

javiermcebrian avatar Apr 12 '23 18:04 javiermcebrian

+1! I would be interested in fine-tuning the model for medical image analysis

francescodisalvo05 avatar Apr 13 '23 06:04 francescodisalvo05

I'm curious that is it possible to point out an unknown object have not been learned (like anomaly detection) by text prompt if I fine-tune with custom data.

travishsu avatar Apr 13 '23 07:04 travishsu

+1!

imandrealombardo avatar Apr 13 '23 08:04 imandrealombardo

CC: @ericmintun @nikhilaravi

satpalsr avatar Apr 13 '23 09:04 satpalsr

@hu-po hi, nice work for sharing finetune script , is "FragmentDataset" the datasets that released by official datasets https://segment-anything.com/dataset/index.html

Kenneth-X avatar Apr 13 '23 09:04 Kenneth-X

@hu-po hi, nice work for sharing finetune script , is "FragmentDataset" the datasets that released by official datasets https://segment-anything.com/dataset/index.html

No, it's a custom dataset for x-ray data of scroll fragments: https://www.kaggle.com/competitions/vesuvius-challenge-ink-detection/data

hu-po avatar Apr 13 '23 12:04 hu-po

I have a finetune starter code for COCO instance segmentation format data with some basic functionalities at this repo. Hope it would help!

bhpfelix avatar Apr 13 '23 18:04 bhpfelix

Hey, we wrote a blog post outlining some of the key steps to fine tune SAM using the mask decoder, particularly describing which functions from SAM to use to pre/post process the data so that it's in a good shape for fine tuning.

alex-encord avatar Apr 13 '23 20:04 alex-encord

@hu-po hi, nice work for sharing finetune script , is "FragmentDataset" the datasets that released by official datasets https://segment-anything.com/dataset/index.html

No, it's a custom dataset for x-ray data of scroll fragments: https://www.kaggle.com/competitions/vesuvius-challenge-ink-detection/data

I know those guys!

codybum avatar Apr 14 '23 00:04 codybum

I am a student and I am also looking forward to the release of the fine-tuning to complete my academic paper, and I would be very grateful if it is released

750563720 avatar Apr 14 '23 02:04 750563720