Skip to content

Commit

Permalink
importing the version module
Browse files Browse the repository at this point in the history
  • Loading branch information
jongwook committed Jun 3, 2024
1 parent e5693f4 commit 3e6026f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clip/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
import urllib
import warnings
from typing import Any, Union, List
import packaging
from packaging import version
from typing import Union, List

import torch
from PIL import Image
Expand All @@ -20,7 +20,7 @@
BICUBIC = Image.BICUBIC


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


Expand Down Expand Up @@ -228,7 +228,7 @@ def tokenize(texts: Union[str, List[str]], context_length: int = 77, truncate: b
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"):
if version.parse(torch.__version__) < 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)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ftfy
packaging
regex
tqdm
torch
Expand Down

0 comments on commit 3e6026f

Please sign in to comment.