towhee.models.clip4clip.clip4clip.create_model¶
- towhee.models.clip4clip.clip4clip.create_model(model_name: Optional[str] = None, context_length: int = 77, pretrained: bool = False, weights_path: Optional[str] = None, device: Optional[Union[str, device]] = None) CLIP4Clip [source]¶
Create a CLIP4Clip model. :param model_name: Model name, clip_vit_b16 or clip_vit_b32. :type model_name: str :param context_length: Length of context sequence, default is 77, the same as these in CLIP. :type context_length: int :param pretrained: Whether pretained model. :type pretrained: bool :param weights_path: Your local trained weights path. default is None. :type weights_path: str :param device: Model device, cpu or cuda. :type device: str
- Returns:
CLIP4Clip model.
- Return type:
(CLIP4Clip)
>>> from towhee.models import clip4clip >>> model = clip4clip.create_model(model_name="clip_vit_b32", context_length=32, pretrained=False, device='cpu') >>> model.__class__.__name__ 'CLIP4Clip'