Initializes the AigcModel helper. Args: model_path (str): The path of checkpoint/LoRA weight file or folder. aigc_type (str): AIGC model type. Recommended: 'Checkpoint', 'LoRA', 'VAE'. base_model_type (str): Vision foundation model type. Recommen
(
self,
aigc_type: str,
base_model_type: str,
model_path: str,
base_model_id: str = '',
tag: Optional[str] = 'v1.0',
description: Optional[str] = 'this is an aigc model',
cover_images: Optional[List[str]] = None,
path_in_repo: Optional[str] = '',
trigger_words: Optional[List[str]] = None,
official_tags: Optional[List[str]] = None,
model_source: Optional[str] = 'USER_UPLOAD',
base_model_sub_type: Optional[str] = '',
)
| 70 | } |
| 71 | |
| 72 | def __init__( |
| 73 | self, |
| 74 | aigc_type: str, |
| 75 | base_model_type: str, |
| 76 | model_path: str, |
| 77 | base_model_id: str = '', |
| 78 | tag: Optional[str] = 'v1.0', |
| 79 | description: Optional[str] = 'this is an aigc model', |
| 80 | cover_images: Optional[List[str]] = None, |
| 81 | path_in_repo: Optional[str] = '', |
| 82 | trigger_words: Optional[List[str]] = None, |
| 83 | official_tags: Optional[List[str]] = None, |
| 84 | model_source: Optional[str] = 'USER_UPLOAD', |
| 85 | base_model_sub_type: Optional[str] = '', |
| 86 | ): |
| 87 | """ |
| 88 | Initializes the AigcModel helper. |
| 89 | |
| 90 | Args: |
| 91 | model_path (str): The path of checkpoint/LoRA weight file or folder. |
| 92 | aigc_type (str): AIGC model type. Recommended: 'Checkpoint', 'LoRA', 'VAE'. |
| 93 | base_model_type (str): Vision foundation model type. Recommended values are in BASE_MODEL_TYPES. |
| 94 | tag (str, optional): Tag for the AIGC model. Defaults to 'v1.0'. |
| 95 | description (str, optional): Model description. Defaults to 'this is an aigc model'. |
| 96 | cover_images (List[str], optional): List of cover image URLs. |
| 97 | base_model_id (str, optional): Base model name. e.g., 'AI-ModelScope/FLUX.1-dev'. |
| 98 | path_in_repo (str, optional): Path in the repository. |
| 99 | trigger_words (List[str], optional): Trigger words for the AIGC Lora model. |
| 100 | official_tags (List[str], optional): Official tags for the AIGC model. Defaults to None. |
| 101 | model_source (str, optional): Source of the model. |
| 102 | `USER_UPLOAD`, `TRAINED_FROM_MODELSCOPE` or `TRAINED_FROM_ALIYUN_FC`. Defaults to 'USER_UPLOAD'. |
| 103 | base_model_sub_type (str, Optional): Sub vision foundation model type. Defaults to ''. e.g. `SD_1_5` |
| 104 | """ |
| 105 | self.model_path = model_path |
| 106 | self.aigc_type = aigc_type |
| 107 | self.base_model_type = base_model_type |
| 108 | self.tag = tag |
| 109 | self.description = description |
| 110 | self.model_source = model_source |
| 111 | self.base_model_sub_type = base_model_sub_type |
| 112 | # Process cover images - convert local paths to base64 data URLs |
| 113 | if cover_images is not None: |
| 114 | processed_cover_images = [] |
| 115 | for img in cover_images: |
| 116 | if isinstance(img, str): |
| 117 | # Check if it's a local file path (not a URL) |
| 118 | if not (img.startswith('http://') |
| 119 | or img.startswith('https://') |
| 120 | or img.startswith('data:')): |
| 121 | try: |
| 122 | # Convert local path to base64 data URL |
| 123 | processed_img = encode_media_to_base64(img) |
| 124 | processed_cover_images.append(processed_img) |
| 125 | logger.info('Converted local image to base64: %s', |
| 126 | os.path.basename(img)) |
| 127 | except (FileNotFoundError, ValueError) as e: |
| 128 | logger.warning( |
| 129 | 'Failed to process local image %s: %s. Using as-is.', |
nothing calls this directly
no test coverage detected