Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
refactor(encoder): no for loop in torch encoder now
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Aug 26, 2019
1 parent 37ca2f6 commit 5253827
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions gnes/encoder/image/torchvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,9 @@ def _encode(_, img: List['np.ndarray']):
if self._use_cuda:
img_tensor = img_tensor.cuda()

result_npy = []
for t in img_tensor:
t = torch.unsqueeze(t, 0)
encodes = self._model(t)
encodes = torch.squeeze(encodes, 0)
result_npy.append(encodes.data.cpu().numpy())

output = np.array(result_npy, dtype=np.float32)
encodes = self._model(img_tensor)

output = np.array(encodes.data.cpu().numpy(), dtype=np.float32)
return output

output = _encode(self, img)
Expand Down

0 comments on commit 5253827

Please sign in to comment.