MCPcopy Index your code
hub / github.com/geekcomputers/Python / __getitem__

Method __getitem__

ML/src/python/neuralforge/data/dataset.py:49–64  ·  view source on GitHub ↗
(self, idx: int)

Source from the content-addressed store, hash-verified

47 return len(self.samples)
48
49 def __getitem__(self, idx: int) -> Tuple[torch.Tensor, int]:
50 img_path, label = self.samples[idx]
51
52 try:
53 image = Image.open(img_path).convert('RGB')
54 except Exception as e:
55 print(f"Error loading image {img_path}: {e}")
56 image = Image.new('RGB', (224, 224), color='black')
57
58 if self.transform:
59 image = self.transform(image)
60
61 if self.target_transform:
62 label = self.target_transform(label)
63
64 return image, label
65
66class SyntheticDataset(Dataset):
67 def __init__(

Callers

nothing calls this directly

Calls 1

convertMethod · 0.80

Tested by

no test coverage detected