JUNPYO99 commited on
Commit
fb69f98
·
verified ·
1 Parent(s): ae73e49

Delete loading script

Browse files
Files changed (1) hide show
  1. conti2line.py +0 -103
conti2line.py DELETED
@@ -1,103 +0,0 @@
1
- import pandas as pd
2
- from huggingface_hub import hf_hub_url
3
- import datasets
4
- import os
5
-
6
- _VERSION = datasets.Version("0.0.6")
7
-
8
- _DESCRIPTION = "TODO"
9
- _HOMEPAGE = "TODO"
10
- _LICENSE = "TODO"
11
- _CITATION = "TODO"
12
-
13
- _FEATURES = datasets.Features(
14
- {
15
- "image": datasets.Image(),
16
- "conditioning_image": datasets.Image(),
17
- },
18
- )
19
-
20
- METADATA_URL = hf_hub_url(
21
- "JUNPYO99/conti2line",
22
- filename="train.jsonl",
23
- repo_type="dataset",
24
- )
25
-
26
- IMAGES_URL = hf_hub_url(
27
- "JUNPYO99/conti2line",
28
- filename="images.zip",
29
- repo_type="dataset",
30
- )
31
-
32
- CONDITIONING_IMAGES_URL = hf_hub_url(
33
- "JUNPYO99/conti2line",
34
- filename="conditioning_images.zip",
35
- repo_type="dataset",
36
- )
37
-
38
- _DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
39
-
40
- class Conti2drawing(datasets.GeneratorBasedBuilder):
41
- BUILDER_CONFIGS = [_DEFAULT_CONFIG]
42
- DEFAULT_CONFIG_NAME = "default"
43
-
44
- def _info(self):
45
- return datasets.DatasetInfo(
46
- description=_DESCRIPTION,
47
- features=_FEATURES,
48
- supervised_keys=None,
49
- homepage=_HOMEPAGE,
50
- license=_LICENSE,
51
- citation=_CITATION,
52
- )
53
-
54
- def _split_generators(self, dl_manager):
55
- metadata_path = dl_manager.download(METADATA_URL)
56
- images_dir = dl_manager.download_and_extract(IMAGES_URL)
57
- conditioning_images_dir = dl_manager.download_and_extract(
58
- CONDITIONING_IMAGES_URL
59
- )
60
-
61
- return [
62
- datasets.SplitGenerator(
63
- name=datasets.Split.TRAIN,
64
- # These kwargs will be passed to _generate_examples
65
- gen_kwargs={
66
- "metadata_path": metadata_path,
67
- "images_dir": images_dir,
68
- "conditioning_images_dir": conditioning_images_dir,
69
- },
70
- ),
71
- ]
72
-
73
- def _generate_examples(self, metadata_path, images_dir, conditioning_images_dir):
74
- try:
75
- metadata = pd.read_json(metadata_path, lines=True)
76
- except ValueError as e:
77
- print(f"Error reading JSON file at {metadata_path}: {e}")
78
- raise e
79
- except FileNotFoundError as e:
80
- print(f"File not found at {metadata_path}: {e}")
81
- raise e
82
-
83
- for _, row in metadata.iterrows():
84
- image_path = row["image"]
85
- image_path = os.path.join(images_dir, image_path)
86
- image = open(image_path, "rb").read()
87
-
88
- conditioning_image_path = row["conditioning_image"]
89
- conditioning_image_path = os.path.join(
90
- conditioning_images_dir, row["conditioning_image"]
91
- )
92
- conditioning_image = open(conditioning_image_path, "rb").read()
93
-
94
- yield row["image"], {
95
- "image": {
96
- "path": image_path,
97
- "bytes": image,
98
- },
99
- "conditioning_image": {
100
- "path": conditioning_image_path,
101
- "bytes": conditioning_image,
102
- },
103
- }