2025-10-13 14:48:00 +02:00
|
|
|
import torch
|
2025-10-14 09:37:51 +00:00
|
|
|
from PIL import Image
|
|
|
|
|
from torchvision.transforms import ToTensor
|
|
|
|
|
|
2025-10-13 14:48:00 +02:00
|
|
|
|
|
|
|
|
def avg_color(img: torch.Tensor):
|
2025-10-14 09:37:51 +00:00
|
|
|
result = img.mean(dim=(1, 2)).tolist()
|
|
|
|
|
return tuple(result)
|
|
|
|
|
|
2025-10-13 14:48:00 +02:00
|
|
|
|
|
|
|
|
def mask(foreground: torch.Tensor, background: torch.Tensor, mask_tensor: torch.Tensor, threshold: float):
|
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
2025-10-14 09:37:51 +00:00
|
|
|
|
2025-10-13 14:48:00 +02:00
|
|
|
def add_matrix_vector(matrix: torch.Tensor, vector: torch.Tensor):
|
2025-10-14 09:37:51 +00:00
|
|
|
return matrix.add(vector)
|
|
|
|
|
|