fofr / cog-comfyui

Run ComfyUI with an API
https://replicate.com/fofr/any-comfyui-workflow
MIT License
544 stars 124 forks source link

How can I add more weights and custom nodes myself? #35

Closed offchan42 closed 4 months ago

offchan42 commented 8 months ago

First of all, I would like to say that this project is wonderful. But I think it's unsustainable to expect the repo maintainer to keep adding more weights and custom nodes as requested by users.

Is there a document describing how to add custom weights and nodes? If there aren't, it'd be great if you can write it.

Before writing the document, I also appreciate if you explain briefly how to add custom weights and nodes here. Thanks!

fofr commented 8 months ago

Hey, good idea.

Custom nodes

The short version on adding custom nodes

Caveat: Some custom nodes do on demand downloading of model weights themselves – you might be ok with this, but in the repo I've tried to remove all external dependencies – this is where it gets a bit more complex.

Simple PR example: https://github.com/fofr/cog-comfyui/pull/20 Complex PR example where I had to do work to make the nodes work properly in a docker env: https://github.com/fofr/cog-comfyui/pull/22

Weights

drommerkiller commented 7 months ago

Hey, good idea.

Custom nodes

The short version on adding custom nodes

That does not seem to work. I did all that and pushed model to replicate to my model page, but it does not find any if the custom nodes that i added before running the cog script. Nor does any of the checkpoints be added as it still tries to find them from where the rest are. Adding direct links to models does not work either as they are not "in the list".

Any pointers beyond that how to mod this to get own custom_nodes and checkpoints?

DrakenZA commented 6 months ago

Im also having an issue with this.

I put aniverse_thxEd14Pruned.safetensors inside comfyui/models/checkpoints before making the cog, and i removed the .safetensors and model dir dockerignore entries. But Weights_downloader complains they are not on the list.

Edit: Some useful information for anyone bumping into this.

Custom SD Checkpoints

bluematter commented 5 months ago

Couldnt you just add a custom map where we can rewrite the key with full path?

def _generate_weights_map(self, keys, dest):
        custom_weights = {
            "zavychromaxl_v31.safetensors": "https://custompath.com/zavychromaxl_v31.safetensors.tar",
        }

        return {
            key: {
                "url": custom_weights[key] if key in custom_weights else f"{BASE_URL}/{dest}/{key}.tar",
                "dest": f"{BASE_PATH}/{dest}"
            }
            for key in keys
        }
drommerkiller commented 5 months ago

It would be really nice if models could be loaded with direct link without getting the "not on the list" error.

drommerkiller commented 5 months ago

I have now tried everything and there seems to be no way to add more models or nodes. No matter what you have in the cog image, it will always load every node and model from replicate. No matter if you edit the weighs.json and add new model names there, that is not the file what it reads as adding model names to that will not carry on to replicate.

Fofr has given good instructions how to reduce and remove nodes and models to create custom model, but that does not help as we need to add models.

This is now more important than ever as Replicate still has cache loading issues. It just downloaded 120mb motion lora file for two minutes. That motion lora was in the cog model i pushed, but it just ignored it. I have my own motion loras that i want to use but have not found any way to do that. Add to model and get error, add direct link and get error.

How to edit weights.json so it will not give 'not in the list' error so we could use direct links for models? Even better would be to include them in the model, but i don't think that will happen soon.

dhanushreddy291 commented 4 months ago

hey @fofr, it would be really amazing if you can record a video/or a blog, showing how to deploy 1-2 workflows from: https://openart.ai/workflows/all

It would be really very helpful, currently something or other fails and getting new errors.

fofr commented 4 months ago

I have something coming really soon that will let you do this from a civit or HF link

fofr commented 4 months ago

Ok, I've shipped a new feature that lets you upload:

You need to use HuggingFace or CivitAI urls

https://replicate.com/fofr/any-comfyui-workflow/train

Check the training logs to see what filenames to use in your workflow JSON. For example:

Downloading from HuggingFace:
...
Size of the tar file: 217.88 MB
====================================
When using your new model, use these filenames in your JSON workflow:
araminta_k_midsommar_cartoon.safetensors
promeG commented 4 months ago

Im also having an issue with this.

I put aniverse_thxEd14Pruned.safetensors inside comfyui/models/checkpoints before making the cog, and i removed the .safetensors and model dir dockerignore entries. But Weights_downloader complains they are not on the list.

Edit: Some useful information for anyone bumping into this.

Custom SD Checkpoints

  • Place them in the correct models folder in the comfyui folder in the cog folder.
  • Edit .dockerignore, and comment out the ignores for safetensors and ckpts
  • Edit .dockerignore, and comment out the ignores for ComfyUI/models
  • Add the full name of the checkpoint you just added, to 'weights.json' file in the correct format.

In addition to the steps above, please run 'sudo cog build --no-cache' to create a new cog image containing new models.