(model_type='FLUX', model_path='FLUX.1-dev')
| 154 | model_dict = {} |
| 155 | |
| 156 | def load_model(model_type='FLUX', model_path='FLUX.1-dev'): |
| 157 | global model_dict |
| 158 | model_key = f"{model_type}:{model_path}" |
| 159 | if model_key in model_dict: |
| 160 | return model_dict[model_key] |
| 161 | model_path = os.path.join(config["model_config"][model_type]["model_folder"], model_path) |
| 162 | model_manager = ModelManager(torch_dtype=torch.bfloat16, device="cuda", model_id_list=["FLUX.1-dev"]) |
| 163 | model_manager.load_lora( |
| 164 | download_customized_models( |
| 165 | model_id="DiffSynth-Studio/Eligen", |
| 166 | origin_file_path="model_bf16.safetensors", |
| 167 | local_dir="models/lora/entity_control", |
| 168 | ), |
| 169 | lora_alpha=1, |
| 170 | ) |
| 171 | pipe = config["model_config"][model_type]["pipeline_class"].from_model_manager(model_manager) |
| 172 | model_dict[model_key] = model_manager, pipe |
| 173 | return model_manager, pipe |
| 174 | |
| 175 | |
| 176 | with gr.Blocks() as app: |
no test coverage detected