This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def setup_pipeline(): | |
| pipeline = depthai.Pipeline() | |
| cam_rgb = pipeline.createColorCamera() | |
| cam_rgb.setPreviewSize(256, 256) | |
| cam_rgb.setInterleaved(False) | |
| detection_nn = pipeline.createNeuralNetwork() | |
| detection_nn.setBlobPath("./exports/test_openvino_2021.4_5shave.blob") | |
| cam_rgb.preview.link(detection_nn.input) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import blobconverter | |
| def convert_blob(name): | |
| xmlfile = os.path.join("./exports", name) + ".xml" | |
| binfile = os.path.join("./exports", name) + ".bin" | |
| blob_path = blobconverter.from_openvino( | |
| xml = xmlfile, | |
| bin = binfile, | |
| data_type = "FP16", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def optimize_model(name): | |
| optimizer_path = "/opt/intel/openvino_2020.1.023/" + \ | |
| "deployment_tools/model_optimizer/mo.py" | |
| subprocess.run(["python3", optimizer_path, | |
| "--input_model", f"./exports/{name}.onnx", | |
| "--data_type", "FP16"]) | |
| os.rename(name + ".bin", os.path.join("./exports", name + ".bin")) | |
| os.rename(name + ".xml", os.path.join("./exports", name + ".xml")) | |
| os.rename(name + ".mapping", os.path.join("./exports", name + ".mapping")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def export_test(): | |
| image = torch.ones((1, 3, 256, 256), requires_grad = False) | |
| model = Test() | |
| torch.onnx.export(model, image, "exports/test.onnx", | |
| export_params = True, | |
| opset_version = 11, | |
| do_constant_folding = True, | |
| input_names = ['input'], | |
| output_names = ['output'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Test(nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| def forward(self, x): | |
| return x / 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def main(): | |
| clear_exports() | |
| export_test() | |
| optimize_model("test") | |
| convert_blob("test") | |
| pipeline = setup_pipeline() | |
| run_pipeline(pipeline) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function toggleExtexify() { | |
| document.getElementsByClassName("extexify-pane")[0].classList.toggle("fade-out") | |
| document.getElementsByClassName("extexify-backdrop")[0].classList.toggle("fade-out") | |
| var canvas = document.getElementById("extexify-canvas"); | |
| canvas.width = canvas.clientWidth; | |
| canvas.height = canvas.clientHeight; | |
| points = [[]]; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addExtexifyPane() { | |
| const editor = document.getElementById("editor") | |
| const extexifyPane = document.createElement("div"); | |
| extexifyPane.classList.add("extexify-pane") | |
| editor.appendChild(extexifyPane) | |
| const backdrop = document.createElement("div"); | |
| backdrop.classList.add("extexify-backdrop") | |
| editor.appendChild(backdrop) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| addExtexifyButton() | |
| addExtexifyPane() | |
| addToggleExtexifyCallbacks() | |
| hideExtexify() | |
| clearCanvas() | |
| addDrawingCallbacks() |