Hi @ChrisCoutureDelValle,
you can use this script:
import requests
import multiprocessing
from typing import Union, Tuple, Literal
from uuid import uuid4
import argparse
_URL = "https://tools.luxonis.com" #"http://tools.luxonis.com/upload" _OUTPUT_FILE_NAME = "output.zip" _FRACTIONS = { "none": 0, "read": 0.1, "initialized": 0.3, "onnx": 0.5, "openvino": 0.65, "blob": 0.8, "json": 0.9, "zip": 1 }
_OUTPUT_FILE_NAME = "output.zip"
def get_progress(id: str):
while True:
try:
r = requests.get(f"{_URL}/progress/{id}")
r.raise_for_status()
data = r.json()
print(f"Progress: {data['progress']}")
if data["progress"] == 1:
break
except Exception as e:
print(f"Error: {e}")
break
def convert_yolo(file_path: str, shape: Union[int, Tuple[int, int]] = 416, version: Literal["v10"] = "v10"):
files = {'file': open(file_path, 'rb')}
values = {
'inputshape': shape if isinstance(shape, int) else " ".join(map(str, shape)),
'version': version,
'id': uuid4()
}
file_name = _OUTPUT_FILE_NAME
url = f"{_URL}/upload"
print(url)
# progress bar
proc = multiprocessing.Process(target=get_progress, args=(str(values["id"]),))
proc.start()
# upload files
session = requests.Session()
with session.post(url, files=files, data=values, stream=True) as r:
r.raise_for_status()
proc.terminate()
print(f"Conversion complete. Downloading...")
with open(file_name, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
# If you have chunk encoded response uncomment if
# and set chunk_size parameter to None.
# if chunk:
f.write(chunk)
return file_name
def main():
parser = argparse.ArgumentParser(description="Convert YOLO models")
parser.add_argument("path", type=str, help="Path to the model's weights")
args = parser.parse_args()
convert_yolo(args.path)
if __name__ == "__main__":
main()
I tested it with yolov10 nano from Ultralytics and it worked. Btw, if you'd be looking for an inspiration how to write a call api to our tools, you can check out this script.
Best,
Jan