Closed mrk-andreev closed 1 year ago
Did you try installing transformers first?
Did you try installing transformers first?
No, the first line that I evaluated in notebook is
!pip install open_clip_torch==2.12.0
After that I tried to import open_clip
import open_clip
Did you try installing transformers first?
No, the first line that I evaluated in notebook is
!pip install open_clip_torch==2.12.0
After that I tried to import open_clip
import open_clip
if you install transformers it will work, otherwise I opened a PR to fix it, sorry it is not working correctly
if you install transformers it will work, otherwise I opened a PR to fix it, sorry it is not working correctly
After install pytorch-transformers
!pip install pytorch-transformers==1.2.0
!pip install open_clip_torch==2.12.0
Error still happens:
import open_clip
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
[<ipython-input-3-0270bfd9aba4>](https://localhost:8080/#) in <module>
----> 1 import open_clip
1 frames
[/usr/local/lib/python3.8/dist-packages/open_clip/coca_model.py](https://localhost:8080/#) in <module>
30
31 GENERATION_TYPES = {
---> 32 "top_k": TopKLogitsWarper,
33 "top_p": TopPLogitsWarper,
34 "beam_search": "beam_search"
NameError: name 'TopKLogitsWarper' is not defined
You have to know that in open_clip_torch==2.11.0
import works fine
But after
!pip install transformers==4.26.1
import works fine
yeah the fix should be this #421.
I think using pip install pytorch-transformers
gets you an old version of transformers while installing the latest, as you just said works. Sorry again
@mrk-andreev should be fixed now on main branch, if there are any other transformers or other deps issues on main please ping (@) me on this issue ASAP and i'll resolve
FYI pytorch-transformers
is and old artifact, it's transformers
@rwightman , FYI
in requirements-test.txt
deps transformers
presented but not in requirements.txt
Probably, skipping errors such as ImportError is bad practice because you don't know what you have to install as extra.
except ImportError as e:
pass
Moreover,
try:
from transformers import (
BeamSearchScorer,
LogitsProcessorList,
TopPLogitsWarper,
TopKLogitsWarper,
RepetitionPenaltyLogitsProcessor,
MinLengthLogitsProcessor,
MaxLengthCriteria,
StoppingCriteriaList
)
GENERATION_TYPES = {
"top_k": TopKLogitsWarper,
"top_p": TopPLogitsWarper,
"beam_search": "beam_search"
}
except ImportError as e:
pass
May produce NameError: name 'GENERATION_TYPES' is not defined
in lines:
logit_warper = GENERATION_TYPES[generation_type](top_p)
@mrk-andreev it's fairly standard to have optional imports handled this way, good point re generation types I'll add an empty dict, I tend to log somewhere when the option functionality is used (if the import isn't there to say 'please install transformers for this functionality'), doesn't look like that's done here
@mrk-andreev FYI I defined the dict in catch block, I tested basic functionality w/o transformers installed and it's; able to load models, etc without any issues
Example colab notebook
Error
Env
Google colab