pycivitai.client.resource
list_models_by_name
- pycivitai.client.resource.list_models_by_name(model_name: str, creator: Optional[str] = None, strict: bool = False) List[dict] [source]
Retrieve model information from the CiviTAI API based on the given model name.
- Parameters:
model_name (str) – The name of the model to retrieve information for.
creator (Optional[str]) – Name of creator.
None
means anyone.strict (bool) – Strict filter all the results or not. Default is
False
.
- Returns:
The list of dictionaries containing the searched model information.
- Return type:
dict
find_model_by_name
- pycivitai.client.resource.find_model_by_name(model_name: str, creator: Optional[str] = None) dict [source]
Retrieve model information from the CiviTAI API based on the given model name.
- Parameters:
model_name (str) – The name of the model to retrieve information for.
creator (Optional[str]) – Name of creator.
None
means anyone.
- Returns:
The dictionary containing the model information.
- Return type:
dict
- Raises:
ModelNotFound – If the model with the given name is not found.
ModelFoundDuplicated – If multiple models with the same name are found.
find_model_by_id
- pycivitai.client.resource.find_model_by_id(model_id) dict [source]
Retrieve model information from the CiviTAI API based on the given model ID.
- Parameters:
model_id (int) – The ID of the model to retrieve information for.
- Returns:
The dictionary containing the model information.
- Return type:
dict
- Raises:
ModelNotFound – If the model with the given ID is not found.
find_model
- pycivitai.client.resource.find_model(model_name_or_id: Union[int, str], creator: Optional[str] = None) dict [source]
Find model information from the CiviTAI API based on the given model name or ID.
- Parameters:
model_name_or_id (Union[int, str]) – The name or ID of the model to retrieve information for.
creator (Optional[str]) – Name of creator.
None
means anyone.
- Returns:
The dictionary containing the model information.
- Return type:
dict
- Raises:
TypeError – If the model name or ID is not a valid integer or string.
find_version
- pycivitai.client.resource.find_version(model_data: dict, version: Optional[Union[int, str]] = None)[source]
Find the specified version from the model data.
- Parameters:
model_data (dict) – The model data containing version information.
version (Union[int, str, None]) – The version ID or name to find. If None, the first version will be chosen.
- Returns:
The dictionary containing the selected version information.
- Return type:
dict
- Raises:
ModelVersionNotFound – If the specified version is not found.
ModelVersionDuplicated – If multiple versions with the same ID or name are found.
find_resource
- pycivitai.client.resource.find_resource(model_data: dict, version_data: dict, pattern: Optional[str] = None)[source]
Find the specified resource from the model and version data.
- Parameters:
model_data (dict) – The model data containing version information.
version_data (dict) – The version data containing resource information.
pattern (str) – The pattern to match the resource filename. If None, the primary resource will be chosen.
- Returns:
The resource information.
- Return type:
- Raises:
TypeError – If the pattern of the resource is not a valid string.
ResourceNotFound – If the specified resource is not found.
ResourceDuplicated – If multiple resources with the same name are found.