Skip to content

Commit

Permalink
[EXAMPLE]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Feb 1, 2024
1 parent 27f5bcc commit b99d578
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 33 deletions.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@ Implementation of Qformer from BLIP2 in Zeta Lego blocks. The implementation is
import torch
from qformer import QFormer

x = torch.randn(
1, 32, 512
) # Create a random tensor of shape (1, 32, 512)

img = torch.randn(
1, 32, 512
) # Create another random tensor of shape (1, 32, 512)

qformer = QFormer(
512, 8, 8, 0.1, 2, 2
) # Create an instance of the QFormer model

y = qformer(
x, img
) # Apply the QFormer model to the input tensors x and img

print(y.shape) # Print the shape of the output tensor y
# Create a random tensor of shape (1, 32, 512)
x = torch.randn(1, 32, 512)

# Create a random image tensor of shape (1, 3, 224, 224)
img = torch.randn(1, 3, 224, 224)

# Create an instance of the QFormer model with the following parameters:
# - input_size: 512
# - num_heads: 8
# - num_layers: 8
# - dropout: 0.1
# - num_classes: 2
# - num_patches: 2
qformer = QFormer(512, 8, 8, 0.1, 2, 2)

# Apply the QFormer model to the input tensors x and img
y = qformer(x, img)

# Print the shape of the output tensor y
print(y.shape)


```
Expand Down
31 changes: 16 additions & 15 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import torch
from qformer import QFormer

x = torch.randn(
1, 32, 512
) # Create a random tensor of shape (1, 32, 512)
# Create a random tensor of shape (1, 32, 512)
x = torch.randn(1, 32, 512)

# Create a random image tensor of shape (1, 3, 224, 224)
img = torch.randn(1, 3, 224, 224)

img = torch.randn(
1, 3, 224, 224
)
# Create an instance of the QFormer model with the following parameters:
# - input_size: 512
# - num_heads: 8
# - num_layers: 8
# - dropout: 0.1
# - num_classes: 2
# - num_patches: 2
qformer = QFormer(512, 8, 8, 0.1, 2, 2)

# Apply the QFormer model to the input tensors x and img
y = qformer(x, img)

qformer = QFormer(
512, 8, 8, 0.1, 2, 2
) # Create an instance of the QFormer model

y = qformer(
x, img
) # Apply the QFormer model to the input tensors x and img

print(y.shape) # Print the shape of the output tensor y
# Print the shape of the output tensor y
print(y.shape)
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 = "qformer"
version = "0.0.4"
version = "0.0.5"
description = "qformer - Pytorch"
license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"]
Expand Down

0 comments on commit b99d578

Please sign in to comment.