jahongir7174 / YOLOv8-pt

YOLOv8 implementation using PyTorch
GNU Affero General Public License v3.0
112 stars 22 forks source link

conversion of models from ultralytics/yolov8 to yours #8

Open mahaling opened 10 months ago

mahaling commented 10 months ago

Can you share insights/code to convert ultralytics models to your version of yolo. I am specifically looking for conversion of yolov8. These are different from the base models you have provided.

jahongir7174 commented 10 months ago
def port_weights(model1, model2):
    model1.eval()
    model2.eval()
    with torch.no_grad():
        m1_std = model1.state_dict().values()
        m2_std = model2.state_dict().values()
        for m1, m2 in zip(m1_std, m2_std):
            m1.copy_(m2)
    state = {'model': model1.half()}
    torch.save(state, 'weights/bestpt')

model1 is the dst model model2 is the src model

mahaling commented 10 months ago

Thanks for this piece of code. But it looks like the architecture of ultralytics' YOLO is different from what your code has. Can you please confirm?