MCPcopy
hub / github.com/visomaster/VisoMaster / process_frame

Method process_frame

app/processors/workers/frame_worker.py:90–205  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

88
89 # @misc_helpers.benchmark
90 def process_frame(self):
91 # Load frame into VRAM
92 img = torch.from_numpy(self.frame.astype('uint8')).to(self.models_processor.device) #HxWxc
93 img = img.permute(2,0,1)#cxHxW
94
95 #Scale up frame if it is smaller than 512
96 img_x = img.size()[2]
97 img_y = img.size()[1]
98
99 # det_scale = 1.0
100 if img_x<512 and img_y<512:
101 # if x is smaller, set x to 512
102 if img_x <= img_y:
103 new_height = int(512*img_y/img_x)
104 tscale = v2.Resize((new_height, 512), antialias=True)
105 else:
106 new_height = 512
107 tscale = v2.Resize((new_height, int(512*img_x/img_y)), antialias=True)
108
109 img = tscale(img)
110
111 # det_scale = torch.div(new_height, img_y)
112
113 elif img_x<512:
114 new_height = int(512*img_y/img_x)
115 tscale = v2.Resize((new_height, 512), antialias=True)
116 img = tscale(img)
117
118 # det_scale = torch.div(new_height, img_y)
119
120 elif img_y<512:
121 new_height = 512
122 tscale = v2.Resize((new_height, int(512*img_x/img_y)), antialias=True)
123 img = tscale(img)
124
125 # det_scale = torch.div(new_height, img_y)
126
127 control = self.main_window.control.copy()
128 # Rotate the frame
129 if control['ManualRotationEnableToggle']:
130 img = v2.functional.rotate(img, angle=control['ManualRotationAngleSlider'], interpolation=v2.InterpolationMode.BILINEAR, expand=True)
131
132 use_landmark_detection=control['LandmarkDetectToggle']
133 landmark_detect_mode=control['LandmarkDetectModelSelection']
134 from_points = control["DetectFromPointsToggle"]
135 if self.main_window.editFacesButton.isChecked():
136 if not use_landmark_detection or landmark_detect_mode=="5":
137 # force to use landmark detector when edit face is enabled.
138 use_landmark_detection = True
139 landmark_detect_mode = "203"
140
141 # force to use from_points in landmark detector when edit face is enabled.
142 from_points = True
143
144 bboxes, kpss_5, kpss = self.models_processor.run_detect(img, control['DetectorModelSelection'], max_num=control['MaxFacesToDetectSlider'], score=control['DetectorScoreSlider']/100.0, input_size=(512, 512), use_landmark_detection=use_landmark_detection, landmark_detect_mode=landmark_detect_mode, landmark_score=control["LandmarkDetectScoreSlider"]/100.0, from_points=from_points, rotation_angles=[0] if not control["AutoRotationToggle"] else [0, 90, 180, 270])
145
146 det_faces_data = []
147 if len(kpss_5)>0:

Callers 1

runMethod · 0.95

Calls 13

keypoints_adjustmentsMethod · 0.95
swap_coreMethod · 0.95
swap_edit_face_coreMethod · 0.95
paint_face_landmarksMethod · 0.95
enhance_coreMethod · 0.95
ParametersDictClass · 0.90
findCosineDistanceMethod · 0.80
get_arcface_modelMethod · 0.80
run_detectMethod · 0.45
run_recognize_directMethod · 0.45

Tested by

no test coverage detected