transformers.js
transformers.js copied to clipboard
[FEAT] Refactor CUSTOM_ARCHITECTURES to provide custom model
This PR will allow for a custom model to be provided for any of the custom architectures - providing null will default to PreTrainedModel.
This came about when I was creating a new model; I wanted to set it up as an Image Segmentation model.
Below shows how a new architecture can be provided with a specific model, rather than PreTrainedModel.
/** @type {CustomArchitectures} */
const CUSTOM_ARCHITECTURES = new Map([
['modnet', [MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, null]],
['birefnet', [MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, null]],
['isnet', [MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, null]],
['u2net', [MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, U2NetModel]],
['ben', [MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, null]],
]);