File size: 621 Bytes
7937f0f
 
5bf3e85
7937f0f
 
 
 
5bf3e85
 
 
 
7937f0f
5bf3e85
7937f0f
 
 
 
 
 
 
 
 
 
 
 
 
 
b360716
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import torch
import torch.hub

os.environ['TORCH_HOME'] = '/tmp/torch_cache'
os.environ['YOLO_CONFIG_DIR'] = '/tmp/ultralytics_config'

# Permanently disable the trust check for ALL hub.load() calls,
# including the nested one inside MiDaS's hubconf.py
def _trust_all(*args, **kwargs):
    pass

torch.hub._check_repo_is_trusted = _trust_all

print("Pre-downloading MiDaS and dependencies...")

midas = torch.hub.load(
    "intel-isl/MiDaS",
    "MiDaS_small",
    trust_repo=True
)
transforms = torch.hub.load(
    "intel-isl/MiDaS",
    "transforms",
    trust_repo=True
)

print("MiDaS cached successfully.")