-
I wanted to add support for an a1111 merger extension, but I can't figure out the model loading part on a1111 it was just sd_models.load_model(sd_models.CheckpointInfo(model_path)) in forge I tried /sdapi/v1/options {sd_model_checkpoint: modelname.safetensors} which for some reason says it can't find the model even though it's there at the time the error appears
and currently I was trying with a custom function in the extension like this def load_model_forge(model_path: str):
"""Custom model loading function for Forge."""
try:
# 1. Unload existing model
memory_management.unload_all_models()
memory_management.soft_empty_cache()
gc.collect()
# 2. Prepare model data
checkpoint_info = sd_models.CheckpointInfo(model_path)
additional_state_dicts = [] # Modify as needed based on your requirements
# 3. Load the model
sd_model = forge_loader(checkpoint_info.filename, additional_state_dicts=additional_state_dicts)
# 4. Initialize model attributes
sd_model.extra_generation_params = {}
sd_model.comments = []
sd_model.sd_checkpoint_info = checkpoint_info
sd_model.filename = checkpoint_info.filename
sd_model.sd_model_hash = checkpoint_info.calculate_shorthash()
# 5. Trigger callbacks
script_callbacks.model_loaded_callback(sd_model)
# Update the shared.sd_model object in Forge
shared.sd_model = sd_model
logger.info(f"Model loaded successfully from: {model_path} in Forge")
except Exception as e:
logger.error(f"Error loading model in Forge: {e}", exc_info=True)
raise Which does load the model, but the subsequent generation request makes images that are burned in greyscale and have no discernible features. The same model will make normal images when manually generating in the ui, and same for when just sending the generate request, so I assume it's related to the loading part. if someone knows pls help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
current logic is so if you do not need to have the model instance immediately, you can just write If you must have model instance immediately, you can just write |
Beta Was this translation helpful? Give feedback.
Actually I think this works. Adding
refresh_model_loading_parameters
seems to have fixed it so far.Thanks for the clues
edit ^ this was almost right, had to use
ch…