7 days later

Hi Team,

Just a quick follow up, what do I need to change here? Last used this for v7.

Code:
_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 }

`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`

Output:
https://tools.luxonis.com/upload

Progress

HTTP error occurred: 520 Server Error: UNKNOWN for url: https://tools.luxonis.com/upload

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

    JanCuhel

    Hi Jan,

    I used the script that you sent over to try and convert a custom yolov10n model that I trained and got the same error as Chris. Do you know why I could still be getting this error?

    Thanks,

    Arnav

    This seems like that your models are for some reason not compatible with the ones we are testing on. Could you please (both of you @ChrisCoutureDelValle and @arnavaggs) provide us with more information, for example, specify what is the source of the model you've used (e.g. did you downloaded from Ultralytics)? It would help me a lot if you'd share your models with me, so that I could take a closer look. You can either share it with me via Google Drive or you can send it to me via email. My email is jan.cuhel@luxonis.com.

    Best,
    Jan

      JanCuhel I see that for the unit test, the Luxonis team is leveraging these weights. I have been using the weights directly from the yolov10 repo, should the weights from the v10 repo and ultralytics weights not be identical?

      `'yolov10n': 'https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov10n.pt',`

      'yolov10s': 'https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov10s.pt',

      'yolov10m': 'https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov10m.pt',

      'yolov10b': 'https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov10b.pt',

      'yolov10l': 'https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov10l.pt',

      'yolov10x': 'https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov10x.pt',

      JanCuhel Hi Jan, just as a follow up I attempted to upload a custom model trained on the ultralytics weights in the same fashion and ran into the same error.

      In addition when manually uploading the custom v10 weights from the ultralytics weights and the standard v10 weights and this is the error that occurs, I believe there may possibly be an error in the backend when detecting the custom v10 weights?
      Automatic version detected: YoloV8 (detection only)

        JanCuhel When I try to manually select the YOLOv10 export option with the weights, I get this in response "Automatic version detected: YoloV8 (detection only)".

          JanCuhel

          I will email you sample output weights, training is as follows with the best.pt weights selected.

          d_config = int(dataset_config["epochs"])`

          y_pths = str(dataset_config["yaml"])

          wtgs = str(dataset_config["weights"])

          batch_size = 32

          img_size = 640

          train_cmd = f'yolo detect train model=weights/{wtgs} data={y_pths} batch={batch_size} epochs={d_config} imgsz={img_size} workers=8 device=0 name={x_name}'

          ChrisCoutureDelValle

          and do you manually select the export version, did you do it after uploading the weights or before? You must do it only after the weights are uploaded, because whenever a model's weights are uploaded the automatic version detector is executed to suggest you a detection version, however you are still free to choose whatever export option you want.

            Hi @ChrisCoutureDelValle and @arnavaggs,

            Apologies, I somehow didn't notice your messages. As I already wrote you via email, we found the source of the issue and are currently in the stage of implementing the fix into our tools. As soon as the fix will be deployed, I'll let you know. It should be in the following days.

            Best,
            Jan