|
|
|
@ -566,10 +566,6 @@ class AutoBackend(nn.Module): |
|
|
|
|
y = [y] |
|
|
|
|
elif self.pb: # GraphDef |
|
|
|
|
y = self.frozen_func(x=self.tf.constant(im)) |
|
|
|
|
if (self.task == "segment" or len(y) == 2) and len(self.names) == 999: # segments and names not defined |
|
|
|
|
ip, ib = (0, 1) if len(y[0].shape) == 4 else (1, 0) # index of protos, boxes |
|
|
|
|
nc = y[ib].shape[1] - y[ip].shape[3] - 4 # y = (1, 160, 160, 32), (1, 116, 8400) |
|
|
|
|
self.names = {i: f"class{i}" for i in range(nc)} |
|
|
|
|
else: # Lite or Edge TPU |
|
|
|
|
details = self.input_details[0] |
|
|
|
|
is_int = details["dtype"] in {np.int8, np.int16} # is TFLite quantized int8 or int16 model |
|
|
|
@ -607,6 +603,10 @@ class AutoBackend(nn.Module): |
|
|
|
|
# for x in y: |
|
|
|
|
# print(type(x), len(x)) if isinstance(x, (list, tuple)) else print(type(x), x.shape) # debug shapes |
|
|
|
|
if isinstance(y, (list, tuple)): |
|
|
|
|
if len(self.names) == 999 and (self.task == "segment" or len(y) == 2): # segments and names not defined |
|
|
|
|
ip, ib = (0, 1) if len(y[0].shape) == 4 else (1, 0) # index of protos, boxes |
|
|
|
|
nc = y[ib].shape[1] - y[ip].shape[3] - 4 # y = (1, 160, 160, 32), (1, 116, 8400) |
|
|
|
|
self.names = {i: f"class{i}" for i in range(nc)} |
|
|
|
|
return self.from_numpy(y[0]) if len(y) == 1 else [self.from_numpy(x) for x in y] |
|
|
|
|
else: |
|
|
|
|
return self.from_numpy(y) |
|
|
|
|