ZoeDepth
ZoeDepth copied to clipboard
Can we load model from local with out internet?
I just follow the #9, but the code still need the internet? conf = get_config("zoedepth", "infer", pretrained_resource="local::/path/to/checkpoint.pt") model_zoe_n = build_model(conf)
I just want to know how inference the image without the internet? Could please give some advices?
+1
可以离线,需要修改下配置就可以
| | 钱文明 | | @.*** | 签名由网易邮箱大师定制
On 01/23/2024 14:03,Wenyuan @.***> wrote:
any ideas now?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
MiDaS repository is also downloaded from the Internet. https://github.com/isl-org/ZoeDepth/blob/edb6daf45458569e24f50250ef1ed08c015f17a7/zoedepth/models/base_models/midas.py#L341-L342
Also, torch.hub.load
accesses the Internet to get the main branch name(main or master) if the branch name is not specified, even if the repository cache exists.
(However, in this case, unsuccessful Internet access does not result in an error)
If you want to stop access to the Internet completely, you will need to change the code.
@nagadomi
MiDaS repository is also downloaded from the Internet.
https://github.com/isl-org/ZoeDepth/blob/edb6daf45458569e24f50250ef1ed08c015f17a7/zoedepth/models/base_models/midas.py#L341-L342
Also,
torch.hub.load
accesses the Internet to get the main branch name(main or master) if the branch name is not specified, even if the repository cache exists. (However, in this case, unsuccessful Internet access does not result in an error) If you want to stop access to the Internet completely, you will need to change the code.
Yes , you are correct , I have modified it
midas = DPTDepthModel( path="dpt_beit_large_384.pt", backbone="beitl16_384", non_negative=True, )
it works for me
@nagadomi
MiDaS repository is also downloaded from the Internet. https://github.com/isl-org/ZoeDepth/blob/edb6daf45458569e24f50250ef1ed08c015f17a7/zoedepth/models/base_models/midas.py#L341-L342
Also,
torch.hub.load
accesses the Internet to get the main branch name(main or master) if the branch name is not specified, even if the repository cache exists. (However, in this case, unsuccessful Internet access does not result in an error) If you want to stop access to the Internet completely, you will need to change the code.Yes , you are correct , I have modified it
midas = DPTDepthModel( path="dpt_beit_large_384.pt", backbone="beitl16_384", non_negative=True, )
it works for me
I modified the code as you said, but there's still a problem. Because DPTDepthModel
is in ~/.cache/torch/hub/intel-isl_MiDaS_master/midas/dpt_depth.py
, I tried several ways to import it in midas.py
but they all failed. I wonder how you solved this problem. Maybe I should change the path of Midas model?
@nagadomi I changed the code ZoeDepth/zoedepth/models/base_models/midas.py
Lines 341 to 342 in edb6daf
midas = torch.hub.load("intel-isl/MiDaS", midas_model_type,
pretrained=use_pretrained_midas, force_reload=force_reload)
to
local_repo_path = '/root/.cache/torch/hub/intel-isl_MiDaS_master' # 替换为实际路径
midas = torch.hub.load(local_repo_path, midas_model_type, source='local')
and
Downloading: "https://github.com/isl-org/MiDaS/releases/download/v3_1/dpt_beit_large_384.pt" to /root/.cache/torch/hub/checkpoints/dpt_beit_large_384.pt
or
vim /root/.cache/torch/hub/intel-isl_MiDaS_master/hubconf.py
change Lines 44 to 52
if pretrained:
checkpoint = (
"local_weights/dpt_beit_large_384.pt"
)
state_dict = torch.load(checkpoint, map_location=torch.device('cpu'))
# state_dict = torch.hub.load_state_dict_from_url(
# checkpoint, map_location=torch.device('cpu'), progress=True, check_hash=True
# )
model.load_state_dict(state_dict)
return model
Load successfully in the absence of network