mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
@@ -2,6 +2,7 @@
|
||||
|
||||
import cv2
|
||||
import os
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
from torchvision.transforms import Compose
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from .vit import (
|
||||
_make_pretrained_vitb_rn50_384,
|
||||
_make_pretrained_vitl16_384,
|
||||
_make_pretrained_vitb16_384,
|
||||
forward_vit,
|
||||
)
|
||||
|
||||
def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ignore",):
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
|
||||
from .base_model import BaseModel
|
||||
from .blocks import (
|
||||
FeatureFusionBlock,
|
||||
FeatureFusionBlock_custom,
|
||||
Interpolate,
|
||||
_make_encoder,
|
||||
|
||||
@@ -6,7 +6,7 @@ import torch
|
||||
import torch.nn as nn
|
||||
|
||||
from .base_model import BaseModel
|
||||
from .blocks import FeatureFusionBlock_custom, Interpolate, _make_encoder
|
||||
from .blocks import FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder
|
||||
|
||||
|
||||
class MidasNet_small(BaseModel):
|
||||
|
||||
@@ -54,7 +54,7 @@ class Transpose(nn.Module):
|
||||
|
||||
|
||||
def forward_vit(pretrained, x):
|
||||
_b, _c, h, w = x.shape
|
||||
b, c, h, w = x.shape
|
||||
|
||||
pretrained.model.forward_flex(x)
|
||||
|
||||
@@ -115,7 +115,7 @@ def _resize_pos_embed(self, posemb, gs_h, gs_w):
|
||||
|
||||
|
||||
def forward_flex(self, x):
|
||||
_b, _c, h, w = x.shape
|
||||
b, c, h, w = x.shape
|
||||
|
||||
pos_embed = self._resize_pos_embed(
|
||||
self.pos_embed, h // self.patch_size[1], w // self.patch_size[0]
|
||||
|
||||
@@ -75,7 +75,7 @@ def write_pfm(path, image, scale=1):
|
||||
if len(image.shape) == 3 and image.shape[2] == 3: # color image
|
||||
color = True
|
||||
elif (
|
||||
len(image.shape) == 2 or (len(image.shape) == 3 and image.shape[2] == 1)
|
||||
len(image.shape) == 2 or len(image.shape) == 3 and image.shape[2] == 1
|
||||
): # greyscale
|
||||
color = False
|
||||
else:
|
||||
@@ -86,7 +86,7 @@ def write_pfm(path, image, scale=1):
|
||||
|
||||
endian = image.dtype.byteorder
|
||||
|
||||
if endian == "<" or (endian == "=" and sys.byteorder == "little"):
|
||||
if endian == "<" or endian == "=" and sys.byteorder == "little":
|
||||
scale = -scale
|
||||
|
||||
file.write("%f\n".encode() % scale)
|
||||
|
||||
Reference in New Issue
Block a user