mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-29 12:31:53 +08:00
Cleanup
This commit is contained in:
1 parent
0a8ae2fe59
commit
b79aa04b62
1 file changed
-18
@@ -17,10 +17,7 @@
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import Optional, Type
|
from typing import Optional, Type
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import numpy as np
|
|
||||||
import torch
|
import torch
|
||||||
from torch.cuda.amp import custom_bwd, custom_fwd
|
|
||||||
from torch.cuda.amp.grad_scaler import GradScaler
|
from torch.cuda.amp.grad_scaler import GradScaler
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
|
||||||
@@ -31,21 +28,6 @@ from nerfstudio.generative.stable_diffusion import StableDiffusion
|
|||||||
from nerfstudio.pipelines.base_pipeline import VanillaPipeline, VanillaPipelineConfig
|
from nerfstudio.pipelines.base_pipeline import VanillaPipeline, VanillaPipelineConfig
|
||||||
|
|
||||||
|
|
||||||
class SpecifyGradient(torch.autograd.Function):
|
|
||||||
@staticmethod
|
|
||||||
@custom_fwd
|
|
||||||
def forward(ctx, input_tensor, gt_grad):
|
|
||||||
ctx.save_for_backward(gt_grad)
|
|
||||||
return torch.zeros([], device=input_tensor.device, dtype=input_tensor.dtype)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
@custom_bwd
|
|
||||||
def backward(ctx, grad):
|
|
||||||
(gt_grad,) = ctx.saved_tensors
|
|
||||||
batch_size = len(gt_grad)
|
|
||||||
return gt_grad / batch_size, None
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DreamfusionPipelineConfig(VanillaPipelineConfig):
|
class DreamfusionPipelineConfig(VanillaPipelineConfig):
|
||||||
"""Configuration for pipeline instantiation"""
|
"""Configuration for pipeline instantiation"""
|
||||||
|
|||||||
Reference in new issue
Block a user