Giter Club home page Giter Club logo

fashionpedia-api's Introduction

Fashionpedia API

Fashionpedia is a new dataset which consists of two parts: (1) an ontology built by fashion experts containing 27 main apparel categories, 19 apparel parts, 294 fine-grained attributes and their relationships; (2) a dataset with 48k everyday and celebrity event fashion images annotated with segmentation masks and their associated per-mask fine-grained attributes, built upon the Fashionpedia ontology.

Check out our project page here and download the data at this link.

teaser

An illustration of the Fashionpedia dataset and ontology: (a) main garment masks; (b) garment part masks; (c) both main garment and garment part masks; (d) fine-grained apparel attributes; (e) an exploded view of the annotation diagram: the image is annotated with both instance segmentation masks (white boxes) and per-mask fine-grained attributes (black boxes); (f) visualization of the Fashionpedia ontology: we created Fashionpedia ontology and separate the concept of categories (yellow nodes) and attributes (blue nodes) in fashion. It covers pre-defined garment categories used by both Deepfashion2 and ModaNet. Mapping with DeepFashion2 also shows the versatility of using attributes and categories. We are able to present all 13 garment classes in DeepFashion2 with 11 main garment categories, 1 garment part, and 7 attributes.

With the introduction of the dataset, we explore the new task of instance segmentation with attribute localization. The proposed task requires both localizing an object and describing its properties, which unifies instance segmentation (detect and segment each object instance) and fine-grained visual attribute categorization (recognize one or multiple attributes).

This Fashionpedia API enables reading, and visualizing annotations, and evaluating results. Check out our two demos for more details.

Setup

via pip install

# create a new environment:
python3 -m venv env               # Create a virtual environment
source env/bin/activate           # Activate virtual environment

# step 1: install COCO API:
# Note: COCO API requires numpy to install. Ensure that you have numpy installed.
# e.g. pip install numpy
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'

# step 2: install Fashionpedia API via pip
pip install fashionpedia


# step 3: test. You can test that you have correctly installed the fashionpedia api
#       by running the following command inside the repo.
python test.py

# do your work ...

deactivate  # exit

via git clone

Clone the repo first and then do the following steps inside the repo:

# create a new environment:
python3 -m venv env               # Create a virtual environment
source env/bin/activate           # Activate virtual environment

# step 1: install COCO API:
# Note: COCO API requires numpy to install. Ensure that you have numpy installed.
# e.g. pip install numpy
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'

# step 2: install required packages
pip install -r requirements.txt

# step 3: test. You can test that you have correctly installed the fashionpedia api
#       by running the following command inside the repo.
python test.py
# do your work here...

deactivate  # exit

Evaluation

The evaluation code provide here can be used to measure results on the publicly available validation set. It computes multiple metrics describe below. We consider both localization constraint (IoU) and attributes prediction constraint (F1 score) when computing $AP$ and $AR$. This is an extension of the 12 metrics of COCO detection evaluation.

Average Precision  (AP)
    AP@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=all | maxDets=100]  # Primary metric
    AP@[ IoU=0.50      | F1=0.50:0.95 |area=all | maxDets=100]
    AP@[ IoU=0.75      | F1=0.50:0.95 |area=all | maxDets=100]
    AP@[ IoU=0.50:0.95 | F1=0.50      |area=all | maxDets=100]
    AP@[ IoU=0.50:0.95 | F1=0.75      |area=all | maxDets=100]
    AP@[ IoU=0.50      | F1=0.50      |area=all | maxDets=100]
    AP@[ IoU=0.50      | F1=0.75      |area=all | maxDets=100]
    AP@[ IoU=0.75      | F1=0.50      |area=all | maxDets=100]
    AP@[ IoU=0.75      | F1=0.75      |area=all | maxDets=100]
    AP@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=  s | maxDets=100]
    AP@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=  m | maxDets=100]
    AP@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=  l | maxDets=100]

Average Recall     (AR)
    AR@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=all | maxDets=  1]
    AR@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=all | maxDets= 10]
    AR@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=all | maxDets=100]
    AR@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=  s | maxDets=100]
    AR@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=  m | maxDets=100]
    AR@[ IoU=0.50:0.95 | F1=0.50:0.95 |area=  l | maxDets=100]

Additionally, we also provide metrics with only IoU constraint and only F1 thresholds constraint, for better understanding of the algorithm. See evaluation demo for more details.

Result format

The results format is similar to COCO format for object detection with additional attribute_ids filed. See evaluation demo and also loadRes() in Fashionpedia API.

Detection with bounding boxes and localized attributes prediction:

[{
    "image_id": int, 
    "category_id": int, 
    "attribute_ids": [int],
    "bbox": [x,y,width,height], 
    "score": float,
}]

Detection with segmentation masks and localized attributes prediction:

[{
    "image_id": int, 
    "category_id": int, 
    "attribute_ids": [int],
    "segmentation": RLE,
    "score": float,
}]

Attribute-Mask R-CNN Predictor Demo

For the task of instance segmentation with attribute localization, we present a strong baseline model named Attribute-Mask R-CNN that is built upon Mask R-CNN for Fashionpedia. Check out our predictior demo and paper for more details.

baseline

Pretrained Models

The 1). pretrained model ckpts and 2). training code including data conversion, model training and inference here.

Citing Fashionpedia

@inproceedings{jia2020fashionpedia,
  title={Fashionpedia: Ontology, Segmentation, and an Attribute Localization Dataset},
  author={Jia, Menglin and Shi, Mengyun and Sirotenko, Mikhail and Cui, Yin and Cardie, Claire and Hariharan, Bharath and Adam, Hartwig and Belongie, Serge}
  booktitle={European Conference on Computer Vision (ECCV)},
  year={2020}
}

Credit

Both fashionpedia and fashionpediaEval are sub-classes of COCO and COCOeval from PythonAPI for COCO. LVIS-API was also referenced during the development.

fashionpedia-api's People

Contributors

kmnp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fashionpedia-api's Issues

What's the threshold of attributes

Hi,
Thanks for your excellent work and It's awesom to have segment ontology annotations.
And what is the the threshold of attributes in the inference?
Thanks.

Model code

Hi @KMnP when will you be open sourcing the code to build the model? Many enthusiasts are waiting for the release. Thank you

How should I extract segmentation ontology from annotations?

Hi,

Thanks for your excellent work and It's awesom to have segment ontology annotations.
But how should I extract the parent-children relationship from the segmentation annotations?
BTW, do you know if there is another dataset having ontology annotations.

Thanks

Segmentation mask draw

@KMnP In the file baseline_predictor_demo.ipynb in the last code block there is a comment :

# draw segmentation mask

followed by some code using predicted segmentation masks but the resulting image does not have masks drawn on it. Am i missing something?

Question about baseline result

Great repository and dataset. But I have some problem reproducing the result.

I trained a Mask-RCNN with detectron2 without using the attribute value of the dataset. The model was trained with mask_rcnn_R_50_FPN_1x.yaml config of detectron2. I only change the learning rate to 1e-3 for the sake of convergence. It seems that the network can predict the bounding box and masks, but it gives a pretty low confidence. This lead to very low mAP(about 7, should be around 30 or 40). My code works fine on deepfashion2 dataset(mAP 69).

It will be helpful if you can share some more detailed configurations about how to achieve the baseline. Thanks !

visualize2

visualize1

Module error in New tensorflow/tpu inference code

Hi, first of all great work with the new SpineNet 143 model with amazing accuracy. I am facing error while running the fashionpedia project of tensorflow/tpu on colab. This is my notebook.

When I do this inside the file inference.py

import sys
sys.path.insert(0, '/content/tpu/models/official/detection')

the previous error in my notebook goes but then the error comes

from hyperparameters import params_dict
ModuleNotFoundError: No module named 'hyperparameters'

How to import all files properly? please guide.
Thanks @KMnP @richardaecn It would be great if you can time some time to release a colab on how to do inference for beginners.

class-agnostic attributes or not ?

Hi,
Thanks for your excellent work and It's awesom to have segment ontology annotations.
But the attributes are class-agnostic or class-specfic?
Thanks.

Wrong prediction

Instead of the line below in baseline_predictor_demo.ipynb

detections_str = '{} ({}%)'.format(ontology['categories'][detection_classes[i]]['name'],
                                           int(100*detection_scores[i]))

it should be this for correct class prediction:
detections_str = '{} ({}%)'.format(ontology['categories'][detection_classes[i]-1]['name'],int(100*detection_scores[i]))

And can you please open-source your training code. Lots of enthusiasts have been waiting for this code now. Thanks

Model Cannot Predict any Shirts (Class Id 0)

Hi. Thanks for your great job!

When I am trying to check your model with your baseline predictor it cannot detect any shirts. Maybe a problem with training phase?

Since TF object detection api requires 1-based indexing for labels I think the problem may be related to your label map being 0-indexed. Check this out

Not able to restore model ckpts

Dear Yin Cui,

First of all it is Great! to see fashionpedia model ckpts with different backbones and their performances have been shared in: https://github.com/tensorflow/tpu/tree/master/models/official/detection/projects/fashionpedia

However, when I was trying to load a model ckpt "SpineNet-143" using following code:

with tf.Session() as sess:
saver = tf.train.import_meta_graph('./spinenet-143/model.ckpt.meta')
saver.restore(sess,tf.train.latest_checkpoint('./spinenet-143/'))

i was getting following error:

"NotFoundError: Op type not registered 'LegacyParallelInterleaveDatasetV2' in binary running on 7d386b9416f5. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) tf.contrib.resampler should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed."

Could you please look into the issue and let us know as how we can load the model to test inference ?

Also it will be great if we can get frozen model (.pb format) similar to example given in "baseline_predictor_demo.ipynb"

Thanking you!

Regards,

Abhishek

getImgIds() doesn't return the combination of images from multiple category ids

First of all, thank you for sharing your work! While running the following code modified from the demo, looks like fp.getImgIds() doesn't return the correct combination of images from multiple category ids. The code is as follows:

`import numpy as np
import os

from fashionpedia.fp import Fashionpedia

anno_file = "./data/sample.json"
img_root = "./images"

fp = Fashionpedia(anno_file)

cat_ids = [24]
img_ids = fp.getImgIds(catIds=cat_ids)
print("category ", cat_ids, " has img ids ", img_ids)

cat_ids = [6]
img_ids = fp.getImgIds(catIds=cat_ids)
print("category ", cat_ids, " has img ids ", img_ids)

cat_ids = [10]
img_ids = fp.getImgIds(catIds=cat_ids)
print("category ", cat_ids, " has img ids ", img_ids)

cat_ids = [6, 24]
img_ids = fp.getImgIds(catIds=cat_ids)
print("category ", cat_ids, " has img ids ", img_ids)

cat_ids = [6, 24, 10]
img_ids = fp.getImgIds(catIds=cat_ids)
print("category ", cat_ids, " has img ids ", img_ids)
`

The output is:

category [24] has img ids [9813]
category [6] has img ids [10223]
category [10] has img ids [9813]
category [6, 24] has img ids []
category [6, 24, 10] has img ids []

I think the last two outputs should be [9813, 10223]? Or I'm miss understanding the meaning of getImgIds()?

Thanks
~

about train annotation

Hi Thanks for your work!
But I found there are duplicated anno id in annotations and may cause mismatch between anns and imgs when using coco api
Thanks again

Retrieve main garment mask

Greetings! Great job on constructing such a dataset! Thank you!
But I don't find a way to retrieve the main garment.
Example:
Current:
Segmentation 0:
Category: pocket
Attribtues:
218: patch (pocket)
Segmentation 1:
Category: sleeve
Attribtues:
204: set-in sleeve
205: dropped-shoulder sleeve
159: three quarter (length)
Segmentation 2:
Category: sleeve
Attribtues:
205: dropped-shoulder sleeve
159: three quarter (length)
Segmentation 3:
Category: sock
Segmentation 4:
Category: sock
Segmentation 5:
Category: collar
Attribtues:
163: shirt (collar)
Segmentation 6:
Category: shirt, blouse
Attribtues:
225: single breasted
295: no non-textile material
137: loose (fit)
145: no waistline
115: symmetrical
148: micro (length)
149: mini (length)
316: no special manufacturing technique
317: plain (pattern)

What I want to see:
Segmentation 0:
Category: shirt, blouse
Attribtues:
225: single breasted
295: no non-textile material
137: loose (fit)
145: no waistline
115: symmetrical
148: micro (length)
149: mini (length)
316: no special manufacturing technique
317: plain (pattern)
Segmentation 1:
Category: sock
Segmentation 2:
Category: sock

Is it possible to retrieve information in such a way?
Thank you very match, and fill free to close this issue if you already have it.

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.