-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conversion of models from ultralytics/yolov8 to yours #8
Comments
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 |
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? |
Hello @jahongir7174 import torch
from ultralytics import YOLO
from nets.nn import yolo_v8_n
downloaded_weights = "yolov8n.pt"
model = YOLO(downloaded_weights)
model_nn = yolo_v8_n(num_classes=80)
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')
port_weights(model_nn, model) I would get an error |
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.
The text was updated successfully, but these errors were encountered: