MCPcopy Index your code
hub / github.com/huggingface/diffusers / InstanceDataRootDataset

Class InstanceDataRootDataset

examples/amused/train_amused.py:301–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299
300
301class InstanceDataRootDataset(Dataset):
302 def __init__(
303 self,
304 instance_data_root,
305 tokenizer,
306 size=512,
307 ):
308 self.size = size
309 self.tokenizer = tokenizer
310 self.instance_images_path = list(Path(instance_data_root).iterdir())
311
312 def __len__(self):
313 return len(self.instance_images_path)
314
315 def __getitem__(self, index):
316 image_path = self.instance_images_path[index % len(self.instance_images_path)]
317 instance_image = Image.open(image_path)
318 rv = process_image(instance_image, self.size)
319
320 prompt = os.path.splitext(os.path.basename(image_path))[0]
321 rv["prompt_input_ids"] = tokenize_prompt(self.tokenizer, prompt)[0]
322 return rv
323
324
325class InstanceDataImageDataset(Dataset):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…