Datasets:
File size: 6,522 Bytes
aa3b0e0 8531810 aa3b0e0 6f2c369 aa3b0e0 6f2c369 aa3b0e0 |
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 |
---
license: cc-by-4.0
task_categories:
- video-text-to-text
- visual-question-answering
- image-to-text
language:
- en
size_categories:
- 10M<n<100M
viewer: false
---
# OmniCorpus-YT
This is the repository of OmniCorpus-YT, which contains 10 million image-text interleaved documents collected from Youtube videos.
- Repository: https://github.com/OpenGVLab/OmniCorpus
- Paper: https://arxiv.org/abs/2406.08418
OmniCorpus dataset is a large-scale image-text interleaved dataset, which pushes the boundaries of scale and diversity by encompassing **8.6 billion images** interleaved with **1,696 text tokens** from diverse sources, significantly surpassing previous datasets.
This dataset demonstrates several advantages over its counterparts:
1. **Larger data scale:** Our dataset is 1.7 times larger in images and 12.5 times larger in texts compared to the previously largest multimodal dataset, LAION-5B, while maintaining excellent data quality.
2. **Richer data diversity:** Drawing from a broader range of data sources, our dataset is more diverse than other image-text interleaved datasets. It includes bilingual multimodal data in both Chinese and English, and encompasses text-centric and vision-centric documents extracted from common websites and video platforms.
3. **More flexible format:** The streaming data format of our dataset offers exceptional flexibility, allowing adaptation to various data structures, including pure text corpora, image-text pairs, and interleaved data formats.
<img width="578" alt="image" src="https://github.com/OpenGVLab/OmniCorpus/assets/47669167/641a6427-ba50-41e6-8634-8810113fd803">
The OmniCorpus contains three sections:
- **OmniCorpus-CC**: processed from dumps in Common Crawl from 2013 to Nov./Dec. 2023.
- **OmniCorpus-CW**: sourced from Chinese internet resources, will be availiable on [OpenDataLab](https://opendatalab.com/) platform.
- **OmniCorpus-YT**: samples Youtube video frames as images and collects subtitles as texts.
Code for pre-training, evaluating, main body extracting, and filtering have been released in the official [repository](https://github.com/OpenGVLab/OmniCorpus). A pre-trained model is availiable [here](). We are processing and uploading the rest data sections as soon as possible.
# Usages
The image-text interleaved documents are recommanded for the following usages:
- Pre-training multimodal large language model (MLLM): Recent MLLMs (such as Flamingo series, EMU series, IDEFICS series, MM1, Cambrian-1, and xGen-MM) have shown that image-text interleaved data aids multimodal in-context learning and maintains the capabilities of large language models during multimodal fine-tuning.
- Long text-image retrieval: We provide image-text similarities calculated with CLIP, which can convert the documents to image-text retrieval dataset with longer text. A retrieval model pre-trained on such data can retrieval images based on longer text, which can be used for multimodal RAG, converting pure text to multimodal sample, etc.
- Source for futher dataset research: Our data is large-scale, which can serve as the source for researches for data curation strategies. We provide many useful attributes as metadata for each document, which can enrich the filtering strategy and reduce the cost.
- ......
# Data Format
Following common practices, the data is organized into Parquet file format.
You might encounter errors when using `pandas.read_parquet` (because the data structure contains nested elements). We recommend using fastparquet to load the parquet files.
```Python
import fastparquet
df = fastparquet.ParquetFile(parquet_file_path).to_pandas()
# You can also use iter_batches
parquet_file = pq.ParquetFile(filepath)
for batch in parquet_file.iter_batches():
df = batch.to_pandas()
```
You can convert the i-th document and convert it into a dictionary.
```Python
doc_dict = df.iloc[i].to_dict()
```
The document format is as follow:
```json
{
'id': <str: youtube video id>,
'images': <bytes: list of image timestamps>,
'texts': <bytes: list of texts>
}
```
the images and texts can be loaded with `lambda s: json.loads(s)`
```json
'images': [
<str: key_frame_1_timestamp>,
None,
<str: key_frame_2_timestamp>,
None,
],
'texts': [
None,
<str: text_paragraph_1_content>
None,
<str: text_paragraph_2_content>,
]
```
The frame can be sampled from downloaded Youtube videos, we provide a python sampling tool:
```python
import os
import sys
import yt_dlp # pip install yt-dlp
import ffmpeg # brew install ffmpeg; pip install ffmpeg-python
import traceback
from multiprocessing import Pool
def download_hls_url(youtube_id):
video_url = f"https://www.youtube.com/watch?v={youtube_id}"
ydl_opts = {
'format': 'best',
'noplaylist': True,
'quiet': True,
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(video_url, download=False)
return info['url']
def extract_frame(hls_url, timestamp, output_file):
try:
(
ffmpeg
.input(hls_url, ss=timestamp, protocol_whitelist='file,http,https,tcp,tls,httpproxy')
.output(output_file, vframes=1)
.run(quiet=True, capture_stdout=True, capture_stderr=True)
)
except ffmpeg.Error as e:
print(f"Error extracting frame at timestamp {timestamp}: {e}")
print("FFmpeg stderr output:\n", e.stderr.decode())
traceback.print_exc()
def extract_frames_with_hls(youtube_id, timestamps, output_dir='frames'):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
hls_url = download_hls_url(youtube_id)
tasks = [(hls_url, timestamp, os.path.join(output_dir, f"{timestamp}.jpg")) for timestamp in timestamps]
with Pool() as pool:
pool.starmap(extract_frame, tasks)
if __name__ == "__main__":
extract_frames_with_hls("1xGiPUeevCM", [19.000000, 23.000000, 28.000000, 32.000000, 45.000000, 54.000000, 57.000000, 67.000000])
```
# License
OmniCorpus is released under a [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/deed.en) license, with the primary intent of supporting research activities.
# Citation
```
@article{li2024omnicorpus,
title={OmniCorpus: A Unified Multimodal Corpus of 10 Billion-Level Images Interleaved with Text},
author={Li, Qingyun and Chen, Zhe and Wang, Weiyun and Wang, Wenhai and Ye, Shenglong and Jin, Zhenjiang and others},
journal={arXiv preprint arXiv:2406.08418},
year={2024}
}
```
|