File size: 1,056 Bytes
11ccb1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# # based on https://github.com/isl-org/MiDaS
# # Third-party model: Midas depth estimation model.
#
# import cv2
# import torch
# import torch.nn as nn
#
#
# from torchvision.transforms import Compose
#
#
#
#
# # OLD_ISL_PATHS = {
# #     "dpt_large": os.path.join(old_modeldir, "dpt_large-midas-2f21e586.pt"),
# #     "dpt_hybrid": os.path.join(old_modeldir, "dpt_hybrid-midas-501f0c75.pt"),
# #     "midas_v21": "",
# #     "midas_v21_small": "",
# # }
#
#
# def disabled_train(self, mode=True):
#     """Overwrite model.train with this function to make sure train/eval mode
#     does not change anymore."""
#     return self
#
#
#
#
#
#
#
#
#
# class MiDaSInference(nn.Module):
#
#
#     def __init__(self, model_type):
#         super().__init__()
#         assert (model_type in self.MODEL_TYPES_ISL)
#         model, _ = load_model(model_type)
#         self.model = model
#         self.model.train = disabled_train
#
#     def forward(self, x):
#         with torch.no_grad():
#             prediction = self.model(x)
#         return prediction