Run this model with HF Jobs
Run InstantX/SD3.5-Large-IP-Adapter on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/InstantX/SD3.5-Large-IP-Adapter. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/InstantX/SD3.5-Large-IP-Adapter on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use InstantX/SD3.5-Large-IP-Adapter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use InstantX/SD3.5-Large-IP-Adapter with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("InstantX/SD3.5-Large-IP-Adapter", 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
- Local Apps Settings
- Draw Things
- DiffusionBee
Upload 2 files
Browse filesAs part of the integration to diffusers (see [PR](https://github.com/huggingface/diffusers/pull/9987)), we can simplify things changing the ip-adapter state dict keys here, instead of adding extra conversion code. The "ip-adapter.bin" file is updated to conform with the integration, and I also uploaded the equivalent in parameters in safetensors. The PR is nearly finished, so shouldn't be long until the integration is merged. The new checkpoints were obtained with the following code:
```python
import torch
from safetensors.torch import save_file
from diffusers.utils import _get_model_file
from diffusers.models.modeling_utils import load_state_dict
# Get weights from the hub
model_file = _get_model_file(
"InstantX/SD3.5-Large-IP-Adapter",
weights_name="ip-adapter.bin",
)
state_dict = load_state_dict(model_file)
# ip_adapter stays the same
safetensors_dict = {f"ip_adapter.{key}": value for key, value in state_dict["ip_adapter"].items()}
# image_proj to diffusers
for key, value in state_dict["image_proj"].items():
if key.startswith("layers."):
idx = key.split(".")[1]
key = key.replace(f"layers.{idx}.0.norm1", f"layers.{idx}.ln0")
key = key.replace(f"layers.{idx}.0.norm2", f"layers.{idx}.ln1")
key = key.replace(f"layers.{idx}.0.to_q", f"layers.{idx}.attn.to_q")
key = key.replace(f"layers.{idx}.0.to_kv", f"layers.{idx}.attn.to_kv")
key = key.replace(f"layers.{idx}.0.to_out", f"layers.{idx}.attn.to_out.0")
key = key.replace(f"layers.{idx}.1.0", f"layers.{idx}.adaln_norm")
key = key.replace(f"layers.{idx}.1.1", f"layers.{idx}.ff.net.0.proj")
key = key.replace(f"layers.{idx}.1.3", f"layers.{idx}.ff.net.2")
key = key.replace(f"layers.{idx}.2.1", f"layers.{idx}.adaln_proj")
safetensors_dict[f"image_proj.{key}"] = value
# Save safetensors
save_file(safetensors_dict, "ip-adapter.safetensors")
# ip_adapter stays the same
torch_new_dict = {"ip_adapter": state_dict["ip_adapter"], "image_proj": {}}
# image_proj to diffusers
for key, value in state_dict["image_proj"].items():
if key.startswith("layers."):
idx = key.split(".")[1]
key = key.replace(f"layers.{idx}.0.norm1", f"layers.{idx}.ln0")
key = key.replace(f"layers.{idx}.0.norm2", f"layers.{idx}.ln1")
key = key.replace(f"layers.{idx}.0.to_q", f"layers.{idx}.attn.to_q")
key = key.replace(f"layers.{idx}.0.to_kv", f"layers.{idx}.attn.to_kv")
key = key.replace(f"layers.{idx}.0.to_out", f"layers.{idx}.attn.to_out.0")
key = key.replace(f"layers.{idx}.1.0", f"layers.{idx}.adaln_norm")
key = key.replace(f"layers.{idx}.1.1", f"layers.{idx}.ff.net.0.proj")
key = key.replace(f"layers.{idx}.1.3", f"layers.{idx}.ff.net.2")
key = key.replace(f"layers.{idx}.2.1", f"layers.{idx}.adaln_proj")
torch_new_dict["image_proj"][key] = value
# Save torch pickle
torch.save(torch_new_dict, "ip-adapter.bin")
```
Files changed (2)
- ip-adapter.bin+2-2
- ip-adapter.safetensorsAdded+3
123version https://git-lfs.github.com/spec/v1oid sha256:9fe54774aa528e712d9145ff6a59dd93b1fcf1d5935304feffd980ae6d42ae03size 1595970439123version https://git-lfs.github.com/spec/v1oid sha256:a12562389f6b4ed56e58077c21aff7c8298401d4de376204bfe04c5d8e2f6aa2size 1595963463
123version https://git-lfs.github.com/spec/v1oid sha256:7605332eeba0194f62bbe46deb62e5f1ee71a522cd38bba543d907a677d94949size 1595885744