Commit ·
93baead
1
Parent(s): 8f1e7ee
Upload 4 files
Browse filesFiles changed (4)
- conditioning_images.zipAdded+3
- images.zipAdded+3
- smoothieV1.pyAdded+101
- train.jsonlAdded
123version https://git-lfs.github.com/spec/v1oid sha256:94e0936229147cdd0daf56130160a7b1ebe3d1c088d9afbdabbaf12267e7dd28size 147830319123version https://git-lfs.github.com/spec/v1oid sha256:5d4f387c9f3ab0f2f807ef549b2d1264c635d025c5ecd3555ad59ede316bbecbsize 104248994123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101import pandas as pdfrom huggingface_hub import hf_hub_urlimport datasetsimport os
_VERSION = datasets.Version("0.0.1")
_DESCRIPTION = "TODO"_HOMEPAGE = "TODO"_LICENSE = "TODO"_CITATION = "TODO"
_FEATURES = datasets.Features( { "image": datasets.Image(), "conditioning_image": datasets.Image(), "text": datasets.Value("string"), },)
METADATA_URL = hf_hub_url( "realimposter/smoothieV1", filename="train.jsonl", repo_type="dataset",)
IMAGES_URL = hf_hub_url( "realimposter/smoothieV1", filename="images.zip", repo_type="dataset",)
CONDITIONING_IMAGES_URL = hf_hub_url( "realimposter/smoothieV1", filename="conditioning_images.zip", repo_type="dataset",)
_DEFAULT_CONFIG = datasets.BuilderConfig(name="default", version=_VERSION)
class SmoothieV1(datasets.GeneratorBasedBuilder): BUILDER_CONFIGS = [_DEFAULT_CONFIG] DEFAULT_CONFIG_NAME = "default"
def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=_FEATURES, supervised_keys=None, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, )
def _split_generators(self, dl_manager): metadata_path = dl_manager.download(METADATA_URL) images_dir = dl_manager.download_and_extract(IMAGES_URL) conditioning_images_dir = dl_manager.download_and_extract( CONDITIONING_IMAGES_URL )
return [ datasets.SplitGenerator( name=datasets.Split.TRAIN, # These kwargs will be passed to _generate_examples gen_kwargs={ "metadata_path": metadata_path, "images_dir": images_dir, "conditioning_images_dir": conditioning_images_dir, }, ), ]
def _generate_examples(self, metadata_path, images_dir, conditioning_images_dir): metadata = pd.read_json(metadata_path, lines=True)
for _, row in metadata.iterrows(): text = row["text"]
image_path = row["image"] image_path = os.path.join(images_dir, image_path) image = open(image_path, "rb").read()
conditioning_image_path = row["conditioning_image"] conditioning_image_path = os.path.join( conditioning_images_dir, row["conditioning_image"] ) conditioning_image = open(conditioning_image_path, "rb").read()
yield row["image"], { "text": text, "image": { "path": image_path, "bytes": image, }, "conditioning_image": { "path": conditioning_image_path, "bytes": conditioning_image, }, }conditioning_images.zipAdded+3
images.zipAdded+3
smoothieV1.pyAdded+101
train.jsonlAdded