Skip to content

Commit

Permalink
Bugfix: Removed packaging from clip which caused issues for some people
Browse files Browse the repository at this point in the history
Reverted back to numpy 1.24.3 due to install problems
  • Loading branch information
C0untFloyd committed Mar 26, 2024
1 parent cc89c5e commit 9907f1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions clip/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import urllib
import warnings
from typing import Any, Union, List
from pkg_resources import packaging

import torch
from PIL import Image
Expand All @@ -20,9 +19,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 @@ -228,10 +224,10 @@ 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"):
result = torch.zeros(len(all_tokens), context_length, dtype=torch.long)
else:
result = torch.zeros(len(all_tokens), context_length, dtype=torch.int)
#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)

for i, tokens in enumerate(all_tokens):
if len(tokens) > context_length:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--extra-index-url https://download.pytorch.org/whl/cu118

numpy==1.26.2
numpy==1.24.3
gradio==4.21.0
opencv-python==4.8.1.78
onnx==1.15.0
Expand Down

0 comments on commit 9907f1f

Please sign in to comment.