File size: 5,490 Bytes
7cbc74a
b9c7f46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
edeebdd
 
 
 
 
b9c7f46
 
 
 
 
edeebdd
 
591a0c2
 
 
 
 
 
 
 
 
 
 
 
0e795b0
 
 
 
 
 
 
 
 
c54d16f
0e795b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00577b5
 
 
77f7858
00577b5
 
 
 
 
 
 
 
 
 
 
 
 
 
a54c590
d8a8a83
 
 
 
a54c590
 
 
 
00577b5
0e795b0
 
d8a8a83
0e795b0
 
bdda320
0e795b0
bdda320
 
0e795b0
 
 
 
 
 
00577b5
 
 
 
 
 
 
 
d8a8a83
 
 
 
 
 
 
 
0e795b0
 
 
 
5997bf7
0e795b0
 
 
 
 
 
 
 
f80cbc2
d8a8a83
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
dataset_info:
  features:
  - name: license
    dtype: int64
  - name: file_name
    dtype: string
  - name: coco_url
    dtype: string
  - name: height
    dtype: int64
  - name: width
    dtype: int64
  - name: date_captured
    dtype: string
  - name: flickr_url
    dtype: string
  - name: image_id
    dtype: int64
  - name: ids
    sequence: int64
  - name: captions
    sequence: string
  splits:
  - name: train
    num_bytes: 60768398.02132102
    num_examples: 112268
  - name: validation
    num_bytes: 2684731
    num_examples: 5000
  download_size: 28718001
  dataset_size: 63453129.02132102
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: validation
    path: data/validation-*
task_categories:
- text-to-image
- image-to-image
language:
- en
tags:
- coco
- image-captioning
- colorization
pretty_name: COCO2017-Colorization
size_categories:
- 100K<n<1M
---
# COCO 2017 Dataset for Image Colorization

## Overview

This dataset is derived from the COCO (Common Objects in Context) 2017 dataset, which is a large-scale object detection, segmentation, and captioning dataset. The COCO 2017 dataset has been adapted here specifically for the task of image colorization.

## Dataset Description

- **Original Dataset:** [COCO 2017](https://cocodataset.org/#download).
- **Task:** Image Colorization
- **License:** [COCO dataset license](https://cocodataset.org/#termsofuse)

## Format

```python
DatasetDict({
    train: Dataset({
        features: ['license', 'file_name', 'coco_url', 'height', 'width', 'date_captured', 'flickr_url', 'image_id', 'ids', 'captions'],
        num_rows: 112268
    })
    validation: Dataset({
        features: ['license', 'file_name', 'coco_url', 'height', 'width', 'date_captured', 'flickr_url', 'image_id', 'ids', 'captions'],
        num_rows: 5000
    })
})
```

## Usage

### Download image data and unzip
  
```bash
cd PATH_TO_IMAGE_FOLDER

wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip

unzip train2017.zip
unzip val2017.zip
```

### Branches

- **main:** Provides the original captions sentences.
- **caption-free:** Provides random prompts selected from the following list:

```python
sentences = [
    "Add colors to this image",
    "Give realistic colors to this image",
    "Add realistic colors to this image",
    "Colorize this grayscale image",
    "Colorize this image",
    "Restore the original colors of this image",
    "Make this image colorful",
    "Colorize this image as if it was taken with a color camera",
    "Create the original colors of this image"
]
```
- **custom-caption:** Provides captions generated by
  [CLIP Interrogator](https://github.com/pharmapsychotic/clip-interrogator/tree/main) with `'ViT-H-14/laion2b_s32b_b79k'` model.
  Then filter with `'csv_filter.py'` to remove unlikely words, such as black and white, monochrome, grainy, desaturated, etc.
  For more details about the prompts filtering criteria,
  refer to the [Dataset-for-Image-Colorization](https://github.com/nick8592/Dataset-for-Image-Colorization.git) repository.
  For example, bellow is one of the generated caption:
```bash
["there is a  photo of a bear sitting in the grass, half grizzly bear, portrait of anthropomorphic bear, head of a bear, grizzly, grizzled, brown bear, by Mirko Rački, bear, half bear, by Jacek Sempoliński, staring, angry bear"]
```

### Loading the Dataset

You can load this dataset using the Hugging Face `'datasets'` library:
```python
from datasets import load_dataset
```

#### Main Branch
```python
# Load the train split of the colorization dataset
train_dataset = load_dataset("nickpai/coco2017-colorization", split="train")
# Load the validation split of the colorization dataset
val_dataset = load_dataset("nickpai/coco2017-colorization", split="validation")
```

#### Caption-Free Branch
```python
# Load the train split of the colorization dataset from the caption-free branch
train_dataset = load_dataset("nickpai/coco2017-colorization", split="train", revision="caption-free")
# Load the validation split of the colorization dataset from the caption-free branch
val_dataset = load_dataset("nickpai/coco2017-colorization", split="validation", revision="caption-free")
```

#### Custom-Caption Branch
```python
# Load the train split of the colorization dataset from the custom-caption branch
train_dataset = load_dataset("nickpai/coco2017-colorization", split="train", revision="custom-caption")
# Load the validation split of the colorization dataset from the custom-caption branch
val_dataset = load_dataset("nickpai/coco2017-colorization", split="validation", revision="custom-caption")
```

## Filtering Criteria

### 1. Grayscale Images
- Images in grayscale mode are identified and removed.
- Grayscale images lack color information are not be suitable for image colorization.

### 2. Identical Color Histograms
- Images with identical histograms across color channels (red, green, and blue) are removed.
- Such images may lack sufficient color variation, affecting model training and performance.

### 3. Low Color Variance
- Images with low color variance, determined by a specified threshold, are removed.
- Low color variance can indicate poor image quality or uniform color distribution.

For more details about the image filtering criteria, 
refer to the [Dataset-for-Image-Colorization](https://github.com/nick8592/Dataset-for-Image-Colorization.git) repository.