TypeError: build_sam_vit_h() got an unexpected keyword argument 'device'
时间: 2023-11-20 19:06:26 浏览: 120
这个错误通常是因为函数 `build_sam_vit_h()` 中没有定义 `device` 这个关键字参数,但是在调用该函数时却传递了 `device` 参数。你可以检查一下代码中 `build_sam_vit_h()` 函数的定义,看看是否缺少了 `device` 参数的定义。如果确实缺少,你可以在函数定义中添加该参数,然后在函数体内使用它。
例如,你可以这样定义函数:
```
def build_sam_vit_h(..., device=None):
# 函数体
```
这里我们将 `device` 参数设置为默认值 `None`,以避免在没有传递 `device` 参数时出现类似的错误。然后你可以在函数体中根据需要使用 `device` 参数。
相关问题
typeerror: __init__() got an unexpected keyword argument
TypeError: __init__() got an unexpected keyword argument是一种常见的错误类型,通常是因为在调用函数或类的构造函数时,传递了不支持的参数或关键字参数。这通常是由于版本不兼容或代码错误导致的。解决此错误的方法是检查代码中的函数或类的定义,并确保传递的参数与定义匹配。如果是版本不兼容的问题,则需要升级或降级相关的库或软件。
TypeError: __init__() got an unexpected keyword argument 'degradation'
根据提供的引用内容,出现了两个不同的错误:TypeError: __init__() got an unexpected keyword argument 'autocompletion' 和 TypeError: init() got an unexpected keyword argument 'indices'。这两个错误都是因为在调用函数时传递了不支持的参数导致的。
如果出现了类似的错误TypeError: __init__() got an unexpected keyword argument 'degradation',则说明在调用某个函数时传递了不支持的参数'degradation'。解决这个问题的方法是检查代码中是否有拼写错误或者参数名错误,并确保传递的参数是函数支持的。
如果确定传递的参数是正确的,但仍然出现了这个错误,则可能是因为使用的库版本过低或者过高导致的。可以尝试更新或降低库的版本来解决这个问题。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)