[Bug]: TypeError: keywords must be strings
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
When I run the following code with the latest (main) towhee version, it randomly shows "TypeError: keywords must be strings", and when I re-run it, it sometimes works, and sometimes it still errors.
import towhee
feat = towhee.glob('/Users/chenshiyu/workspace/data/pic/test/1.jpg') \
.image_decode() \
.image_embedding.timm(model_name='resnet50') \
.tensor_normalize() \
.to_list()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
File <timed exec>:1, in <module>
Input In [13], in Resnet501.resnet50_extract_feat(self, img_path)
13 def resnet50_extract_feat(self, img_path):
---> 14 feat = towhee.glob(img_path) \
15 .image_decode() \
16 .image_embedding.timm(model_name='resnet50') \
17 .tensor_normalize() \
18 .to_list()
19 return feat
File ~/workspace/git/towhee/towhee/hparam/hyperparameter.py:200, in DynamicDispatch.__call__(self, *args, **kws)
198 def __call__(self, *args, **kws) -> Any:
199 with param_scope(_index=self._index, _name=self._name):
--> 200 return self._func(*args, **kws)
File ~/workspace/git/towhee/towhee/functional/data_collection.py:135, in DataCollection.__getattr__.<locals>.wrapper(*arg, **kws)
133 op = self.jit_resolve(path, index, *arg, **kws)
134 else:
--> 135 with param_scope( #
136 locals={
137 k: v
138 for k, v in inspect.stack()[2]
139 [0].f_locals.items() if k != 'self'
140 },
141 globals={
142 k: v
143 for k, v in inspect.stack()[2]
144 [0].f_globals.items() if k != 'self'
145 }):
146 op = self.resolve(path, index, *arg, **kws)
147 return self.map(op)
File ~/workspace/git/towhee/towhee/hparam/hyperparameter.py:473, in param_scope.__init__(self, *args, **kws)
470 if hasattr(param_scope.tls,
471 'history') and len(param_scope.tls.history) > 0:
472 self.update(param_scope.tls.history[-1])
--> 473 self.update(kws)
474 for line in args:
475 if '=' in line:
File ~/workspace/git/towhee/towhee/hparam/hyperparameter.py:270, in HyperParameter.update(self, kws)
268 v = vv
269 else:
--> 270 v = HyperParameter(**v)
271 self[k] = v
File ~/workspace/git/towhee/towhee/hparam/hyperparameter.py:260, in HyperParameter.__init__(self, **kws)
258 def __init__(self, **kws):
259 super().__init__()
--> 260 self.update(kws)
File ~/workspace/git/towhee/towhee/hparam/hyperparameter.py:270, in HyperParameter.update(self, kws)
268 v = vv
269 else:
--> 270 v = HyperParameter(**v)
271 self[k] = v
TypeError: keywords must be strings
Expected Behavior
No response
Steps To Reproduce
No response
Environment
- Towhee version(e.g. v0.1.3 or 8b23a93):
- OS(Ubuntu or CentOS):
- CPU/Memory:
- GPU:
- Others:
Anything else?
No response
I can reproduce it, instead of random, it shows error when I define a function for the first time and then change it:
import towhee
img_path = 'my_img.png'
def resnet50_extract_feat(img_path):
feat = towhee.glob(img_path) \
.image_decode() \
.image_embedding.timm(model_name='resnet50') \
.tensor_normalize() \
.to_list()
return feat[0]
resnet50_extract_feat(img_path)
def resnet50_extract_feat(img_path):
feat = towhee.glob(img_path) \
.image_decode() \
.image_embedding.timm(model_name='resnet50') \
.tensor_normalize() \
.to_list()
return feat
resnet50_extract_feat(img_path)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Rotten issues close after 30d of inactivity. Close the stale issues and pull requests after 7 days of inactivity. Reopen the issue with /reopen.