mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
@@ -53,7 +53,7 @@ class SamDetector:
|
||||
|
||||
def __call__(self, input_image: Union[np.ndarray, Image.Image]=None, detect_resolution=512, image_resolution=512, output_type="pil", **kwargs) -> Image.Image:
|
||||
if "image" in kwargs:
|
||||
warnings.warn("image is deprecated, please use `input_image=...` instead.", DeprecationWarning, stacklevel=2)
|
||||
warnings.warn("image is deprecated, please use `input_image=...` instead.", DeprecationWarning)
|
||||
input_image = kwargs.pop("image")
|
||||
if input_image is None:
|
||||
raise ValueError("input_image must be defined.")
|
||||
|
||||
@@ -25,8 +25,8 @@ class Sam(nn.Module):
|
||||
image_encoder: Union[ImageEncoderViT, TinyViT],
|
||||
prompt_encoder: PromptEncoder,
|
||||
mask_decoder: MaskDecoder,
|
||||
pixel_mean: List[float] | None = None,
|
||||
pixel_std: List[float] | None = None,
|
||||
pixel_mean: List[float] = None,
|
||||
pixel_std: List[float] = None,
|
||||
) -> None:
|
||||
"""
|
||||
SAM predicts object masks from an image and input prompts.
|
||||
|
||||
@@ -79,7 +79,7 @@ class TwoWayTransformer(nn.Module):
|
||||
torch.Tensor: the processed image_embedding
|
||||
"""
|
||||
# BxCxHxW -> BxHWxC == B x N_image_tokens x C
|
||||
_bs, _c, _h, _w = image_embedding.shape
|
||||
bs, c, h, w = image_embedding.shape
|
||||
image_embedding = image_embedding.flatten(2).permute(0, 2, 1)
|
||||
image_pe = image_pe.flatten(2).permute(0, 2, 1)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from torch.nn import functional as F
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
from ..modeling import Sam # noqa: TID252
|
||||
from ..modeling import Sam
|
||||
from .amg import calculate_stability_score
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user