Datasets:
Tasks:
Image-to-Text
Sub-tasks:
image-captioning
Languages:
English
Size:
10M<n<100M
ArXiv:
License:
Commit
·
d9a112f
1
Parent(s):
7d06fc7
Make code for image downloading from image urls cacheable (#4218)
Browse files* Make code for image downloading from image urls cacheable
* Minor improvement in RedCaps card
* Minor fixes in formatting
Commit from https://github.com/huggingface/datasets/commit/6a201a6f8fb8837f37925e38c4cc69e92155120f
README.md
CHANGED
|
@@ -51,9 +51,9 @@ pretty_name: RedCaps
|
|
| 51 |
|
| 52 |
## Dataset Description
|
| 53 |
|
| 54 |
-
- **Homepage:** https://redcaps.xyz/
|
| 55 |
-
- **Repository:**
|
| 56 |
-
- **Paper:** https://arxiv.org/abs/2111.11431
|
| 57 |
- **Leaderboard:**
|
| 58 |
- **Point of Contact:** [Karan Desai](mailto:[email protected])
|
| 59 |
|
|
@@ -84,13 +84,16 @@ from datasets import load_dataset
|
|
| 84 |
from datasets.utils.file_utils import get_datasets_user_agent
|
| 85 |
|
| 86 |
|
|
|
|
|
|
|
|
|
|
| 87 |
def fetch_single_image(image_url, timeout=None, retries=0):
|
| 88 |
for _ in range(retries + 1):
|
| 89 |
try:
|
| 90 |
request = urllib.request.Request(
|
| 91 |
image_url,
|
| 92 |
data=None,
|
| 93 |
-
headers={"user-agent":
|
| 94 |
)
|
| 95 |
with urllib.request.urlopen(request, timeout=timeout) as req:
|
| 96 |
image = PIL.Image.open(io.BytesIO(req.read()))
|
|
@@ -118,6 +121,8 @@ Some image links point to more than one image. You can process and downloaded th
|
|
| 118 |
from concurrent.futures import ThreadPoolExecutor
|
| 119 |
from functools import partial
|
| 120 |
import io
|
|
|
|
|
|
|
| 121 |
import urllib
|
| 122 |
|
| 123 |
import PIL.Image
|
|
@@ -127,13 +132,16 @@ from datasets import load_dataset
|
|
| 127 |
from datasets.utils.file_utils import get_datasets_user_agent
|
| 128 |
|
| 129 |
|
|
|
|
|
|
|
|
|
|
| 130 |
def fetch_single_image(image_url, timeout=None, retries=0):
|
| 131 |
for _ in range(retries + 1):
|
| 132 |
try:
|
| 133 |
request = urllib.request.Request(
|
| 134 |
image_url,
|
| 135 |
data=None,
|
| 136 |
-
headers={"user-agent":
|
| 137 |
)
|
| 138 |
with urllib.request.urlopen(request, timeout=timeout) as req:
|
| 139 |
image = PIL.Image.open(io.BytesIO(req.read()))
|
|
@@ -452,7 +460,7 @@ From the paper:
|
|
| 452 |
|
| 453 |
### Citation Information
|
| 454 |
|
| 455 |
-
```
|
| 456 |
@misc{desai2021redcaps,
|
| 457 |
title={RedCaps: web-curated image-text data created by the people, for the people},
|
| 458 |
author={Karan Desai and Gaurav Kaul and Zubin Aysola and Justin Johnson},
|
|
|
|
| 51 |
|
| 52 |
## Dataset Description
|
| 53 |
|
| 54 |
+
- **Homepage:** [RedCaps homepage](https://redcaps.xyz/)
|
| 55 |
+
- **Repository:** [RedCaps repository](https://github.com/redcaps-dataset/redcaps-downloader)
|
| 56 |
+
- **Paper:** [RedCaps: web-curated image-text data created by the people, for the people](https://arxiv.org/abs/2111.11431)
|
| 57 |
- **Leaderboard:**
|
| 58 |
- **Point of Contact:** [Karan Desai](mailto:[email protected])
|
| 59 |
|
|
|
|
| 84 |
from datasets.utils.file_utils import get_datasets_user_agent
|
| 85 |
|
| 86 |
|
| 87 |
+
USER_AGENT = get_datasets_user_agent()
|
| 88 |
+
|
| 89 |
+
|
| 90 |
def fetch_single_image(image_url, timeout=None, retries=0):
|
| 91 |
for _ in range(retries + 1):
|
| 92 |
try:
|
| 93 |
request = urllib.request.Request(
|
| 94 |
image_url,
|
| 95 |
data=None,
|
| 96 |
+
headers={"user-agent": USER_AGENT},
|
| 97 |
)
|
| 98 |
with urllib.request.urlopen(request, timeout=timeout) as req:
|
| 99 |
image = PIL.Image.open(io.BytesIO(req.read()))
|
|
|
|
| 121 |
from concurrent.futures import ThreadPoolExecutor
|
| 122 |
from functools import partial
|
| 123 |
import io
|
| 124 |
+
import os
|
| 125 |
+
import re
|
| 126 |
import urllib
|
| 127 |
|
| 128 |
import PIL.Image
|
|
|
|
| 132 |
from datasets.utils.file_utils import get_datasets_user_agent
|
| 133 |
|
| 134 |
|
| 135 |
+
USER_AGENT = get_datasets_user_agent()
|
| 136 |
+
|
| 137 |
+
|
| 138 |
def fetch_single_image(image_url, timeout=None, retries=0):
|
| 139 |
for _ in range(retries + 1):
|
| 140 |
try:
|
| 141 |
request = urllib.request.Request(
|
| 142 |
image_url,
|
| 143 |
data=None,
|
| 144 |
+
headers={"user-agent": USER_AGENT},
|
| 145 |
)
|
| 146 |
with urllib.request.urlopen(request, timeout=timeout) as req:
|
| 147 |
image = PIL.Image.open(io.BytesIO(req.read()))
|
|
|
|
| 460 |
|
| 461 |
### Citation Information
|
| 462 |
|
| 463 |
+
```bibtex
|
| 464 |
@misc{desai2021redcaps,
|
| 465 |
title={RedCaps: web-curated image-text data created by the people, for the people},
|
| 466 |
author={Karan Desai and Gaurav Kaul and Zubin Aysola and Justin Johnson},
|