Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Apparent differences between results from cpu and edgetpu #92

@tino926

Description

@tino926

Hi, thanks for your wonderful work. However, I have got very different results from cpu and edgetpu. In the following image, left one is the result using cpu, and the right one is the result using edgetpu.
Untitled

These are the scripts I've used:

  1. convert weight to tflite and quantize:
from yolov4.tf import YOLOv4, YOLODataset, save_as_tflite

yolo = YOLOv4()

yolo.config.parse_names("test/coco.names")
yolo.config.parse_cfg("config/yolov4-tiny-relu-tpu.cfg")

yolo.make_model()
yolo.load_weights(
    "/home/hhk7734/NN/yolov4-tiny-relu.weights", weights_type="yolo"
)

dataset = YOLODataset(
    config=yolo.config,
    dataset_list="/home/hhk7734/NN/val2017.txt",
    image_path_prefix="/home/hhk7734/NN/val2017",
    training=False,
)

save_as_tflite(
    model=yolo.model,
    tflite_path="yolov4-tiny-relu-int8.tflite",
    quantization="full_int8",
    dataset=dataset,
)
  1. convert to edgetpu model:
    edgetpu_compiler -sa yolov4-tiny-relu-int8.tflite

  2. inference on cpu:

import cv2

from yolov4.tflite import YOLOv4

yolo = YOLOv4()

yolo.config.parse_names("test/coco.names")
yolo.config.parse_cfg("config/yolov4-tiny-relu-tpu.cfg")

yolo.summary()

yolo.load_tflite("yolov4-tiny-relu-int8.tflite")

yolo.inference("test/kite.jpg")
  1. inference on edgetpu:
import cv2

from yolov4.tflite import YOLOv4

yolo = YOLOv4()

yolo.config.parse_names("test/coco.names")
yolo.config.parse_cfg("config/yolov4-tiny-relu-tpu.cfg")

yolo.summary()

yolo.load_tflite("yolov4-tiny-relu-int8_edgetpu.tflite")

yolo.inference("test/kite.jpg")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions