Increased GPU usage
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
import torch
|
||||
import sys
|
||||
sys.path.insert(0,'./facelib/detection/yolov5face')
|
||||
model = torch.load('facelib/detection/yolov5face/yolov5n-face.pt', map_location='cpu')['model']
|
||||
torch.save(model.state_dict(),'weights/facelib/yolov5n-face.pth')
|
||||
import os
|
||||
|
||||
# Setup dynamic device selection
|
||||
if torch.cuda.is_available():
|
||||
device = torch.device("cuda")
|
||||
elif torch.backends.mps.is_available():
|
||||
device = torch.device("mps")
|
||||
else:
|
||||
device = torch.device("cpu")
|
||||
|
||||
sys.path.insert(0, './facelib/detection/yolov5face')
|
||||
|
||||
# Load the model to the selected device
|
||||
ckpt = torch.load('facelib/detection/yolov5face/yolov5n-face.pt', map_location=device)
|
||||
model = ckpt['model'].to(device)
|
||||
|
||||
# Save only the weights
|
||||
os.makedirs('weights/facelib', exist_ok=True)
|
||||
torch.save(model.state_dict(), 'weights/facelib/yolov5n-face.pth')
|
||||
Reference in New Issue
Block a user