Skip to content

Integration of ImageBind and StableUnCLIPImg2ImgPipeline for audio2image generation #3444

Open

Description

@Zeqiang-Lai

Model/Pipeline/Scheduler description

For anyone who need, here is a simple demo to illustrate how to integrate ImageBind and StableUnCLIPImg2ImgPipeline for audio2image generation.

Open source status

  • The model implementation is available
  • The model weights are available (Only relevant if addition is not a scheduler).

Provide useful links for the implementation

See also, https://github.com/Zeqiang-Lai/Anything2Image

import imagebind
import torch
from diffusers import StableUnCLIPImg2ImgPipeline

# construct models
device = "cuda:0" if torch.cuda.is_available() else "cpu"
pipe = StableUnCLIPImg2ImgPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-1-unclip", torch_dtype=torch.float16, variation="fp16"
)
pipe = pipe.to(device)

model = imagebind.imagebind_huge(pretrained=True)
model.eval()
model.to(device)

# generate image
with torch.no_grad():
    audio_paths=["assets/wav/bird_audio.wav"]
    embeddings = model.forward({
        imagebind.ModalityType.AUDIO: imagebind.load_and_transform_audio_data(audio_paths, device),
    })
    embeddings = embeddings[imagebind.ModalityType.AUDIO]
    images = pipe(image_embeds=embeddings.half()).images
    images[0].save("bird_audio.png")

Activity

  1. patrickvonplaten commented on May 16, 2023

    @patrickvonplaten
    Contributor

    Looks cool!

  2. sayakpaul commented on Jun 1, 2023

    @sayakpaul
    Member

    @patrickvonplaten I believe this code example provided here is already a good one, no? Might make sense to add a doc instead of a pipeline or community example IMO.

    @Zeqiang-Lai would you be interested in doing that? Happy to help :)

  3. Zeqiang-Lai commented on Jun 1, 2023

    @Zeqiang-Lai
    Author

    Oh,sure. I would like to help for that, but where should I start?

  4. sayakpaul commented on Nov 22, 2024

    @sayakpaul
    Member

    I think this could be added to the examples/research_projects directory. Sorry for the late reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions