mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-30 04:50:16 +08:00
Rename to nerfstudio (#589)
This commit is contained in:
1 parent
fae01d3ca6
commit
1f83ad03db
210 files changed
+3400
-3413
No files matched your search
@@ -0,0 +1,55 @@
|
||||
# Copyright 2022 The Plenoptix Team. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Common Colors"""
|
||||
from typing import Union
|
||||
|
||||
import torch
|
||||
from omegaconf import ListConfig
|
||||
from torchtyping import TensorType
|
||||
|
||||
WHITE = torch.tensor([1.0, 1.0, 1.0])
|
||||
BLACK = torch.tensor([0.0, 0.0, 0.0])
|
||||
RED = torch.tensor([1.0, 0.0, 0.0])
|
||||
GREEN = torch.tensor([0.0, 1.0, 0.0])
|
||||
BLUE = torch.tensor([0.0, 0.0, 1.0])
|
||||
|
||||
COLORS_DICT = {
|
||||
"white": WHITE,
|
||||
"black": BLACK,
|
||||
"red": RED,
|
||||
"green": GREEN,
|
||||
"blue": BLUE,
|
||||
}
|
||||
|
||||
|
||||
def get_color(color: Union[str, list, ListConfig]) -> TensorType[3]:
|
||||
"""
|
||||
Args:
|
||||
color (Union[str, list, ListConfig]): Color as a string or a rgb list
|
||||
|
||||
Returns:
|
||||
TensorType[3]: Parsed color
|
||||
"""
|
||||
if isinstance(color, str):
|
||||
color = color.lower()
|
||||
if color not in COLORS_DICT:
|
||||
raise ValueError(f"{color} is not a valid preset color")
|
||||
return COLORS_DICT[color]
|
||||
if isinstance(color, (list, ListConfig)):
|
||||
if len(color) != 3:
|
||||
raise ValueError(f"Color should be 3 values (RGB) instead got {color}")
|
||||
return torch.tensor(color)
|
||||
|
||||
raise ValueError(f"Color should be an RGB list or string, instead got {type(color)}")
|
||||
Reference in new issue
Block a user