Skip to content

Commit

Permalink
chore(example): fix pfp example workarount for 0.3.2 sdk id changed i…
Browse files Browse the repository at this point in the history
…ssue (#1551)

fix pfp example with 0.3.2 sdk id changed
  • Loading branch information
tianweidut authored Nov 23, 2022
1 parent b3172b1 commit b9ed335
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions example/PennFudanPed/pfp/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ def __init__(self) -> None:
super().__init__()

@torch.no_grad()
def ppl(self, img: Image, index: int, **kw):
def ppl(self, img: Image, index: str, **kw):
index = index.split("_")[-1]
_img = PILImage.open(io.BytesIO(img.to_bytes())).convert("RGB")
_tensor = functional.to_tensor(_img).to(self.device)
output = self.model(torch.stack([_tensor]))
return index, self._post(index, output[0])

def _post(self, index: int, pred: t.Dict[str, torch.Tensor]) -> t.Dict[str, t.Any]:
def _post(self, index: str, pred: t.Dict[str, torch.Tensor]) -> t.Dict[str, t.Any]:
output = {}
pred = {k: v.cpu() for k, v in pred.items()}
for typ in self.iou_types:
Expand Down

0 comments on commit b9ed335

Please sign in to comment.