Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

Add the HEF

by roundabout, Monday, 28 April 2025, 19:48:21 (1745869701), pushed by roundabout, Monday, 28 April 2025, 19:48:27 (1745869707)

Author identity: vlad <vlad.muntoiu@gmail.com>

b7ab20ec78a7dbc0fb8c2181f7253227a0f48783

gitignore

@@ -1,2 +1,3 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            data/
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            val_data/
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        hailo/
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

hailo_conversion.py

@@ -1,5 +1,33 @@

                                
                                
                                
                            
                                
                                    
                                        
                                        import subprocess
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        import os
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            import ultralytics
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        import onnx
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        from os import path
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        model = ultralytics.YOLO("model.pt")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        model = ultralytics.YOLO("yolov8n.pt")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        model.export(format="onnx")   # Creates model.onnx
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        model.export(format="onnx", imgsz=640, opset=11)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        model = onnx.load("/home/vlad/recycle4me/yolov8n.onnx")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        print("Inputs:")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        for i in model.graph.input:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(i.name, [d.dim_value for d in i.type.tensor_type.shape.dim])
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        print("Outputs:")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        for o in model.graph.output:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(o.name, [d.dim_value for d in o.type.tensor_type.shape.dim])
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        current_dir = os.getcwd()
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        onnx_path = os.path.join(current_dir, "yolov8n.onnx")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        val_data_path = os.path.join(current_dir, "val_data")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        result = subprocess.run([
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            path.expanduser(".venv/bin/hailomz"),
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "compile",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "yolov8n",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "--hw-arch", "hailo8l",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "--ckpt", onnx_path,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "--calib-path", val_data_path,
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "--start-node-names", "images",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "--end-node-names", "output0",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            "--classes", "7",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        ], check=True)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

main.ipynb

@@ -4240,7 +4240,7 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               "cell_type": "code",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               "outputs": [],
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               "execution_count": null,
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                           "source": "torch.save(model.state_dict(), \"model.pt\")",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                           "source": "torch.save(model.state_dict(), \"yolov8n.pt\")",
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                               "id": "138880b6a127671a"
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                              },
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                              {
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

model.pt

yolov8n.hef

yolov8n.pt