mirror of
https://github.com/facefusion/facefusion.git
synced 2026-08-10 11:00:35 +02:00
Uniform frame handling for predictor
This commit is contained in:
@@ -61,11 +61,16 @@ def predict_stream(frame : Frame, fps : float) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def prepare_frame(frame : Frame) -> Frame:
|
||||||
|
frame = cv2.resize(frame, (224, 224)).astype(numpy.float32)
|
||||||
|
frame -= numpy.array([ 104, 117, 123 ]).astype(numpy.float32)
|
||||||
|
frame = numpy.expand_dims(frame, axis = 0)
|
||||||
|
return frame
|
||||||
|
|
||||||
|
|
||||||
def predict_frame(frame : Frame) -> bool:
|
def predict_frame(frame : Frame) -> bool:
|
||||||
predictor = get_predictor()
|
predictor = get_predictor()
|
||||||
frame = cv2.resize(frame, (224, 224)).astype(numpy.float32)
|
frame = prepare_frame(frame)
|
||||||
frame -= numpy.array([ 104, 117, 123 ], dtype = numpy.float32)
|
|
||||||
frame = numpy.expand_dims(frame, axis = 0)
|
|
||||||
probability = predictor.run(None,
|
probability = predictor.run(None,
|
||||||
{
|
{
|
||||||
'input:0': frame
|
'input:0': frame
|
||||||
|
|||||||
Reference in New Issue
Block a user