hhk7734 / tensorflow-yolov4

YOLOv4 Implemented in Tensorflow 2.
MIT License
136 stars 75 forks source link

running on edge-tpu: cross platform #56

Closed chanangaza closed 3 years ago

chanangaza commented 3 years ago

First, I think this is an amazing repository. Well documented and designed.

I wish to run yolov4 with TPU on windows however, the code only supports linux runtime names.

  1. is there anything I am missing?
  2. perhaps add the following to file https://github.com/hhk7734/tensorflow-yolov4/blob/master/py_src/yolov4/tflite/__init__.py
import platform

EDGETPU_SHARED_LIB = {
  'Linux': 'libedgetpu.so.1',
  'Darwin': 'libedgetpu.1.dylib',
  'Windows': 'edgetpu.dll'
}[platform.system()]

def load_tflite(self, tflite_path: str) -> None:
        if self.tpu:
            self.interpreter = tflite.Interpreter(
                model_path=tflite_path,
                experimental_delegates=[load_delegate(EDGETPU_SHARED_LIB) # can now run on windows
            )
        else:
            self.interpreter = tflite.Interpreter(model_path=tflite_path)

thanks in advance and please let me know whether I have overlooked something here...

hhk7734 commented 3 years ago
    def load_tflite(
        self, tflite_path: str, edgetpu_lib: str = EDGETPU_SHARED_LIB
    ) -> None:
        if self.tpu:
            self.interpreter = tflite.Interpreter(
                model_path=tflite_path,
                experimental_delegates=[load_delegate(edgetpu_lib)],
            )
        else:
            self.interpreter = tflite.Interpreter(model_path=tflite_path)

How about this?

I don't have a USB accelerator. Can you test your code on Windows or Mac?

Please make PR if possible. :)

chanangaza commented 3 years ago
    def load_tflite(
        self, tflite_path: str, edgetpu_lib: str = EDGETPU_SHARED_LIB
    ) -> None:
        if self.tpu:
            self.interpreter = tflite.Interpreter(
                model_path=tflite_path,
                experimental_delegates=[load_delegate(edgetpu_lib)],
            )
        else:
            self.interpreter = tflite.Interpreter(model_path=tflite_path)

How about this?

~I don't have a USB accelerator. Can you test your code on Windows or Mac?~

Please make PR if possible. :)

this is even better;) already tested in on windows with google-coral edge-tpu USB accelerator.