forked from EleutherAI/gpt-neox
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Kaplan
committed
Apr 3, 2024
1 parent
19ba4ca
commit 148f8fc
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import torch | ||
# from .vision_encoder import get_vision_encoder | ||
# from dinov2.models import vision_transformer as vits | ||
# from megatron.model.encoders.vision.vision_encoder import get_vision_encoder | ||
import torch | ||
from PIL import Image | ||
import open_clip | ||
|
||
class Args: | ||
def __init__(self): | ||
|
||
pass | ||
|
||
def test_eva_clip_image_transformer_shapes(): | ||
|
||
device = "cuda" | ||
|
||
model, preprocess = open_clip.create_model_from_pretrained('ViT-B-16','hf-hub:timm/vit_base_patch16_224.augreg_in21k') | ||
|
||
for transform in preprocess.transforms: | ||
print(transform) | ||
# preprocess.transforms = preprocess.transforms[3:] | ||
# print(preprocess.transforms) | ||
|
||
visual = model.visual | ||
visual.trunk.output_tokens = True | ||
|
||
visual = visual.to(device) | ||
del model | ||
|
||
image_path = "dog.jpg" | ||
image = preprocess(Image.open(image_path)).unsqueeze(0).to(device) | ||
print(image.shape) | ||
|
||
pooled = visual(image) | ||
|
||
print(pooled.shape) | ||
# print(tokens.shape) | ||
|
||
|
||
|
||
def main(): | ||
|
||
|
||
test_eva_clip_image_transformer_shapes() | ||
# test_eva_clip_image_transformer() | ||
# test_dino_image_frozen_transformer() | ||
# test_dino_image_frozen_lora_transformer() | ||
# test_dino_video_transformer_basic() | ||
|
||
if __name__ == "__main__": | ||
|
||
|
||
main() |