-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract.py
More file actions
31 lines (23 loc) · 770 Bytes
/
Copy pathextract.py
File metadata and controls
31 lines (23 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'''
extract model shape and weights
'''
import os
import torch
from app.config import Settings
from app.face_parsing import BiSeNet
from app import face_alignment
def extract_model_feature():
'''
function
:parameter {None}: none
:return {None}: none
'''
settings = Settings()
alignment = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, flip_input=False)
torch.save(alignment, os.path.join(settings.KEEPMODEL, "face_alignment.pth"))
weight_path = "app/face_parsing/res/cp/79999_iter.pth"
parsing = BiSeNet(19)
parsing.load_state_dict(torch.load(weight_path, map_location='cpu'))
torch.save(parsing, os.path.join(settings.KEEPMODEL, 'face_parsing.pth'))
if __name__ == '__main__':
extract_model_feature()