Coder Social home page Coder Social logo

About beard model about hisd HOT 14 CLOSED

imlixinyang avatar imlixinyang commented on September 25, 2024
About beard model

from hisd.

Comments (14)

imlixinyang avatar imlixinyang commented on September 25, 2024

Hi, @lovejing0306, I'm sorry to infer you that the beard model has been unavailable since the training machine has been broken. But you can get it by simply modify the preprocessor and config file. It wouldn't take long for even only one GPU.
If you have any questions for you training, please contract me again.

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

Hi, @lovejing0306, I'm sorry to infer you that the beard model has been unavailable since the training machine has been broken. But you can get it by simply modify the preprocessor and config file. It wouldn't take long for even only one GPU. If you have any questions for you training, please contract me again.

Thanks for your reply, I will try it .

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

Hi, @lovejing0306, I'm sorry to infer you that the beard model has been unavailable since the training machine has been broken. But you can get it by simply modify the preprocessor and config file. It wouldn't take long for even only one GPU. If you have any questions for you training, please contract me again.

Hi, I am sorry to bother you. I want to remove beard in face. So I modify the preprocessor and config file as below:

preprocessor:

parser = argparse.ArgumentParser()
parser.add_argument('--img_path', type=str, default=None)
parser.add_argument('--label_path', type=str)
parser.add_argument("--target_path", type=str)
parser.add_argument("--start", type=int, default=3002)
parser.add_argument("--end", type=int, default=30002)
opts = parser.parse_args()

target_path = opts.target_path

os.makedirs(target_path, exist_ok=True)

Tags_Attributes = {
    # 'Bangs': ['with', 'without'],
    # 'Eyeglasses': ['with', 'without'],
    # 'HairColor': ['black', 'blond', 'brown'],
    'Beard': ['with', 'without'],
}

for tag in Tags_Attributes.keys():
    for attribute in Tags_Attributes[tag]:
        open(os.path.join(target_path, f'{tag}_{attribute}.txt'), 'w')

# celeba-hq
celeba_imgs = opts.img_path
celeba_label = opts.label_path

with open(celeba_label) as f:
    lines = f.readlines()

for line in tqdm.tqdm(lines[opts.start:opts.end]):
    line = line.split()
    # filename = os.path.join(os.path.abspath(celeba_imgs), line[0])
    filename = line[0]

    # Use only gender and age as tag-irrelevant conditions. Add other labels if you want.
    if int(line[25]) == 1:
        with open(os.path.join(target_path, 'Beard_without.txt'), mode='a') as f:
            f.write(f'{filename} {line[21]} {line[40]}\n')
    elif int(line[25]) == -1:
        with open(os.path.join(target_path, 'Beard_with.txt'), mode='a') as f:
            f.write(f'{filename} {line[21]} {line[40]}\n')

the config file :

# logger options
image_save_iter: 1000         # How often do you want to save output images during training
snapshot_save_iter: 10000     # How often do you want to save trained models
log_iter: 10                  # How often do you want to log the training stats

# optimization options
total_iterations: 600000
batch_size: 8
num_workers: 1
weight_decay: 0
beta1: 0
beta2: 0.99
init: kaiming
lr_dis: 0.0001
lr_gen_mappers: 0.000001
lr_gen_others: 0.0001

# 
adv_w: 1
sty_w: 1
rec_w: 1

style_dim: 256
noise_dim: 32

discriminators:
  # No normalization (Attribute-specific)
  channels: [32, 64, 128, 256, 512, 512, 512]
extractors:
  # No normalization (Tag-specific)
  channels: [32, 64, 128, 256, 512, 512, 512]
encoder:
  # Instance Normalization (Shared)
  channels: [64, 128, 256]
translators:
  # Adaptive Instance Normalization (Tag-specific)
  channels: [64, 64, 64, 64, 64, 64, 64, 64]
decoder:
   # Instance Normalization (Shared)
  channels: [256, 128, 64]
mappers:
  # No normalization (Attribute-specific)
  # Last num of pre_channels should be equal to the first num of post_channels
  pre_channels: [256, 256, 256]
  post_channels: [256, 256, 256]

img_dir: /datasets/face_parsing/CelebAMask-HQ/CelebA-HQ-img-512
tags:
  -
    name: Beard
    tag_irrelevant_conditions_dim: 2
    attributes:
      -
        name: 'with'
        filename: /datasets/face_parsing/CelebAMask-HQ/Beard_with.txt
      -
        name: 'without'
        filename: /datasets/face_parsing/CelebAMask-HQ/Beard_without.txt

# data options
input_dim: 3                  # number of image channels
new_size: 256                 # first resize the shortest image side to this size
crop_image_height: 256        # random crop image of this height
crop_image_width: 256         # random crop image of this width

Can you tell me, the preprocessor and config file is right ?

from hisd.

imlixinyang avatar imlixinyang commented on September 25, 2024

I think they are right and you can have a try to train with them~

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

I think they are right and you can have a try to train with them~

Hi, bother you again. I use the preprocessor and config file in my training code, but I meet two questions.

Question 1, the training visual quality is not really well, only few images implement the transfer from beard to no beard.

Question 2, the training visual quality get worse from 100000 steps.

I save the visual image in baidu cloud. Can you give me some advice ?

链接: https://pan.baidu.com/s/1HGcRhnIkWpdyMJ4NHJ5XCQ 提取码: fhh7

I am looking forward to your reply.

from hisd.

imlixinyang avatar imlixinyang commented on September 25, 2024

I think there are some points you can try:

  1. turn off the ALI part in discriminator by setting s[:] = 0 after
    def forward(self, x, s, y, i):
  2. since the images with beard are always male, modify the preprocess file to:
    if int(line[25]) == 1 and int(line[25]) == 1:
        with open(os.path.join(target_path, 'Beard_without.txt'), mode='a') as f:
            f.write(f'{filename} {line[40]}\n')
    elif int(line[25]) == -1 and int(line[25]) == 1:
        with open(os.path.join(target_path, 'Beard_with.txt'), mode='a') as f:
            f.write(f'{filename} {line[40]}\n')

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

Thanks for your advice @imlixinyang , I want to confirm these points with you.

About 1, I update the code as below, is right ?

def forward(self, x, s, y, i):
        s[:] = 0
        f = self.conv(x)
        fsy = torch.cat([f, tile_like(s, f), tile_like(y, f)], 1)
        return self.fcs[i](fsy).view(f.size(0), 2, -1)

About 2, remove the female samples from the dataset ?

from hisd.

imlixinyang avatar imlixinyang commented on September 25, 2024

Yes. Please have a try and tell me the results.

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

Yes. Please have a try and tell me the results.

OK, thanks. I prepared two sets of experiments. The first is remove female samples, second is remove female samples + update code s[:] = 0.

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

Hi, I am coming @imlixinyang .
I spent two weeks for "remove female samples" and "remove female samples + update code s[:] = 0".

The first set of experiments is "remove female samples" , the intermediate results in this link 链接: https://pan.baidu.com/s/1D8N8qqwrXB6qOueaBIwL0A 提取码: tab0

I found that there is a color deviation by view the training visual quality in the first set of experiments.

The second set of experiment is "remove female samples + update code s[:] = 0", the intermediate results in this link 链接: https://pan.baidu.com/s/1Ui6gABqD4GVFODxJrgv8wg 提取码: n87a

By setting s[:] = 0, the color deviation problem disappeared. But there are new questions, I summarize the problems as follow:

  1. some results show the identity information of person is changed
  2. some results show the image information is not well reconstructed
  3. the transfer results is not good enough

Can you give me some advice about improve generation quality ?

from hisd.

imlixinyang avatar imlixinyang commented on September 25, 2024

Thank you for your sharing results. In the rebuttal of HiSD, we also conduct experiments for beard and the results for latent-guided tasks are:
image
By removing female samples and updating code s[:] = 0, I think most of our settings are the same but you get unsatisfying results, especially for reference-guided task. In my training, HiSD is always trained with multiple tag and I suspect that the joint training of other tags may help the disentanglement and quality. Removing female examples severely decreases the number of images, which may be a major problem of beard model. Maybe you could use two more tags to see if it would help (not sure).
Any further experiments and questions are welcomed here and I would try my best to help you. @lovejing0306

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

Thanks for your reply.
I am very interested in your work, so I want to have a deeply discussion with you. Would you mind adding my wechat (my ID: lovejing0306) ?

Looking forward for reply. @imlixinyang

from hisd.

zhushuqi2333 avatar zhushuqi2333 commented on September 25, 2024

hello, after modified s[:] = 0, I met a problem,
image
Have you ever met this before? Looking forward to your replay!

from hisd.

lovejing0306 avatar lovejing0306 commented on September 25, 2024

hello, after modified s[:] = 0, I met a problem, image Have you ever met this before? Looking forward to your replay!

If you want to set s[:] = 0, you should write the code 's = torch.zeros_like(s)'

from hisd.

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.