Skip to content

Instantly share code, notes, and snippets.

@iejMac
Last active August 27, 2022 01:15
Show Gist options
  • Save iejMac/97d77b4c113babed0f7f8516dfe446bf to your computer and use it in GitHub Desktop.
Save iejMac/97d77b4c113babed0f7f8516dfe446bf to your computer and use it in GitHub Desktop.
import time
import torch
import open_clip
from data import get_data
from params import parse_args
# Args
args = parse_args()
dev = "cuda"
# Model
model_l, _, preprocess = open_clip.create_model_and_transforms('ViT-L-14', pretrained='laion400m_e32')
model_l = model_l.to(dev)
images = torch.randn((256, 3, 224, 224)).to(dev)
texts = torch.ones((256, 77), dtype=int).to(dev)
for i in range(5):
t0 = time.time()
with torch.no_grad():
_, _, _ = model_l(images, texts)
tf = time.time()
print(images.shape[0]/(tf-t0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment