pranjali-pathre
commited on
Commit
•
431eb84
1
Parent(s):
b1b41ed
Initial commit
Browse files- README.md +17 -0
- data/video_01.zip +3 -0
- i2i.py +73 -0
README.md
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
dataset_info:
|
3 |
+
config_name: video_01
|
4 |
+
features:
|
5 |
+
- name: initial_image
|
6 |
+
dtype: image
|
7 |
+
- name: edit_prompt
|
8 |
+
dtype: string
|
9 |
+
- name: edited_image
|
10 |
+
dtype: image
|
11 |
+
splits:
|
12 |
+
- name: train
|
13 |
+
num_bytes: 3604
|
14 |
+
num_examples: 10
|
15 |
+
download_size: 548787
|
16 |
+
dataset_size: 3604
|
17 |
+
---
|
data/video_01.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23e5ce54a127b3b55a05a4fc03527a20c73b105b7bb7b0f2eb04013f6ca1c693
|
3 |
+
size 548787
|
i2i.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from xml.etree import ElementTree as ET
|
3 |
+
import datasets
|
4 |
+
import lxml.etree
|
5 |
+
|
6 |
+
_DESCRIPTION = """\
|
7 |
+
The dataset img2img data.
|
8 |
+
"""
|
9 |
+
_NAME = "i2i"
|
10 |
+
|
11 |
+
_HOMEPAGE = f"https://huggingface.co/datasets/pranjalipathre/{_NAME}"
|
12 |
+
|
13 |
+
_LICENSE = ""
|
14 |
+
|
15 |
+
# _DATA = f"https://huggingface.co/datasets/pranjalipathre/{_NAME}/resolve/main/data/"
|
16 |
+
_DATA = f"/home/pranjali/Documents/Research/pybullet/img2img/{_NAME}/data/"
|
17 |
+
|
18 |
+
class i2iDataset(datasets.GeneratorBasedBuilder):
|
19 |
+
BUILDER_CONFIGS = [
|
20 |
+
datasets.BuilderConfig(name="video_01", data_dir=f"{_DATA}video_01.zip"),
|
21 |
+
]
|
22 |
+
|
23 |
+
DEFAULT_CONFIG_NAME = "video_01"
|
24 |
+
|
25 |
+
def _info(self):
|
26 |
+
return datasets.DatasetInfo(
|
27 |
+
description=_DESCRIPTION,
|
28 |
+
features=datasets.Features(
|
29 |
+
{
|
30 |
+
"initial_image": datasets.Image(),
|
31 |
+
"edit_prompt": datasets.Value("string"),
|
32 |
+
"edited_image": datasets.Image(),
|
33 |
+
}
|
34 |
+
),
|
35 |
+
supervised_keys=None,
|
36 |
+
homepage=_HOMEPAGE,
|
37 |
+
citation=None,
|
38 |
+
)
|
39 |
+
|
40 |
+
def _split_generators(self, dl_manager):
|
41 |
+
data = dl_manager.download_and_extract(self.config.data_dir)
|
42 |
+
return [
|
43 |
+
datasets.SplitGenerator(
|
44 |
+
name=datasets.Split.TRAIN,
|
45 |
+
gen_kwargs={
|
46 |
+
"data": data,
|
47 |
+
},
|
48 |
+
),
|
49 |
+
]
|
50 |
+
|
51 |
+
@staticmethod
|
52 |
+
def parse_text(root: ET.Element, file: str, index: int) -> dict:
|
53 |
+
idx = str(index)
|
54 |
+
ele = root.find(f".//prompt[@frame='{idx}']")
|
55 |
+
# print("Extracted text: ", ele.get("text"))
|
56 |
+
dt = {
|
57 |
+
"text": ele.get("text")
|
58 |
+
}
|
59 |
+
return dt
|
60 |
+
|
61 |
+
def _generate_examples(self, data):
|
62 |
+
tree = lxml.etree.parse(os.path.join(data, "annotations.xml"))
|
63 |
+
root = tree.getroot()
|
64 |
+
|
65 |
+
for idx, file in enumerate(sorted(os.listdir(os.path.join(data, "initial_images")))):
|
66 |
+
dat = self.parse_text(root, file, idx)
|
67 |
+
txt = dat["text"]
|
68 |
+
|
69 |
+
yield idx, {
|
70 |
+
"initial_image": os.path.join(data, "initial_images", file),
|
71 |
+
"edit_prompt": txt,
|
72 |
+
"edited_image": os.path.join(data, "edited_images", file.replace("_ip", "")),
|
73 |
+
}
|