Git Product home page Git Product logo

Comments (3)

pkhungurn avatar pkhungurn commented on May 12, 2024 1

Please check the RGB channels of the PNG file you exported from Photoshop. One of the condition for the input is that if A = 0, then RGB should be (0,0,0). When you remove the background using Photoshop, it is most likely the case that it just sets the alpha channel to 0, leaving the RGB channel as white. Please clear the RGB channels.

from talking-head-anime-demo.

HelixNGC7293 avatar HelixNGC7293 commented on May 12, 2024

Hi, Great job! Thanks for your sharing.

The method works well in given examples, however, I get a worse result when using the picture generated by waifulabs.com.

The pic is from waifulabs.com, and I convert it to RGBA format with Photoshop. I alignment the face to 128x128 center box and resize the pic to 256x256
image

the results look like this:
image

I believe it should be something wrong at the alignment,
so could you please share the alignment code?

Here my code of alignment:


from PIL import Image
import numpy as np
import cv2

def alinment_image_lowhigh(image, high, low, save_path=None):
    '''
    :param image: image path
    :param high: the bigger hight cordinate
    :param low:  the smaller hight cordinate
    :param save_path:
    :return:
    '''
    image = np.array(Image.open(image))
    size = np.array(image.shape[:2])

    # adjust face scale to 128
    h = high - low
    scale = 128 / h
    high, low = high * scale, low * scale
    hc = (high + low) / 2
    image = np.array(Image.fromarray(image).resize((int(size[0] * scale), int(size[1] * scale))))

    # move face to center
    size = np.array(image.shape[:2])
    delta = size[0] / 2 - hc
    M = np.float32([[1, 0, 0], [0, 1, delta]])
    image = cv2.warpAffine(image, M, (size[1], size[0]), borderValue=(255, 255, 255))
    image = Image.fromarray(image)
    image = image.resize(256, 256)
    if save_path is not None: image.save(save_path)
    image.show()

Thanks, your reply will be appreciated.

Hello BaldrLector~
You can use Gimp to export your PNG file (uncheck 'saving color value from trans pixs' when saving)
It should work!

from talking-head-anime-demo.

BaldrLector avatar BaldrLector commented on May 12, 2024

Please check the RGB channels of the PNG file you exported from Photoshop. One of the condition for the input is that if A = 0, then RGB should be (0,0,0). When you remove the background using Photoshop, it is most likely the case that it just sets the alpha channel to 0, leaving the RGB channel as white. Please clear the RGB channels.

You are right, after clear the RGB channels, the method work well.
Thanks!

from talking-head-anime-demo.

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.