Remove more tf
This commit is contained in:
parent
1f8ebc0bca
commit
da5edc610f
2 changed files with 0 additions and 49 deletions
|
@ -1,39 +0,0 @@
|
|||
import * as tf from "@tensorflow/tfjs-core";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FaceImage } from "types/machineLearning";
|
||||
|
||||
interface FaceImageProps {
|
||||
faceImage: FaceImage;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
export default function TFJSImage(props: FaceImageProps) {
|
||||
const canvasRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!props || !props.faceImage) {
|
||||
return;
|
||||
}
|
||||
const canvas = canvasRef.current;
|
||||
const faceTensor = tf.tensor3d(props.faceImage);
|
||||
const resized =
|
||||
props.width && props.height
|
||||
? tf.image.resizeBilinear(faceTensor, [
|
||||
props.width,
|
||||
props.height,
|
||||
])
|
||||
: faceTensor;
|
||||
const normFaceImage = tf.div(tf.add(resized, 1.0), 2);
|
||||
tf.browser.toPixels(normFaceImage as tf.Tensor3D, canvas);
|
||||
}, [props]);
|
||||
|
||||
return (
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
width={112}
|
||||
height={112}
|
||||
style={{ display: "inline" }}
|
||||
/>
|
||||
);
|
||||
}
|
|
@ -13,16 +13,6 @@ export interface MLSyncResult {
|
|||
error?: Error;
|
||||
}
|
||||
|
||||
export interface DebugFace {
|
||||
fileId: string;
|
||||
// face: FaceApiResult;
|
||||
face: AlignedFace;
|
||||
embedding: FaceEmbedding;
|
||||
faceImage: FaceImage;
|
||||
}
|
||||
|
||||
export declare type FaceImage = Array<Array<Array<number>>>;
|
||||
|
||||
export declare type FaceDescriptor = Float32Array;
|
||||
|
||||
export declare type Cluster = Array<number>;
|
||||
|
|
Loading…
Add table
Reference in a new issue