Code Monkey home page Code Monkey logo

Comments (4)

GoGoDuck912 avatar GoGoDuck912 commented on July 2, 2024

Exactly. Each pixel in the annotation image is the label_id.
Each line in the trian_id.txt represents the img_name prefix of each image in the training set.
If you want to train on a customize dataset, you need to also corresponding modifications for the dataset.py based on your own need (usually minor modification).

from self-correction-human-parsing.

SajjadAemmi avatar SajjadAemmi commented on July 2, 2024

can you explain what should i do for train step by step?
first run witch file? and then?
thanks

from self-correction-human-parsing.

VyBui avatar VyBui commented on July 2, 2024

@SajjadAemmi please follow the data structure of LIP (Look into people) dataset.

Simply put you need a train_images (original images) folder with train_id.txt accordingly mapping with the image's name. The same applies to validation_images.

However, for the train/Val segmentations there is a little bit trickier to get it. You have to have the labels (ground truth) of your definitions and then convert it to the class images before mapping its name to val_id.txt.

The default LIP Val/train segmentations have 19 classes which mean each class represents a specific object.

Suppose your segmentation is the bellow image:

0a0f64ffdb6aa45b0f445b217b05a6c6

There are 11 classes in that color image, each one represents for an object in the picture (head, top, bottom .. etc. You can define your own objects/classes.)

Each class has a different color, for example, the hair has the value (35, 125, 200) in BGR. What you need to do is convert that specific color to the class.

Here is the snipped code that helps you convert the color to class:

`
COLOR_PICKER_THRESHOLD = 20
def convert_color_image_to_class_image(img: np.ndarray, LABEL_COLORS: np.array) -> np.ndarray:
'''Args:
img: Color image (np.adarray)

Returns: Classes image

'''
assert img is not None, "This is the empty image!"
class_image = np.zeros((img.shape[0], img.shape[1], len(LABEL_COLORS)), np.uint8)

class_image = np.zeros((img.shape[0], img.shape[1], len(LABEL_COLORS)), np.uint8)

for i in range(1, len(LABEL_COLORS)):
    single_part = cv2.inRange(img, LABEL_COLORS[i] - COLOR_PICKER_THRESHOLD,
                              LABEL_COLORS[i] + COLOR_PICKER_THRESHOLD)
    class_image[:, :, i] = single_part

class_image = np.argmax(class_image, axis=2)
class_image = np.uint8(class_image)

return class_image

`

you define the variable 'LABEL_COLORS' like below:
`
CLASS_COLOR = {
"hair": (0, 0, 0),
"other classes": (x, y, y)
}

LABEL_COLORS = np.array([CLASS_COLOR['hair'],
CLASS_COLOR['other classes"']],
dtype=np.float32)
`
Now the hair is the first class of the image which has the value of 0, then you feed both original image and segmentation image to the network with num_classes=11 and wait for the great and glorious work of @PeikeLi!

Thank @PeikeLi for make the training code available.

p/s: there is a minor issue in the training code that I have shared with @PeikeLi here: #17, go and fix it your self.

regards,

from self-correction-human-parsing.

SajjadAemmi avatar SajjadAemmi commented on July 2, 2024

@PeikeLi and @VyBui
thanks

from self-correction-human-parsing.

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.