Code Monkey home page Code Monkey logo

Comments (3)

aycaecemgul avatar aycaecemgul commented on July 28, 2024

please add a reproducible code, probably there is a mistake about rgb conversion?

from ip-adapter.

guoti777 avatar guoti777 commented on July 28, 2024

please add a reproducible code, probably there is a mistake about rgb conversion?

thanks! Here is the transform code:

  1. image:
        self.transform = transforms.Compose([
            transforms.Resize(self.size, interpolation=transforms.InterpolationMode.BILINEAR),
            transforms.CenterCrop(self.size),
            transforms.ToTensor(),
            # transforms.Normalize([-1], [1]),
            transforms.Normalize([0.5], [0.5]),
            # transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
        ])
        raw_image = Image.open(os.path.join(self.image_root_path, image_file))
        image = self.transform(raw_image.convert("RGB"))

2: faceid_embeds:

                image = cv2.imread(img_path)
                faces = app.get(image)
                if len(faces) == 1:
                    faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
                    torch.save(faceid_embeds, bin_path)
  1. encode:
    images = torch.stack([example["image"] for example in data])
    face_id_embed = torch.stack([example["face_id_embed"] for example in data])
                    latents = vae.encode(batch["images"].to(accelerator.device, dtype=weight_dtype)).latent_dist.sample()
                    latents = latents * vae.config.scaling_factor
                image_embeds = batch["face_id_embed"].to(accelerator.device, dtype=weight_dtype)
                with torch.no_grad():
                    encoder_hidden_states = text_encoder(batch["text_input_ids"].to(accelerator.device))[0]
                noise_pred = ip_adapter(noisy_latents, timesteps, encoder_hidden_states, image_embeds)

from ip-adapter.

alexblattner avatar alexblattner commented on July 28, 2024

it has to do with the convertion between cv2 and PIL. the color mapping is different

from ip-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.