# Segment Anything model fine-tuning use in a pipeline

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsegment-anything-model-fine-tuning-use-in-a-pipeline%2F53667%3E%5C
**Category:** 🤗Transformers\
**Created:** [September 5, 2023, 4:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsegment-anything-model-fine-tuning-use-in-a-pipeline%2F53667 "2023-09-05T16:02:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcomameli01](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marcomameli01](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmarcomameli01)%5C
**Post date:** [September 5, 2023, 4:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsegment-anything-model-fine-tuning-use-in-a-pipeline%2F53667%2F1 "2023-09-05T16:02:40Z")

</div>

Hi,  
I have finetuned the facebook/sam-vit-base on my own dataset based on the example in Jupyter Notebook for fine-tuning.  
But If I try to use it in the mask-generation pipeline I receive an error:

OSError: Can’t load the configuration of ‘./model/sam\_model.pth’. If you were trying to load it from ‘[Models - Hugging Face](https://huggingface.co/models)’, make sure you don’t have a local directory with the same name. Otherwise, make sure ./model/sam\_model.pth’ is the correct path to a directory containing a config.json file

how can I save the config.json from SamModel.from\_pretrained(‘facebook/sam-vit-base’) with the trained weight?

Can you explain that please.

Thank you

---

<div class="post-metadata">

**Author:** ![marcomameli01](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@marcomameli01](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmarcomameli01)%5C
**Post date:** [September 5, 2023, 6:26pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsegment-anything-model-fine-tuning-use-in-a-pipeline%2F53667%2F2 "2023-09-05T18:26:54Z")

</div>

I would like to give the answer for all:  
To use the model finetuned with the pipeline you can save the processor and tuned model with save\_pretrained and pass the same folder, after that you can pass to the pipeline the path where you save the with the save\_pretrained method.
