Segment Anything model fine-tuning use in a pipeline

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’, 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

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.