Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Oct 2, 2023
1 parent 7ad7dd5 commit 155d89c
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 22 deletions.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,54 @@ A simple implementation of a CLIP that splits up an image into quandrants and th


# Install
`pip install mega-vit`

# Usage

- Simple usage,
```python
import torch
from mega_vit.main import MegaVit

v = MegaVit(
image_size = 256,
patch_size = 32,
num_classes = 1000,
dim = 1024,
depth = 6,
heads = 16,
mlp_dim = 2048,
dropout = 0.1,
emb_dropout = 0.1
)

img = torch.randn(1, 3, 256, 256)

preds = v(img) # (1, 1000)
print(preds)
```

- Hyperparams as stated in paper:
```python
import torch
from mega_vit.main import MegaVit

v = ViT(
image_size = 224,
patch_size = 14,
num_classes = 1000,
dim = 6144,
depth = 48,
heads = 48,
mlp_dim = 2048,
dropout = 0.1,
emb_dropout = 0.1
)

img = torch.randn(1, 3, 224, 224)

preds = v(img) # (1, 1000)
print(preds)
```
# Architecture

# Dataset Strategy
Expand Down
19 changes: 19 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import torch
from mega_vit.main import MegaVit

v = MegaVit(
image_size = 256,
patch_size = 32,
num_classes = 1000,
dim = 1024,
depth = 6,
heads = 16,
mlp_dim = 2048,
dropout = 0.1,
emb_dropout = 0.1
)

img = torch.randn(1, 3, 256, 256)

preds = v(img) # (1, 1000)
print(preds)
1 change: 1 addition & 0 deletions mega_vit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from mega_vit.main import MegaVit
40 changes: 20 additions & 20 deletions mega_vit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def forward(self, x):

return self.norm(x)

class ViT(nn.Module):
class MegaVit(nn.Module):
def __init__(
self,
*,
Expand Down Expand Up @@ -189,22 +189,22 @@ def forward(self, img):
# preds = v(img) # (1, 1000)
# print(preds)

import torch
# from vit_pytorch import ViT

v = ViT(
image_size = 256,
patch_size = 32,
num_classes = 1000,
dim = 1024,
depth = 6,
heads = 16,
mlp_dim = 2048,
dropout = 0.1,
emb_dropout = 0.1
)

img = torch.randn(1, 3, 256, 256)

preds = v(img) # (1, 1000)
print(preds)
# import torch
# # from vit_pytorch import ViT

# v = MegaVit(
# image_size = 256,
# patch_size = 32,
# num_classes = 1000,
# dim = 1024,
# depth = 6,
# heads = 16,
# mlp_dim = 2048,
# dropout = 0.1,
# emb_dropout = 0.1
# )

# img = torch.randn(1, 3, 256, 256)

# preds = v(img) # (1, 1000)
# print(preds)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "mega-vit"
version = "0.0.1"
version = "0.0.2"
description = "mega-vit - Pytorch"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down

0 comments on commit 155d89c

Please sign in to comment.