Skip to content

Commit dcba3cb

Browse files
JamieMartinJamiejongwook
authored
import packaging to be compatible with setuptools==70.0.0 (#449)
* import packaging to be compatible with setuptools==70.0.0 * importing the version module --------- Co-authored-by: Jamie <[email protected]> Co-authored-by: Jong Wook Kim <[email protected]>
1 parent a1d0717 commit dcba3cb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

clip/clip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import os
33
import urllib
44
import warnings
5-
from typing import Any, Union, List
6-
from pkg_resources import packaging
5+
from packaging import version
6+
from typing import Union, List
77

88
import torch
99
from PIL import Image
@@ -20,7 +20,7 @@
2020
BICUBIC = Image.BICUBIC
2121

2222

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

2626

@@ -228,7 +228,7 @@ def tokenize(texts: Union[str, List[str]], context_length: int = 77, truncate: b
228228
sot_token = _tokenizer.encoder["<|startoftext|>"]
229229
eot_token = _tokenizer.encoder["<|endoftext|>"]
230230
all_tokens = [[sot_token] + _tokenizer.encode(text) + [eot_token] for text in texts]
231-
if packaging.version.parse(torch.__version__) < packaging.version.parse("1.8.0"):
231+
if version.parse(torch.__version__) < version.parse("1.8.0"):
232232
result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
233233
else:
234234
result = torch.zeros(len(all_tokens), context_length, dtype=torch.int)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ftfy
2+
packaging
23
regex
34
tqdm
45
torch

0 commit comments

Comments
 (0)