Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def predict(
description="Input image, tar or zip file. Read guidance on workflows and input files here: https://github.com/fofr/cog-comfyui. Alternatively, you can replace inputs with URLs in your JSON workflow and the model will download them.",
default=None,
),
custom_lora_url: str = Input(
description="URL to a custom LoRA file to be downloaded.",
default=None,
),
return_temp_files: bool = Input(
description="Return any temporary files, such as preprocessed controlnet images. Useful for debugging.",
default=False,
Expand All @@ -121,6 +125,25 @@ def predict(
"""Run a single prediction on the model"""
self.comfyUI.cleanup(ALL_DIRECTORIES)

if custom_lora_url:
downloader = WeightsDownloader()
local_filename = os.path.basename(custom_lora_url.split('?')[0])

# Create a separate weights map just for this download
custom_weights_map = {
local_filename: {
"url": custom_lora_url,
"dest": "ComfyUI/models/loras/"
}
}

# Download using the isolated weights map
downloader.download_if_not_exists(
local_filename,
custom_weights_map[local_filename]["url"],
custom_weights_map[local_filename]["dest"]
)

if input_file:
self.handle_input_file(input_file)

Expand Down