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
# torch==2.3.1 | |
# ultralytics==8.2.35 | |
import torch | |
from ultralytics.models.yolo import YOLO | |
torch.manual_seed(42) | |
def run_yolo(torch_fx, inputs): | |
yolo_model = YOLO("yolov8n") |
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
# torch==2.3.1 | |
# ultralytics==8.2.35 | |
from typing import Dict, Tuple | |
import numpy as np | |
import torch | |
from tqdm import tqdm | |
from ultralytics.data.utils import check_det_dataset | |
from ultralytics.engine.validator import BaseValidator as Validator | |
from ultralytics.models.yolo import YOLO |
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 sys | |
import json | |
from collections import defaultdict | |
import numpy as np | |
def main(): | |
path = sys.argv[1] | |
with open(path, 'r') as f: | |
data = json.load(f) |
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 os | |
import sys | |
import json | |
import xml.etree.ElementTree as ET | |
def get_json_name_map(model_path_before, model_path_after, output_path): | |
attrs_to_check = ['type'] | |
attr_to_map = 'name' | |
root_before = ET.parse(model_path_before).getroot() |
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 xml.etree.ElementTree as ET | |
root = ET.parse('openvino.xml').getroot() | |
layers = root[0] | |
for idx, l in enumerate(layers): | |
if l.get('type') == 'Interpolate': | |
if layers[idx + 1].get('type') in ['Add', 'Multiply']: | |
print(layers[idx + 1].get('name'))#, layers[idx + 1].get('type')) |
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
# Openvino==2022.2.0 | |
import sys | |
import numpy as np | |
from openvino.runtime import Core | |
if len(sys.argv) < 3: | |
print("Please provide path to model xml file as a first arg and" | |
" path to output text file to dump model constants.") |
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 sys | |
from openvino.frontend import FrontEndManager | |
from openvino.offline_transformations import apply_pruning_transformation | |
from openvino.runtime import serialize | |
print(f'input model path {sys.argv[1]} \n output model path {sys.argv[2]}.xml \n output model weights {sys.argv[2]}.bin') | |
input_model = sys.argv[1] | |
fem = FrontEndManager() |
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
# Openvino==2022.1.0 | |
import sys | |
from openvino.runtime import Core | |
DELIMITER = ' | ' | |
if len(sys.argv) < 3: | |
print("Please provide path to model xml file as a first arg and" | |
" path to output text file to dump model constants.") |