Commit
·
125c44b
1
Parent(s):
cbd0404
handler
Browse files- handler.py +3 -2
handler.py
CHANGED
|
@@ -11,8 +11,9 @@ class EndpointHandler():
|
|
| 11 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 12 |
self.generator = pipeline("mask-generation", model="facebook/sam-vit-large", device=self.device)
|
| 13 |
|
| 14 |
-
def __call__(self,
|
| 15 |
-
|
|
|
|
| 16 |
outputs = self.generator(raw_image, points_per_batch=32)
|
| 17 |
masks = outputs["masks"]
|
| 18 |
data = []
|
|
|
|
| 11 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 12 |
self.generator = pipeline("mask-generation", model="facebook/sam-vit-large", device=self.device)
|
| 13 |
|
| 14 |
+
def __call__(self, data):
|
| 15 |
+
inputs = data.pop("inputs", data)
|
| 16 |
+
raw_image = Image.open(requests.get(inputs, stream=True).raw).convert("RGB")
|
| 17 |
outputs = self.generator(raw_image, points_per_batch=32)
|
| 18 |
masks = outputs["masks"]
|
| 19 |
data = []
|