forked from WalterSimoncini/grounded-diffusers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.py
67 lines (58 loc) · 1.61 KB
/
data.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import torch
import numpy as np
from typing import Dict, List
class SegmentationSample:
"""
Class used for a segmentation sample
with one semantic class
"""
def __init__(
self,
image: np.ndarray,
mask: np.ndarray,
unet_features: Dict[str, List[torch.Tensor]],
label: str
) -> None:
self.image = image
self.mask = mask
self.unet_features = unet_features
self.label = label
class MultiClassSegmentationSample:
"""
Class used for a segmentation sample
with multiple semantic classes
"""
def __init__(
self,
image: np.ndarray,
masks: np.ndarray,
unet_features: Dict[str, List[torch.Tensor]],
labels: List[str]
) -> None:
self.image = image
self.masks = masks
self.unet_features = unet_features
self.labels = labels
class PromptsMultiClassSegmentationSample(MultiClassSegmentationSample):
"""
Class used for a segmentation sample
with multiple semantic classes and
prompts with visual adjectives
"""
def __init__(
self,
image: np.ndarray,
masks: np.ndarray,
unet_features: Dict[str, List[torch.Tensor]],
labels: List[str],
visual_labels: List[str],
camera_parameters: List[str]
) -> None:
super().__init__(
image=image,
masks=masks,
unet_features=unet_features,
labels=labels
)
self.visual_labels = visual_labels
self.camera_parameters = camera_parameters