Instructions to use mhnakif/comfy2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use mhnakif/comfy2 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("mhnakif/comfy2", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| def merge_json_recursive(base, update): | |
| """Recursively merge two JSON-like objects. | |
| - Dictionaries are merged recursively | |
| - Lists are concatenated | |
| - Other types are overwritten by the update value | |
| Args: | |
| base: Base JSON-like object | |
| update: Update JSON-like object to merge into base | |
| Returns: | |
| Merged JSON-like object | |
| """ | |
| if not isinstance(base, dict) or not isinstance(update, dict): | |
| if isinstance(base, list) and isinstance(update, list): | |
| return base + update | |
| return update | |
| merged = base.copy() | |
| for key, value in update.items(): | |
| if key in merged: | |
| merged[key] = merge_json_recursive(merged[key], value) | |
| else: | |
| merged[key] = value | |
| return merged | |