Skip to content

Commit

Permalink
fix: remove unnecessary version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedrennan committed Apr 18, 2024
1 parent e2bc41e commit 69b90ec
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions imaginairy/vendored/clip/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import torch
from PIL import Image
from pkg_resources import packaging
from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor
from tqdm import tqdm

Expand All @@ -23,9 +22,6 @@
BICUBIC = Image.BICUBIC


if packaging.version.parse(torch.__version__) < packaging.version.parse("1.7.1"):
warnings.warn("PyTorch version 1.7.1 or higher is recommended")


__all__ = ["available_models", "load", "tokenize"]
_tokenizer = _Tokenizer()
Expand Down Expand Up @@ -272,10 +268,7 @@ def tokenize(
sot_token = _tokenizer.encoder["<|startoftext|>"]
eot_token = _tokenizer.encoder["<|endoftext|>"]
all_tokens = [[sot_token] + _tokenizer.encode(text) + [eot_token] for text in texts]
if packaging.version.parse(torch.__version__) < packaging.version.parse("1.8.0"):
result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
else:
result = torch.zeros(len(all_tokens), context_length, dtype=torch.int)
result = torch.zeros(len(all_tokens), context_length, dtype=torch.int)

for i, tokens in enumerate(all_tokens):
if len(tokens) > context_length:
Expand Down

0 comments on commit 69b90ec

Please sign in to comment.