From c9e7701417efd41136acd8bd58c900e1ef00b61c Mon Sep 17 00:00:00 2001 From: Ahmed Harmouche Date: Wed, 4 Dec 2024 15:23:09 +0100 Subject: [PATCH] Fast YoloV8 on WebGPU (#8036) * Fast yolov8 with downscaled input * Faster + FPS meter * Add loader while model is downloading/compiling * Title touchup --- examples/webgpu/yolov8/compile.py | 2 +- examples/webgpu/yolov8/index.html | 139 ++++++++++++++++++++++++------ 2 files changed, 115 insertions(+), 26 deletions(-) diff --git a/examples/webgpu/yolov8/compile.py b/examples/webgpu/yolov8/compile.py index 34f4780752..32097dd9cd 100644 --- a/examples/webgpu/yolov8/compile.py +++ b/examples/webgpu/yolov8/compile.py @@ -12,7 +12,7 @@ if __name__ == "__main__": yolo_infer = YOLOv8(w=0.25, r=2.0, d=0.33, num_classes=80) state_dict = safe_load(get_weights_location(yolo_variant)) load_state_dict(yolo_infer, state_dict) - prg, inp_sizes, out_sizes, state = export_model(yolo_infer, Device.DEFAULT.lower(), Tensor.randn(1,3,640,640)) + prg, inp_sizes, out_sizes, state = export_model(yolo_infer, Device.DEFAULT.lower(), Tensor.randn(1,3,256,256)) dirname = Path(__file__).parent safe_save(state, (dirname / "net.safetensors").as_posix()) with open(dirname / f"net.js", "w") as text_file: diff --git a/examples/webgpu/yolov8/index.html b/examples/webgpu/yolov8/index.html index 0bc7c8f020..e5daf83b11 100644 --- a/examples/webgpu/yolov8/index.html +++ b/examples/webgpu/yolov8/index.html @@ -1,12 +1,12 @@ - + YOLOv8 tinygrad WebGPU -

YOLOv8 tinygrad WebGPU

+

YOLOv8 tinygrad WebGPU

+
+ +
+

Loading model

+ +
-