Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_model :error:'str' object has no attribute 'get' #92

Open
bupianlizhugui opened this issue Sep 5, 2024 · 0 comments
Open

get_model :error:'str' object has no attribute 'get' #92

bupianlizhugui opened this issue Sep 5, 2024 · 0 comments

Comments

@bupianlizhugui
Copy link

from uform import get_model, Modality
import torch.nn as nn

encoders, processors = get_model('unum-cloud/uform-vl-multilingual-v2',backend='torch')

model_text = models[Modality.TEXT_ENCODER]
model_image = models[Modality.IMAGE_ENCODER]
processor_text = processors[Modality.TEXT_ENCODER]
processor_image = processors[Modality.IMAGE_ENCODER]

model_text.return_features = False
model_image.return_features = False
model_text_parallel = nn.DataParallel(model_text)
model_image_parallel = nn.DataParallel(model_image)

error:


AttributeError Traceback (most recent call last)
Cell In[41], line 4
1 from uform import get_model, Modality
2 import torch.nn as nn
----> 4 encoders, processors = get_model('unum-cloud/uform-vl-multilingual-v2',backend='torch')
6 model_text = models[Modality.TEXT_ENCODER]
7 model_image = models[Modality.IMAGE_ENCODER]

File /opt/conda/envs/uform/lib/python3.10/site-packages/uform/init.py:189, in get_model(model_name, device, backend, modalities, token)
187 return get_model_onnx(model_name, device=device, token=token, modalities=modalities)
188 elif backend == "torch":
--> 189 return get_model_torch(model_name, device=device, token=token, modalities=modalities)
190 else:
191 raise ValueError(f"Unknown backend: {backend}")

File /opt/conda/envs/uform/lib/python3.10/site-packages/uform/init.py:113, in get_model_torch(model_name, token, device, modalities)
111 if Modality.TEXT_ENCODER in modalities:
112 processor = TextProcessor(config_path, tokenizer_path)
--> 113 encoder = TextEncoder.from_pretrained(config_path, modality_paths.get(Modality.TEXT_ENCODER))
114 encoder = encoder.eval().to(device)
115 result_processors[Modality.TEXT_ENCODER] = processor

AttributeError: 'str' object has no attribute 'get'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant