fix: external lora

This commit is contained in:
nick 2024-04-24 23:27:01 -07:00
parent 810aec5135
commit b4c27bbbea
2 changed files with 28 additions and 19 deletions

View File

@ -16,8 +16,8 @@ class ComfyUIDeployExternalLora:
), ),
}, },
"optional": { "optional": {
"default_lora_name": (folder_paths.get_filename_list("loras"), ), "default_lora_name": (folder_paths.get_filename_list("loras"),),
} },
} }
RETURN_TYPES = (folder_paths.get_filename_list("loras"),) RETURN_TYPES = (folder_paths.get_filename_list("loras"),)
@ -32,23 +32,29 @@ class ComfyUIDeployExternalLora:
import os import os
import uuid import uuid
if input_id: if default_lora_name.startswith("http"):
if input_id.startswith('http'): unique_filename = str(uuid.uuid4()) + ".safetensors"
unique_filename = str(uuid.uuid4()) + ".safetensors" print(unique_filename)
print(unique_filename) print(folder_paths.folder_names_and_paths["loras"][0][0])
print(folder_paths.folder_names_and_paths["loras"][0][0]) destination_path = os.path.join(
destination_path = os.path.join(folder_paths.folder_names_and_paths["loras"][0][0], unique_filename) folder_paths.folder_names_and_paths["loras"][0][0], unique_filename
print(destination_path) )
print("Downloading external lora - " + input_id + " to " + destination_path) print(destination_path)
response = requests.get(input_id, headers={'User-Agent': 'Mozilla/5.0'}, allow_redirects=True) print("Downloading external lora - " + input_id + " to " + destination_path)
with open(destination_path, 'wb') as out_file: response = requests.get(
out_file.write(response.content) input_id,
return (unique_filename,) headers={"User-Agent": "Mozilla/5.0"},
else: allow_redirects=True,
return (input_id,) )
with open(destination_path, "wb") as out_file:
out_file.write(response.content)
return (unique_filename,)
else:
print(f"using lora: {default_lora_name}")
return (default_lora_name,)
return (default_lora_name,)
NODE_CLASS_MAPPINGS = {"ComfyUIDeployExternalLora": ComfyUIDeployExternalLora} NODE_CLASS_MAPPINGS = {"ComfyUIDeployExternalLora": ComfyUIDeployExternalLora}
NODE_DISPLAY_NAME_MAPPINGS = {"ComfyUIDeployExternalLora": "External Lora (ComfyUI Deploy)"} NODE_DISPLAY_NAME_MAPPINGS = {
"ComfyUIDeployExternalLora": "External Lora (ComfyUI Deploy)"
}

View File

@ -137,6 +137,9 @@ def apply_inputs_to_workflow(workflow_api: Any, inputs: Any, sid: str = None):
if (value["class_type"] == "ComfyUIDeployExternalImageBatch"): if (value["class_type"] == "ComfyUIDeployExternalImageBatch"):
value['inputs']["images"] = new_value value['inputs']["images"] = new_value
if value["class_type"] == "ComfyUIDeployExternalLora":
value["inputs"]["default_lora_name"] = new_value
def send_prompt(sid: str, inputs: StreamingPrompt): def send_prompt(sid: str, inputs: StreamingPrompt):
# workflow_api = inputs.workflow_api # workflow_api = inputs.workflow_api