MCPcopy Create free account
hub / github.com/aigc3d/LHM / _get_batch_size

Method _get_batch_size

engine/BiRefNet/models/modules/prompt_encoder.py:109–125  ·  view source on GitHub ↗

Gets the batch size of the output given the batch size of the input prompts.

(
        self,
        points: Optional[Tuple[torch.Tensor, torch.Tensor]],
        boxes: Optional[torch.Tensor],
        masks: Optional[torch.Tensor],
    )

Source from the content-addressed store, hash-verified

107 return mask_embedding
108
109 def _get_batch_size(
110 self,
111 points: Optional[Tuple[torch.Tensor, torch.Tensor]],
112 boxes: Optional[torch.Tensor],
113 masks: Optional[torch.Tensor],
114 ) -> int:
115 """
116 Gets the batch size of the output given the batch size of the input prompts.
117 """
118 if points is not None:
119 return points[0].shape[0]
120 elif boxes is not None:
121 return boxes.shape[0]
122 elif masks is not None:
123 return masks.shape[0]
124 else:
125 return 1
126
127 def _get_device(self) -> torch.device:
128 return self.point_embeddings[0].weight.device

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected