Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : load_class() path replace on windows #60

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import torch
import torch.nn.functional as F

from vidar.core.evaluator import Evaluator
from vidar.utils.config import read_config
from vidar.utils.setup import setup_arch, setup_network
from knk_vision.vidar.vidar.core.evaluator import Evaluator
from knk_vision.vidar.vidar.utils.config import read_config
from knk_vision.vidar.vidar.utils.setup import setup_arch, setup_network


def DeFiNe(pretrained=True, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions scripts/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import fire
import torch

from vidar.core.trainer import Trainer
from vidar.utils.config import read_config
from vidar.core.wrapper import Wrapper
from knk_vision.vidar.vidar.core.trainer import Trainer
from knk_vision.vidar.vidar.utils.config import read_config
from knk_vision.vidar.vidar.core.wrapper import Wrapper


def train(cfg, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions scripts/launch_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import torch.distributed as dist
import torch.multiprocessing as mp

from vidar.core.trainer import Trainer
from vidar.utils.config import read_config
from vidar.core.wrapper import Wrapper
from knk_vision.vidar.vidar.core.trainer import Trainer
from knk_vision.vidar.vidar.utils.config import read_config
from knk_vision.vidar.vidar.core.wrapper import Wrapper


def train(cfg, **kwargs):
Expand Down
8 changes: 4 additions & 4 deletions scripts/sesc_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from camviz import Draw
from camviz.objects.camera import Camera as CVCam

from vidar.arch.models.releaseSesc.SescInference import SescInference
from vidar.geometry.camera import Camera
from vidar.geometry.pose_utils import pose_vec2mat_homogeneous
from vidar.utils.viz import viz_depth
from knk_vision.vidar.vidar.arch.models.releaseSesc.SescInference import SescInference
from knk_vision.vidar.vidar.geometry.camera import Camera
from knk_vision.vidar.vidar.geometry.pose_utils import pose_vec2mat_homogeneous
from knk_vision.vidar.vidar.utils.viz import viz_depth

cam_colors = ['red', 'yel', 'gre', 'blu', 'mag', 'cya'] * 100 # Full
camera_scale = 1.
Expand Down
4 changes: 2 additions & 2 deletions vidar/arch/blocks/depth/SigmoidToInvDepth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import torch.nn as nn

from vidar.utils.decorators import iterate2
from vidar.utils.depth import inv2depth
from knk_vision.vidar.vidar.utils.decorators import iterate2
from knk_vision.vidar.vidar.utils.depth import inv2depth


class SigmoidToInvDepth(nn.Module, ABC):
Expand Down
2 changes: 1 addition & 1 deletion vidar/arch/blocks/depth/SigmoidToLogDepth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import torch.nn as nn

from vidar.utils.decorators import iterate2
from knk_vision.vidar.vidar.utils.decorators import iterate2


class SigmoidToLogDepth(nn.Module, ABC):
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/blocks/image/ViewSynthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import torch
import torch.nn as nn

from vidar.utils.flow import coords_from_optical_flow, coords_from_motion
from vidar.utils.tensor import grid_sample, interpolate
from vidar.utils.types import is_list, is_dict
from knk_vision.vidar.vidar.utils.flow import coords_from_optical_flow, coords_from_motion
from knk_vision.vidar.vidar.utils.tensor import grid_sample, interpolate
from knk_vision.vidar.vidar.utils.types import is_list, is_dict


class ViewSynthesis(nn.Module, ABC):
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/blocks/image/ViewSynthesisSelfSup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import torch
import torch.nn as nn

from vidar.utils.flow import coords_from_optical_flow
from vidar.utils.tensor import grid_sample, interpolate
from vidar.utils.types import is_list
from knk_vision.vidar.vidar.utils.flow import coords_from_optical_flow
from knk_vision.vidar.vidar.utils.tensor import grid_sample, interpolate
from knk_vision.vidar.vidar.utils.types import is_list


class ViewSynthesis(nn.Module, ABC):
Expand Down
4 changes: 2 additions & 2 deletions vidar/arch/losses/BaseLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import torch
import torch.nn as nn

from vidar.utils.tensor import same_shape, interpolate
from vidar.utils.types import is_dict, is_list
from knk_vision.vidar.vidar.utils.tensor import same_shape, interpolate
from knk_vision.vidar.vidar.utils.types import is_dict, is_list


class BaseLoss(nn.Module, ABC):
Expand Down
8 changes: 4 additions & 4 deletions vidar/arch/losses/ConsistencyLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import torch

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.data import get_mask_from_list
from vidar.utils.tensor import interpolate, same_shape, multiply_mask, masked_average
from vidar.utils.types import is_list
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.data import get_mask_from_list
from knk_vision.vidar.vidar.utils.tensor import interpolate, same_shape, multiply_mask, masked_average
from knk_vision.vidar.vidar.utils.types import is_list


class ConsistencyLoss(BaseLoss, ABC):
Expand Down
10 changes: 5 additions & 5 deletions vidar/arch/losses/MultiCamPhotometricLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import torch

from vidar.arch.losses.MultiViewPhotometricLoss import MultiViewPhotometricLoss
from vidar.arch.networks.layers.fsm.utils import coords_from_motion, warp_from_coords, mask_from_coords
from vidar.utils.depth import inv2depth
from vidar.utils.tensor import match_scales
from vidar.utils.types import is_list, is_double_list
from knk_vision.vidar.vidar.arch.losses.MultiViewPhotometricLoss import MultiViewPhotometricLoss
from knk_vision.vidar.vidar.arch.networks.layers.fsm.utils import coords_from_motion, warp_from_coords, mask_from_coords
from knk_vision.vidar.vidar.utils.depth import inv2depth
from knk_vision.vidar.vidar.utils.tensor import match_scales
from knk_vision.vidar.vidar.utils.types import is_list, is_double_list


class MultiCamPhotometricLoss(MultiViewPhotometricLoss):
Expand Down
8 changes: 4 additions & 4 deletions vidar/arch/losses/MultiViewPhotometricLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import torch.nn as nn
import torch.nn.functional as tf

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.geometry.camera import Camera
from vidar.utils.depth import inv2depth
from vidar.utils.tensor import match_scales
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.geometry.camera import Camera
from knk_vision.vidar.vidar.utils.depth import inv2depth
from knk_vision.vidar.vidar.utils.tensor import match_scales


def view_synthesis(ref_image, depth, ref_cam, cam,
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/losses/PhotometricLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import torch

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.arch.losses.SSIMLoss import SSIMLoss
from vidar.utils.tensor import interpolate
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.arch.losses.SSIMLoss import SSIMLoss
from knk_vision.vidar.vidar.utils.tensor import interpolate


class PhotometricLoss(BaseLoss, ABC):
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/losses/PoseConsistencyLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from torch import nn
from torch import linalg as LA

from vidar.utils.config import cfg_has
from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.geometry.pose_utils import \
from knk_vision.vidar.vidar.utils.config import cfg_has
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.geometry.pose_utils import \
(invert_multi_pose, pose_tensor2euler_tensor, pose_tensor2transl_vec, pose_tensor2rotmatrix, invert_pose)


Expand Down
10 changes: 5 additions & 5 deletions vidar/arch/losses/ReprojectionLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import torch

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.config import cfg_has
from vidar.utils.data import get_from_list, get_mask_from_list, get_scale_from_dict
from vidar.utils.tensor import interpolate, multiply_args, masked_average
from vidar.utils.types import is_list, is_dict
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.config import cfg_has
from knk_vision.vidar.vidar.utils.data import get_from_list, get_mask_from_list, get_scale_from_dict
from knk_vision.vidar.vidar.utils.tensor import interpolate, multiply_args, masked_average
from knk_vision.vidar.vidar.utils.types import is_list, is_dict


class ReprojectionLoss(BaseLoss, ABC):
Expand Down
2 changes: 1 addition & 1 deletion vidar/arch/losses/SSIMLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import torch
import torch.nn as nn

from vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss


class SSIMLoss(BaseLoss, ABC):
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/losses/SmoothnessLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import torch

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.data import get_mask_from_list
from vidar.utils.tensor import same_shape, interpolate_image
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.data import get_mask_from_list
from knk_vision.vidar.vidar.utils.tensor import same_shape, interpolate_image


class SmoothnessLoss(BaseLoss, ABC):
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/losses/SupervisedDepthLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import torch
import torch.nn as nn

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.data import get_mask_from_list, get_from_list
from vidar.utils.depth import depth2index, get_depth_bins, depth2inv, scale_and_shift_pred, align
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.data import get_mask_from_list, get_from_list
from knk_vision.vidar.vidar.utils.depth import depth2index, get_depth_bins, depth2inv, scale_and_shift_pred, align


def grad(x):
Expand Down
8 changes: 4 additions & 4 deletions vidar/arch/losses/SupervisedImageLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import torch.nn as nn

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.data import get_mask_from_list, get_from_list
from vidar.utils.tensor import same_shape, interpolate
from vidar.utils.types import is_list
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.data import get_mask_from_list, get_from_list
from knk_vision.vidar.vidar.utils.tensor import same_shape, interpolate
from knk_vision.vidar.vidar.utils.types import is_list


class LossWrapper(nn.Module):
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/losses/SupervisedNormalsLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import torch

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.data import get_from_list, get_mask_from_list
from vidar.utils.depth import calculate_normals
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.data import get_from_list, get_mask_from_list
from knk_vision.vidar.vidar.utils.depth import calculate_normals


def grad_mask(mask):
Expand Down
8 changes: 4 additions & 4 deletions vidar/arch/losses/SupervisedOpticalFlowLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import torch
import torch.nn as nn

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.data import get_mask_from_list, get_from_list
from vidar.utils.depth import depth2inv
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.data import get_mask_from_list, get_from_list
from knk_vision.vidar.vidar.utils.depth import depth2inv


def get_criterion(method):
Expand Down Expand Up @@ -65,7 +65,7 @@ def calculate(self, pred, gt, mask=None, soft_mask=None, logvar=None):
mask = self.interp_nearest(mask, gt)
soft_mask = self.interp_bilinear(soft_mask, gt)

from vidar.utils.write import write_image
from knk_vision.vidar.vidar.utils.write import write_image
write_image('mask.png', mask[0])

# Flatten tensors
Expand Down
6 changes: 3 additions & 3 deletions vidar/arch/losses/SupervisedSemanticLoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import torch

from vidar.arch.losses.BaseLoss import BaseLoss
from vidar.utils.tensor import same_shape, interpolate
from vidar.utils.types import is_list
from knk_vision.vidar.vidar.arch.losses.BaseLoss import BaseLoss
from knk_vision.vidar.vidar.utils.tensor import same_shape, interpolate
from knk_vision.vidar.vidar.utils.types import is_list


class SupervisedSemanticLoss(BaseLoss, ABC):
Expand Down
4 changes: 2 additions & 2 deletions vidar/arch/models/BaseModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import torch
import torch.nn as nn

from vidar.utils.config import cfg_has
from vidar.utils.types import is_dict
from knk_vision.vidar.vidar.utils.config import cfg_has
from knk_vision.vidar.vidar.utils.types import is_dict


class BaseModel(nn.Module):
Expand Down
14 changes: 7 additions & 7 deletions vidar/arch/models/define/DefineGenericModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import numpy as np
import torch

from vidar.arch.models.BaseModel import BaseModel
from vidar.arch.models.define.DefineModel import augment_canonical, create_virtual_cameras
from vidar.geometry.camera import Camera
from vidar.geometry.pose import Pose
from vidar.utils.data import flatten
from vidar.utils.types import is_list
from vidar.arch.networks.perceiver.DeFiNeNet import DeFiNeNet
from knk_vision.vidar.vidar.arch.models.BaseModel import BaseModel
from knk_vision.vidar.vidar.arch.models.define.DefineModel import augment_canonical, create_virtual_cameras
from knk_vision.vidar.vidar.geometry.camera import Camera
from knk_vision.vidar.vidar.geometry.pose import Pose
from knk_vision.vidar.vidar.utils.data import flatten
from knk_vision.vidar.vidar.utils.types import is_list
from knk_vision.vidar.vidar.arch.networks.perceiver.DeFiNeNet import DeFiNeNet


def sample_pred_gt(output, gt, pred):
Expand Down
8 changes: 4 additions & 4 deletions vidar/arch/models/define/DefineInferenceModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from abc import ABC

from vidar.arch.networks.perceiver.DeFiNeNet import DefineNet
from vidar.arch.models.BaseModel import BaseModel
from vidar.geometry.camera_nerf import CameraNerf
from vidar.geometry.pose import Pose
from knk_vision.vidar.vidar.arch.networks.perceiver.DeFiNeNet import DefineNet
from knk_vision.vidar.vidar.arch.models.BaseModel import BaseModel
from knk_vision.vidar.vidar.geometry.camera_nerf import CameraNerf
from knk_vision.vidar.vidar.geometry.pose import Pose


class DefineInferenceModel(BaseModel, ABC):
Expand Down
4 changes: 2 additions & 2 deletions vidar/arch/models/define/DefineModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import torch

from vidar.geometry.pose import Pose
from vidar.utils.types import is_int
from knk_vision.vidar.vidar.geometry.pose import Pose
from knk_vision.vidar.vidar.utils.types import is_int


def augment_canonical(pose):
Expand Down
16 changes: 8 additions & 8 deletions vidar/arch/models/depth/DepthFormerModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import torch

from vidar.arch.blocks.image.ViewSynthesis import ViewSynthesis
from vidar.arch.models.BaseModel import BaseModel
from vidar.arch.models.utils import make_rgb_scales, break_context, create_cameras
from vidar.utils.data import get_from_dict
from vidar.utils.depth import inv2depth
from vidar.utils.tensor import interpolate, multiply_args
from vidar.utils.types import is_str, is_tuple, is_list, is_dict
from knk_vision.vidar.vidar.arch.blocks.image.ViewSynthesis import ViewSynthesis
from knk_vision.vidar.vidar.arch.models.BaseModel import BaseModel
from knk_vision.vidar.vidar.arch.models.utils import make_rgb_scales, break_context, create_cameras
from knk_vision.vidar.vidar.utils.data import get_from_dict
from knk_vision.vidar.vidar.utils.depth import inv2depth
from knk_vision.vidar.vidar.utils.tensor import interpolate, multiply_args
from knk_vision.vidar.vidar.utils.types import is_str, is_tuple, is_list, is_dict


def fix_predictions(predictions):
Expand Down Expand Up @@ -339,7 +339,7 @@ def forward(self, batch, epoch=0):
cal = self.networks['multi_depth'].networks['cal']
depth1 = depth_multi[0]
depth2 = predictions['depth_regr'][0][0]
from vidar.utils.tensor import interpolate
from knk_vision.vidar.vidar.utils.tensor import interpolate
depth2 = interpolate(depth2, size=depth1.shape[-2:], scale_factor=None, mode='nearest')
predictions['depth_regr'][0].insert(0, cal(depth1, depth2, rgb))

Expand Down
2 changes: 1 addition & 1 deletion vidar/arch/models/depth/DepthModel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2023 Toyota Research Institute. All rights reserved.

from vidar.arch.models.BaseModel import BaseModel
from knk_vision.vidar.vidar.arch.models.BaseModel import BaseModel


class DepthModel(BaseModel):
Expand Down
Loading