You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### 1. Find the closest face pose from a video compared to a given image wiht a facefromscipy.spatialimportConvexHulldeffind_best_frame(source, driving, cpu=False):
importface_alignmentdefnormalize_kp(kp):
kp=kp-kp.mean(axis=0, keepdims=True)
area=ConvexHull(kp[:, :2]).volumearea=np.sqrt(area)
kp[:, :2] =kp[:, :2] /areareturnkpfa=face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=True,
device='cpu'ifcpuelse'cuda')
kp_source=fa.get_landmarks(255*source)[0]
kp_source=normalize_kp(kp_source)
norm=float('inf')
frame_num=0fori, imageintqdm(enumerate(driving)):
kp_driving=fa.get_landmarks(255*image)[0]
kp_driving=normalize_kp(kp_driving)
new_norm= (np.abs(kp_source-kp_driving) **2).sum()
ifnew_norm<norm:
norm=new_normframe_num=ireturnframe_num
deffunc(arg1, arg2, arg3):
print(arg1)
print(arg2)
print(arg3)
l= ['one', 'two', 'three']
func(*l)
# one# two# threefunc(*['one', 'two', 'three'])
# one# two# threet= ('one', 'two', 'three')
func(*t)
# one# two# threefunc(*('one', 'two', 'three'))
# one# two# three# When specifying a dictionary (dict) with ** as an argument, key will be expanded as an argument name and value as the value of the argument. Each element will be passed as keyword arguments.deffunc(arg1, arg2, arg3):
print(arg1)
print(arg2)
print(arg3)
d= {'arg1': 'one', 'arg2': 'two', 'arg3': 'three'}
func(**d)
# one# two# threefunc(**{'arg1': 'one', 'arg2': 'two', 'arg3': 'three'})
# one# two# three
Git
### Revion - a tracked state of project. Every revion has it's own sha-1 hash
### Rebase // copy new commits from one branch to another
(master) git rebase developement
### Lightweight tag // a user friendly name pointer to a commit
git tag awesome_tag_name
(master) git rebase developement
### Remotes
There is nothing special about remotes. Same revisions, with their own unique hashes are stored in your local git repository when you fetch changes. References to remote branches are automatically created, based on name of remote branch, and prepended with the name of remote.