Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJiezou committed May 20, 2022
1 parent 2899f4b commit 4b84af7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ extend-ignore =
INP001
# ANN101: Missing type annotation for self in method
ANN101
# E402: module level import not at top of file
E402

per-file-ignores =
# F401: Module imported by unused (non-implicit modules)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

[![logo](https://raw.githubusercontent.com/XavierJiezou/LitMNIST/main/images/favicon_256x256.svg)](https://pixelied.com/editor/design/6282f5970515730397249959)
[![logo](https://raw.githubusercontent.com/XavierJiezou/LitMNIST/main/images/logo.png)](https://pixelied.com/editor/design/6282f5970515730397249959)

# LitMNIST

Expand Down Expand Up @@ -97,7 +97,7 @@ Love the project? Please consider [donating](https://paypal.me/xavierjiezou?coun

## Demo

![demo](https://cdn.jsdelivr.net/gh/XavierJiezou/LitMNIST@main/images/favicon_256x256.svg)
![demo](https://cdn.jsdelivr.net/gh/XavierJiezou/LitMNIST@main/images/logo.png)

## Features

Expand Down
18 changes: 0 additions & 18 deletions images/favicon_280x280.jpg

This file was deleted.

Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions litmnist/datamodules/mnist_datamodule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Any

import torch
from pytorch_lightning import LightningDataModule
Expand Down Expand Up @@ -44,9 +45,11 @@ def prepare_data(self) -> None:
MNIST(self.hparams.data_dir, train=True, download=_download)
MNIST(self.hparams.data_dir, train=False, download=_download)

def setup(self, stage: str | None = None) -> None:
def setup(self, stage: Any = None) -> None:
if stage in ("fit", "test", None):
trainset = MNIST(root=self.data_dir, train=True, transform=self.transform)
trainset = MNIST(
root=self.hparams.data_dir, train=True, transform=self.transform
)
testset = MNIST(
root=self.hparams.data_dir, train=False, transform=self.transform
)
Expand Down
Empty file removed litmnist/utils/core.py
Empty file.
28 changes: 28 additions & 0 deletions litmnist/utils/make_logo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

sys.path.append(".")

from torchvision.utils import save_image

from litmnist.datamodules import MNISTDataModule


def make_logo(save_path: str) -> None:
datamodule = MNISTDataModule()
datamodule.prepare_data()
datamodule.setup()
temp = {i: [] for i in range(10)}
for x, y in datamodule.data_test:
if len(temp[y]) < 10:
temp[y] += x
else:
if sum(len(value) for value in temp.values()) == 100:
break
else:
continue
logo = [each.unsqueeze(0) for value in temp.values() for each in value]
save_image(logo, save_path, nrow=10, padding=0)


if __name__ == "__main__":
make_logo("images/logo.png")
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ generate-setup-file = false
python = "^3.7"
torch = "^1.8.0"
torchvision = "^0.9.0"
pytorch-lightning = "^1.6.3"
pytorch-lightning = "^1.5.0"
torchmetrics="^0.8.2"
comet-ml = "^3.31.0"
fire = "^0.4.0"
rich = "^12.3.0"
hydra-core = "^1.1"
wandb="^0.12.16"

[tool.poetry.dev-dependencies]
toml = "^0.10.2"
Expand Down

0 comments on commit 4b84af7

Please sign in to comment.