aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdamms <damguillotin@gmail.com>2024-05-27 14:10:15 +0200
committergdamms <damguillotin@gmail.com>2024-05-27 14:10:15 +0200
commit9ad3df0317162809c41230101b88f5e672f38ecd (patch)
treeb85b440f165996e96a4d663cd7df77a06ff38c9a
parent166b0f9bfa13672cc6679cf32fc8d715f34467d0 (diff)
downloaddiffusion-mnist-9ad3df0317162809c41230101b88f5e672f38ecd.tar.gz
diffusion-mnist-9ad3df0317162809c41230101b88f5e672f38ecd.zip
folder dataset
-rw-r--r--main.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/main.py b/main.py
index 2d5c9f1..6ba7eb6 100644
--- a/main.py
+++ b/main.py
@@ -77,16 +77,16 @@ class UNet(nn.Module):
return x7
-
-class LFWcrop(Dataset):
- def __init__(self):
+class FolderDataset(Dataset):
+ def __init__(self, path, size=(32, 32)):
super().__init__()
- self.path = './data/lfwcrop_color/faces'
+ self.path = path
+ self.size = size
self.files = os.listdir(self.path)
def __getitem__(self, index):
img = cv2.imread(os.path.join(self.path, self.files[index]))
- img = cv2.resize(img, (32, 32))
+ img = cv2.resize(img, self.size)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = np.transpose(img, (2, 0, 1)) / 255
return torch.tensor(img, dtype=torch.float32), 0
@@ -204,12 +204,12 @@ BETA = torch.cat((torch.tensor([0.], device=DEVICE), BETA))
ALPHA = 1 - BETA
ALPHA_BAR = torch.cumprod(ALPHA, dim=0)
-dataset = datasets.MNIST(
- root="./data",
- train=True,
- download=True,
- transform=transforms.ToTensor(),
-)
+# dataset = datasets.MNIST(
+# root="./data",
+# train=True,
+# download=True,
+# transform=transforms.ToTensor(),
+# )
# dataset = datasets.LFWPeople(
# root="./data",
# download=True,
@@ -218,13 +218,14 @@ dataset = datasets.MNIST(
# transforms.ToTensor(),
# ]),
# )
-# dataset = LFWcrop()
+# dataset = FolderDataset('data/lfwcrop_color/faces')
+dataset = FolderDataset('data/edface')
img = dataset[0][0]
NB_CHANNEL, IMG_SIZE, _ = img.shape
-NB_LABEL = 10
+NB_LABEL = 1
-EPOCHS = 0
+EPOCHS = 100
LEARNING_RATE = 2e-4