ultralytics 8.0.53
DDP AMP and Edge TPU fixes (#1362)
Co-authored-by: Richard Aljaste <richardaljasteabramson@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Vuong Kha Sieu <75152429+hotfur@users.noreply.github.com>
This commit is contained in:
@ -332,13 +332,6 @@ class AutoBackend(nn.Module):
|
||||
y = [self.bindings[x].data for x in sorted(self.output_names)]
|
||||
elif self.coreml: # CoreML
|
||||
im = im[0].cpu().numpy()
|
||||
if self.task == 'classify':
|
||||
from ultralytics.yolo.data.utils import IMAGENET_MEAN, IMAGENET_STD
|
||||
|
||||
# im_pil = Image.fromarray(((im / 6 + 0.5) * 255).astype('uint8'))
|
||||
for i in range(3):
|
||||
im[..., i] *= IMAGENET_STD[i]
|
||||
im[..., i] += IMAGENET_MEAN[i]
|
||||
im_pil = Image.fromarray((im * 255).astype('uint8'))
|
||||
# im = im.resize((192, 320), Image.ANTIALIAS)
|
||||
y = self.model.predict({'image': im_pil}) # coordinates are xywh normalized
|
||||
@ -371,10 +364,10 @@ class AutoBackend(nn.Module):
|
||||
self.names = {i: f'class{i}' for i in range(nc)}
|
||||
else: # Lite or Edge TPU
|
||||
input = self.input_details[0]
|
||||
int8 = input['dtype'] == np.uint8 # is TFLite quantized uint8 model
|
||||
int8 = input['dtype'] == np.int8 # is TFLite quantized int8 model
|
||||
if int8:
|
||||
scale, zero_point = input['quantization']
|
||||
im = (im / scale + zero_point).astype(np.uint8) # de-scale
|
||||
im = (im / scale + zero_point).astype(np.int8) # de-scale
|
||||
self.interpreter.set_tensor(input['index'], im)
|
||||
self.interpreter.invoke()
|
||||
y = []
|
||||
|
Reference in New Issue
Block a user