Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Aquiles-ai_Aquiles-Image /aquilesimage /runtime /lora.py
| from aquilesimage.models import LoRAConfig | |
| from diffusers import DiffusionPipeline | |
| import logging | |
| from aquilesimage.utils import setup_colored_logger | |
| logger = setup_colored_logger("Aquiles-LoRA-Loader", logging.INFO) | |
| def loadLoRA(pipeline: DiffusionPipeline, conf: LoRAConfig): | |
| try: | |
| if conf.prefix is None: | |
| pipeline.load_lora_weights( | |
| conf.repo_id, | |
| weight_name=conf.weight_name, | |
| adapter_name=conf.adapter_name, | |
| ) | |
| else: | |
| component = getattr(pipeline, conf.prefix, None) | |
| if component is None: | |
| logger.error(f"X Pipeline has no component '{conf.prefix}'.") | |
| logger.info("There was an error loading LoRA. Only the base model is loaded.") | |
| return False | |
| component.load_lora_adapter( | |
| conf.repo_id, | |
| weight_name=conf.weight_name, | |
| adapter_name=conf.adapter_name, | |
| prefix=conf.prefix, | |
| ) | |
| logger.info(f"LoRA '{conf.adapter_name}' loaded successfully from '{conf.repo_id}'.") | |
| return True | |
| except Exception as e: | |
| logger.error(f"X Error loading LoRA: {e}") | |
| logger.info("There was an error loading LoRA. Only the base model is loaded.") | |
| return False |
Xet Storage Details
- Size:
- 1.33 kB
- Xet hash:
- f74641ee873828f498a0556f541014b809d6a27c8acc761e68df0f55f191e9e5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.