π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Remove all tflite models
laurenspriemd4086357ec3a
diff --git a/mobile/assets/models/cocossd/labels.txt b/mobile/assets/models/cocossd/labels.txtdeleted file mode 100644index fc674c0b99..0000000000--- a/mobile/assets/models/cocossd/labels.txt+++ /dev/null@@ -1,91 +0,0 @@-unknown-person-bicycle-car-motorcycle-airplane-bus-train-truck-boat-traffic light-fire hydrant-unknown-stop sign-parking meter-bench-bird-cat-dog-horse-sheep-cow-elephant-bear-zebra-giraffe-unknown-backpack-umbrella-unknown-unknown-handbag-tie-suitcase-frisbee-skis-snowboard-sports ball-kite-baseball bat-baseball glove-skateboard-surfboard-tennis racket-bottle-unknown-wine glass-cup-fork-knife-spoon-bowl-banana-apple-sandwich-orange-broccoli-carrot-hot dog-pizza-donut-cake-chair-couch-potted plant-bed-unknown-dining table-unknown-unknown-toilet-unknown-tv-laptop-mouse-remote-keyboard-cell phone-microwave-oven-toaster-sink-refrigerator-unknown-book-clock-vase-scissors-teddy bear-hair drier-toothbrushdiff --git a/mobile/assets/models/cocossd/model.tflite b/mobile/assets/models/cocossd/model.tflitedeleted file mode 100644index 8015ee5d8a..0000000000Binary files a/mobile/assets/models/cocossd/model.tflite and /dev/null differdiff --git a/mobile/assets/models/mobilefacenet/mobilefacenet_ente_web.tflite b/mobile/assets/models/mobilefacenet/mobilefacenet_ente_web.tflitedeleted file mode 100644index 057b98506a..0000000000Binary files a/mobile/assets/models/mobilefacenet/mobilefacenet_ente_web.tflite and /dev/null differdiff --git a/mobile/assets/models/mobilefacenet/mobilefacenet_unq_TF211.tflite b/mobile/assets/models/mobilefacenet/mobilefacenet_unq_TF211.tflitedeleted file mode 100644index 391bc41d27..0000000000Binary files a/mobile/assets/models/mobilefacenet/mobilefacenet_unq_TF211.tflite and /dev/null differdiff --git a/mobile/assets/models/mobilenet/labels_mobilenet_quant_v1_224.txt b/mobile/assets/models/mobilenet/labels_mobilenet_quant_v1_224.txtdeleted file mode 100644index fe811239d8..0000000000--- a/mobile/assets/models/mobilenet/labels_mobilenet_quant_v1_224.txt+++ /dev/null@@ -1,1001 +0,0 @@-background-tench-goldfish-great white shark-tiger shark-hammerhead-electric ray-stingray-cock-hen-ostrich-brambling-goldfinch-house finch-junco-indigo bunting-robin-bulbul-jay-magpie-chickadee-water ouzel-kite-bald eagle-vulture-great grey owl-European fire salamander-common newt-eft-spotted salamander-axolotl-bullfrog-tree frog-tailed frog-loggerhead-leatherback turtle-mud turtle-terrapin-box turtle-banded gecko-common iguana-American chameleon-whiptail-agama-frilled lizard-alligator lizard-Gila monster-green lizard-African chameleon-Komodo dragon-African crocodile-American alligator-triceratops-thunder snake-ringneck snake-hognose snake-green snake-king snake-garter snake-water snake-vine snake-night snake-boa constrictor-rock python-Indian cobra-green mamba-sea snake-horned viper-diamondback-sidewinder-trilobite-harvestman-scorpion-black and gold garden spider-barn spider-garden spider-black widow-tarantula-wolf spider-tick-centipede-black grouse-ptarmigan-ruffed grouse-prairie chicken-peacock-quail-partridge-African grey-macaw-sulphur-crested cockatoo-lorikeet-coucal-bee eater-hornbill-hummingbird-jacamar-toucan-drake-red-breasted merganser-goose-black swan-tusker-echidna-platypus-wallaby-koala-wombat-jellyfish-sea anemone-brain coral-flatworm-nematode-conch-snail-slug-sea slug-chiton-chambered nautilus-Dungeness crab-rock crab-fiddler crab-king crab-American lobster-spiny lobster-crayfish-hermit crab-isopod-white stork-black stork-spoonbill-flamingo-little blue heron-American egret-bittern-crane-limpkin-European gallinule-American coot-bustard-ruddy turnstone-red-backed sandpiper-redshank-dowitcher-oystercatcher-pelican-king penguin-albatross-grey whale-killer whale-dugong-sea lion-Chihuahua-Japanese spaniel-Maltese dog-Pekinese-Shih-Tzu-Blenheim spaniel-papillon-toy terrier-Rhodesian ridgeback-Afghan hound-basset-beagle-bloodhound-bluetick-black-and-tan coonhound-Walker hound-English foxhound-redbone-borzoi-Irish wolfhound-Italian greyhound-whippet-Ibizan hound-Norwegian elkhound-otterhound-Saluki-Scottish deerhound-Weimaraner-Staffordshire bullterrier-American Staffordshire terrier-Bedlington terrier-Border terrier-Kerry blue terrier-Irish terrier-Norfolk terrier-Norwich terrier-Yorkshire terrier-wire-haired fox terrier-Lakeland terrier-Sealyham terrier-Airedale-cairn-Australian terrier-Dandie Dinmont-Boston bull-miniature schnauzer-giant schnauzer-standard schnauzer-Scotch terrier-Tibetan terrier-silky terrier-soft-coated wheaten terrier-West Highland white terrier-Lhasa-flat-coated retriever-curly-coated retriever-golden retriever-Labrador retriever-Chesapeake Bay retriever-German short-haired pointer-vizsla-English setter-Irish setter-Gordon setter-Brittany spaniel-clumber-English springer-Welsh springer spaniel-cocker spaniel-Sussex spaniel-Irish water spaniel-kuvasz-schipperke-groenendael-malinois-briard-kelpie-komondor-Old English sheepdog-Shetland sheepdog-collie-Border collie-Bouvier des Flandres-Rottweiler-German shepherd-Doberman-miniature pinscher-Greater Swiss Mountain dog-Bernese mountain dog-Appenzeller-EntleBucher-boxer-bull mastiff-Tibetan mastiff-French bulldog-Great Dane-Saint Bernard-Eskimo dog-malamute-Siberian husky-dalmatian-affenpinscher-basenji-pug-Leonberg-Newfoundland-Great Pyrenees-Samoyed-Pomeranian-chow-keeshond-Brabancon griffon-Pembroke-Cardigan-toy poodle-miniature poodle-standard poodle-Mexican hairless-timber wolf-white wolf-red wolf-coyote-dingo-dhole-African hunting dog-hyena-red fox-kit fox-Arctic fox-grey fox-tabby-tiger cat-Persian cat-Siamese cat-Egyptian cat-cougar-lynx-leopard-snow leopard-jaguar-lion-tiger-cheetah-brown bear-American black bear-ice bear-sloth bear-mongoose-meerkat-tiger beetle-ladybug-ground beetle-long-horned beetle-leaf beetle-dung beetle-rhinoceros beetle-weevil-fly-bee-ant-grasshopper-cricket-walking stick-cockroach-mantis-cicada-leafhopper-lacewing-dragonfly-damselfly-admiral-ringlet-monarch-cabbage butterfly-sulphur butterfly-lycaenid-starfish-sea urchin-sea cucumber-wood rabbit-hare-Angora-hamster-porcupine-fox squirrel-marmot-beaver-guinea pig-sorrel-zebra-hog-wild boar-warthog-hippopotamus-ox-water buffalo-bison-ram-bighorn-ibex-hartebeest-impala-gazelle-Arabian camel-llama-weasel-mink-polecat-black-footed ferret-otter-skunk-badger-armadillo-three-toed sloth-orangutan-gorilla-chimpanzee-gibbon-siamang-guenon-patas-baboon-macaque-langur-colobus-proboscis monkey-marmoset-capuchin-howler monkey-titi-spider monkey-squirrel monkey-Madagascar cat-indri-Indian elephant-African elephant-lesser panda-giant panda-barracouta-eel-coho-rock beauty-anemone fish-sturgeon-gar-lionfish-puffer-abacus-abaya-academic gown-accordion-acoustic guitar-aircraft carrier-airliner-airship-altar-ambulance-amphibian-analog clock-apiary-apron-ashcan-assault rifle-backpack-bakery-balance beam-balloon-ballpoint-Band Aid-banjo-bannister-barbell-barber chair-barbershop-barn-barometer-barrel-barrow-baseball-basketball-bassinet-bassoon-bathing cap-bath towel-bathtub-beach wagon-beacon-beaker-bearskin-beer bottle-beer glass-bell cote-bib-bicycle-built-for-two-bikini-binder-binoculars-birdhouse-boathouse-bobsled-bolo tie-bonnet-bookcase-bookshop-bottlecap-bow-bow tie-brass-brassiere-breakwater-breastplate-broom-bucket-buckle-bulletproof vest-bullet train-butcher shop-cab-caldron-candle-cannon-canoe-can opener-cardigan-car mirror-carousel-carpenter's kit-carton-car wheel-cash machine-cassette-cassette player-castle-catamaran-CD player-cello-cellular telephone-chain-chainlink fence-chain mail-chain saw-chest-chiffonier-chime-china cabinet-Christmas stocking-church-cinema-cleaver-cliff dwelling-cloak-clog-cocktail shaker-coffee mug-coffeepot-coil-combination lock-computer keyboard-confectionery-container ship-convertible-corkscrew-cornet-cowboy boot-cowboy hat-cradle-crane-crash helmet-crate-crib-Crock Pot-croquet ball-crutch-cuirass-dam-desk-desktop computer-dial telephone-diaper-digital clock-digital watch-dining table-dishrag-dishwasher-disk brake-dock-dogsled-dome-doormat-drilling platform-drum-drumstick-dumbbell-Dutch oven-electric fan-electric guitar-electric locomotive-entertainment center-envelope-espresso maker-face powder-feather boa-file-fireboat-fire engine-fire screen-flagpole-flute-folding chair-football helmet-forklift-fountain-fountain pen-four-poster-freight car-French horn-frying pan-fur coat-garbage truck-gasmask-gas pump-goblet-go-kart-golf ball-golfcart-gondola-gong-gown-grand piano-greenhouse-grille-grocery store-guillotine-hair slide-hair spray-half track-hammer-hamper-hand blower-hand-held computer-handkerchief-hard disc-harmonica-harp-harvester-hatchet-holster-home theater-honeycomb-hook-hoopskirt-horizontal bar-horse cart-hourglass-iPod-iron-jack-o'-lantern-jean-jeep-jersey-jigsaw puzzle-jinrikisha-joystick-kimono-knee pad-knot-lab coat-ladle-lampshade-laptop-lawn mower-lens cap-letter opener-library-lifeboat-lighter-limousine-liner-lipstick-Loafer-lotion-loudspeaker-loupe-lumbermill-magnetic compass-mailbag-mailbox-maillot-maillot-manhole cover-maraca-marimba-mask-matchstick-maypole-maze-measuring cup-medicine chest-megalith-microphone-microwave-military uniform-milk can-minibus-miniskirt-minivan-missile-mitten-mixing bowl-mobile home-Model T-modem-monastery-monitor-moped-mortar-mortarboard-mosque-mosquito net-motor scooter-mountain bike-mountain tent-mouse-mousetrap-moving van-muzzle-nail-neck brace-necklace-nipple-notebook-obelisk-oboe-ocarina-odometer-oil filter-organ-oscilloscope-overskirt-oxcart-oxygen mask-packet-paddle-paddlewheel-padlock-paintbrush-pajama-palace-panpipe-paper towel-parachute-parallel bars-park bench-parking meter-passenger car-patio-pay-phone-pedestal-pencil box-pencil sharpener-perfume-Petri dish-photocopier-pick-pickelhaube-picket fence-pickup-pier-piggy bank-pill bottle-pillow-ping-pong ball-pinwheel-pirate-pitcher-plane-planetarium-plastic bag-plate rack-plow-plunger-Polaroid camera-pole-police van-poncho-pool table-pop bottle-pot-potter's wheel-power drill-prayer rug-printer-prison-projectile-projector-puck-punching bag-purse-quill-quilt-racer-racket-radiator-radio-radio telescope-rain barrel-recreational vehicle-reel-reflex camera-refrigerator-remote control-restaurant-revolver-rifle-rocking chair-rotisserie-rubber eraser-rugby ball-rule-running shoe-safe-safety pin-saltshaker-sandal-sarong-sax-scabbard-scale-school bus-schooner-scoreboard-screen-screw-screwdriver-seat belt-sewing machine-shield-shoe shop-shoji-shopping basket-shopping cart-shovel-shower cap-shower curtain-ski-ski mask-sleeping bag-slide rule-sliding door-slot-snorkel-snowmobile-snowplow-soap dispenser-soccer ball-sock-solar dish-sombrero-soup bowl-space bar-space heater-space shuttle-spatula-speedboat-spider web-spindle-sports car-spotlight-stage-steam locomotive-steel arch bridge-steel drum-stethoscope-stole-stone wall-stopwatch-stove-strainer-streetcar-stretcher-studio couch-stupa-submarine-suit-sundial-sunglass-sunglasses-sunscreen-suspension bridge-swab-sweatshirt-swimming trunks-swing-switch-syringe-table lamp-tank-tape player-teapot-teddy-television-tennis ball-thatch-theater curtain-thimble-thresher-throne-tile roof-toaster-tobacco shop-toilet seat-torch-totem pole-tow truck-toyshop-tractor-trailer truck-tray-trench coat-tricycle-trimaran-tripod-triumphal arch-trolleybus-trombone-tub-turnstile-typewriter keyboard-umbrella-unicycle-upright-vacuum-vase-vault-velvet-vending machine-vestment-viaduct-violin-volleyball-waffle iron-wall clock-wallet-wardrobe-warplane-washbasin-washer-water bottle-water jug-water tower-whiskey jug-whistle-wig-window screen-window shade-Windsor tie-wine bottle-wing-wok-wooden spoon-wool-worm fence-wreck-yawl-yurt-web site-comic book-crossword puzzle-street sign-traffic light-book jacket-menu-plate-guacamole-consomme-hot pot-trifle-ice cream-ice lolly-French loaf-bagel-pretzel-cheeseburger-hotdog-mashed potato-head cabbage-broccoli-cauliflower-zucchini-spaghetti squash-acorn squash-butternut squash-cucumber-artichoke-bell pepper-cardoon-mushroom-Granny Smith-strawberry-orange-lemon-fig-pineapple-banana-jackfruit-custard apple-pomegranate-hay-carbonara-chocolate sauce-dough-meat loaf-pizza-potpie-burrito-red wine-espresso-cup-eggnog-alp-bubble-cliff-coral reef-geyser-lakeside-promontory-sandbar-seashore-valley-volcano-ballplayer-groom-scuba diver-rapeseed-daisy-yellow lady's slipper-corn-acorn-hip-buckeye-coral fungus-agaric-gyromitra-stinkhorn-earthstar-hen-of-the-woods-bolete-ear-toilet tissuediff --git a/mobile/assets/models/mobilenet/mobilenet_v1_1.0_224_quant.tflite b/mobile/assets/models/mobilenet/mobilenet_v1_1.0_224_quant.tflitedeleted file mode 100644index 437640b069..0000000000Binary files a/mobile/assets/models/mobilenet/mobilenet_v1_1.0_224_quant.tflite and /dev/null differdiff --git a/mobile/assets/models/scenes/labels.txt b/mobile/assets/models/scenes/labels.txtdeleted file mode 100644index e0df140821..0000000000--- a/mobile/assets/models/scenes/labels.txt+++ /dev/null@@ -1,30 +0,0 @@-waterfall-snow-landscape-underwater-architecture-sunset / sunrise-blue sky-cloudy sky-greenery-autumn leaves-portrait-flower-night shot-stage concert-fireworks-candle light-neon lights-indoor-backlight-text documents-qr images-group portrait-computer screens-kids-dog-cat-macro-food-beach-mountaindiff --git a/mobile/assets/models/scenes/model.tflite b/mobile/assets/models/scenes/model.tflitedeleted file mode 100644index f2c9423548..0000000000Binary files a/mobile/assets/models/scenes/model.tflite and /dev/null differdiff --git a/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart b/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dartdeleted file mode 100644index 1a3dcf4167..0000000000--- a/mobile/lib/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart+++ /dev/null@@ -1,279 +0,0 @@-import 'dart:io';-import "dart:math" show min, max, sqrt;-// import 'dart:math' as math show min, max;-import 'dart:typed_data' show Uint8List;--import "package:flutter/foundation.dart";-import "package:logging/logging.dart";-import 'package:photos/models/ml/ml_typedefs.dart';-import 'package:photos/services/machine_learning/face_ml/face_detection/detection.dart';-import 'package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_exceptions.dart';-import 'package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_options.dart';-import 'package:photos/services/machine_learning/face_ml/face_embedding/mobilefacenet_model_config.dart';-import 'package:photos/utils/image_ml_isolate.dart';-import 'package:photos/utils/image_ml_util.dart';-import 'package:tflite_flutter/tflite_flutter.dart';--/// This class is responsible for running the MobileFaceNet model, and can be accessed through the singleton `FaceEmbedding.instance`.-class FaceEmbedding {- Interpreter? _interpreter;- IsolateInterpreter? _isolateInterpreter;- int get getAddress => _interpreter!.address;-- final outputShapes = <List<int>>[];- final outputTypes = <TensorType>[];-- final _logger = Logger("FaceEmbeddingService");-- final MobileFaceNetModelConfig config;- final FaceEmbeddingOptions embeddingOptions;- // singleton pattern- FaceEmbedding._privateConstructor({required this.config})- : embeddingOptions = config.faceEmbeddingOptions;-- /// Use this instance to access the FaceEmbedding service. Make sure to call `init()` before using it.- /// e.g. `await FaceEmbedding.instance.init();`- ///- /// Then you can use `predict()` to get the embedding of a face, so `FaceEmbedding.instance.predict(imageData)`- ///- /// config options: faceEmbeddingEnte- static final instance =- FaceEmbedding._privateConstructor(config: faceEmbeddingEnte);- factory FaceEmbedding() => instance;-- /// Check if the interpreter is initialized, if not initialize it with `loadModel()`- Future<void> init() async {- if (_interpreter == null || _isolateInterpreter == null) {- await _loadModel();- }- }-- Future<void> dispose() async {- _logger.info('dispose() is called');-- try {- _interpreter?.close();- _interpreter = null;- await _isolateInterpreter?.close();- _isolateInterpreter = null;- } catch (e) {- _logger.severe('Error while closing interpreter: $e');- rethrow;- }- }-- /// WARNING: This function only works for one face at a time. it's better to use [predict], which can handle both single and multiple faces.- Future<List<double>> predictSingle(- Uint8List imageData,- FaceDetectionRelative face,- ) async {- assert(_interpreter != null && _isolateInterpreter != null);-- final stopwatch = Stopwatch()..start();-- // Image decoding and preprocessing- List<List<List<List<num>>>> input;- List output;- try {- final stopwatchDecoding = Stopwatch()..start();- final (inputImageMatrix, _, _, _, _) =- await ImageMlIsolate.instance.preprocessMobileFaceNet(- imageData,- [face],- );- input = inputImageMatrix;- stopwatchDecoding.stop();- _logger.info(- 'Image decoding and preprocessing is finished, in ${stopwatchDecoding.elapsedMilliseconds}ms',- );-- output = createEmptyOutputMatrix(outputShapes[0]);- } catch (e) {- _logger.severe('Error while decoding and preprocessing image: $e');- throw MobileFaceNetImagePreprocessingException();- }-- _logger.info('interpreter.run is called');- // Run inference- try {- await _isolateInterpreter!.run(input, output);- // _interpreter!.run(input, output);- // ignore: avoid_catches_without_on_clauses- } catch (e) {- _logger.severe('Error while running inference: $e');- throw MobileFaceNetInterpreterRunException();- }- _logger.info('interpreter.run is finished');-- // Get output tensors- final embedding = output[0] as List<double>;-- // Normalize the embedding- final norm = sqrt(embedding.map((e) => e * e).reduce((a, b) => a + b));- for (int i = 0; i < embedding.length; i++) {- embedding[i] /= norm;- }-- stopwatch.stop();- _logger.info(- 'predict() executed in ${stopwatch.elapsedMilliseconds}ms',- );-- // _logger.info(- // 'results (only first few numbers): embedding ${embedding.sublist(0, 5)}',- // );- // _logger.info(- // 'Mean of embedding: ${embedding.reduce((a, b) => a + b) / embedding.length}',- // );- // _logger.info(- // 'Max of embedding: ${embedding.reduce(math.max)}',- // );- // _logger.info(- // 'Min of embedding: ${embedding.reduce(math.min)}',- // );-- return embedding;- }-- Future<List<List<double>>> predict(- List<Num3DInputMatrix> inputImageMatrix,- ) async {- assert(_interpreter != null && _isolateInterpreter != null);-- final stopwatch = Stopwatch()..start();-- _checkPreprocessedInput(inputImageMatrix); // [inputHeight, inputWidth, 3]- final input = [inputImageMatrix];- // await encodeAndSaveData(inputImageMatrix, 'input_mobilefacenet');-- final output = <int, Object>{};- final outputShape = outputShapes[0];- outputShape[0] = inputImageMatrix.length;- output[0] = createEmptyOutputMatrix(outputShape);- // for (int i = 0; i < faces.length; i++) {- // output[i] = createEmptyOutputMatrix(outputShapes[0]);- // }-- _logger.info('interpreter.run is called');- // Run inference- final stopwatchInterpreter = Stopwatch()..start();- try {- await _isolateInterpreter!.runForMultipleInputs(input, output);- // _interpreter!.runForMultipleInputs(input, output);- // ignore: avoid_catches_without_on_clauses- } catch (e) {- _logger.severe('Error while running inference: $e');- throw MobileFaceNetInterpreterRunException();- }- stopwatchInterpreter.stop();- _logger.info(- 'interpreter.run is finished, in ${stopwatchInterpreter.elapsedMilliseconds}ms',- );- // _logger.info('output: $output');-- // Get output tensors- final embeddings = <List<double>>[];- final outerEmbedding = output[0]! as Iterable<dynamic>;- for (int i = 0; i < inputImageMatrix.length; i++) {- final embedding = List<double>.from(outerEmbedding.toList()[i]);- // _logger.info("The $i-th embedding: $embedding");- embeddings.add(embedding);- }- // await encodeAndSaveData(embeddings, 'output_mobilefacenet');-- // Normalize the embedding- for (int i = 0; i < embeddings.length; i++) {- final embedding = embeddings[i];- final norm = sqrt(embedding.map((e) => e * e).reduce((a, b) => a + b));- for (int j = 0; j < embedding.length; j++) {- embedding[j] /= norm;- }- }-- stopwatch.stop();- _logger.info(- 'predictBatch() executed in ${stopwatch.elapsedMilliseconds}ms',- );-- return embeddings;- }-- Future<void> _loadModel() async {- _logger.info('loadModel is called');-- try {- final interpreterOptions = InterpreterOptions();-- // Android Delegates- // TODO: Make sure this works on both platforms: Android and iOS- if (Platform.isAndroid) {- // Use GPU Delegate (GPU). WARNING: It doesn't work on emulator- // if (!kDebugMode) {- // interpreterOptions.addDelegate(GpuDelegateV2());- // }- // Use XNNPACK Delegate (CPU)- interpreterOptions.addDelegate(XNNPackDelegate());- }-- // iOS Delegates- if (Platform.isIOS) {- // Use Metal Delegate (GPU)- interpreterOptions.addDelegate(GpuDelegate());- }-- // Load model from assets- _interpreter ??= await Interpreter.fromAsset(- config.modelPath,- options: interpreterOptions,- );- _isolateInterpreter ??=- await IsolateInterpreter.create(address: _interpreter!.address);-- _logger.info('Interpreter created from asset: ${config.modelPath}');-- // Get tensor input shape [1, 112, 112, 3]- final inputTensors = _interpreter!.getInputTensors().first;- _logger.info('Input Tensors: $inputTensors');- // Get tensour output shape [1, 192]- final outputTensors = _interpreter!.getOutputTensors();- final outputTensor = outputTensors.first;- _logger.info('Output Tensors: $outputTensor');-- for (var tensor in outputTensors) {- outputShapes.add(tensor.shape);- outputTypes.add(tensor.type);- }- _logger.info('outputShapes: $outputShapes');- _logger.info('loadModel is finished');- // ignore: avoid_catches_without_on_clauses- } catch (e) {- _logger.severe('Error while creating interpreter: $e');- throw MobileFaceNetInterpreterInitializationException();- }- }-- void _checkPreprocessedInput(- List<Num3DInputMatrix> inputMatrix,- ) {- final embeddingOptions = config.faceEmbeddingOptions;-- if (inputMatrix.isEmpty) {- // Check if the input is empty- throw MobileFaceNetEmptyInput();- }-- // Check if the input is the correct size- if (inputMatrix[0].length != embeddingOptions.inputHeight ||- inputMatrix[0][0].length != embeddingOptions.inputWidth) {- throw MobileFaceNetWrongInputSize();- }-- final flattened = inputMatrix[0].expand((i) => i).expand((i) => i);- final minValue = flattened.reduce(min);- final maxValue = flattened.reduce(max);-- if (minValue < -1 || maxValue > 1) {- throw MobileFaceNetWrongInputRange();- }- }-}diff --git a/mobile/lib/services/machine_learning/face_ml/face_embedding/mobilefacenet_model_config.dart b/mobile/lib/services/machine_learning/face_ml/face_embedding/mobilefacenet_model_config.dartdeleted file mode 100644index fd45f51674..0000000000--- a/mobile/lib/services/machine_learning/face_ml/face_embedding/mobilefacenet_model_config.dart+++ /dev/null@@ -1,20 +0,0 @@-import 'package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_options.dart';-import 'package:photos/services/machine_learning/face_ml/model_file.dart';--class MobileFaceNetModelConfig {- final String modelPath;- final FaceEmbeddingOptions faceEmbeddingOptions;-- MobileFaceNetModelConfig({- required this.modelPath,- required this.faceEmbeddingOptions,- });-}--final MobileFaceNetModelConfig faceEmbeddingEnte = MobileFaceNetModelConfig(- modelPath: ModelFile.faceEmbeddingEnte,- faceEmbeddingOptions: FaceEmbeddingOptions(- inputWidth: 112,- inputHeight: 112,- ),-);diff --git a/mobile/lib/services/machine_learning/face_ml/face_embedding/onnx_face_embedding.dart b/mobile/lib/services/machine_learning/face_ml/face_embedding/onnx_face_embedding.dartindex bdf2ac5cfb..c7d7025412 100644--- a/mobile/lib/services/machine_learning/face_ml/face_embedding/onnx_face_embedding.dart+++ b/mobile/lib/services/machine_learning/face_ml/face_embedding/onnx_face_embedding.dart@@ -10,6 +10,7 @@ import "package:photos/services/remote_assets_service.dart";import "package:photos/utils/image_ml_isolate.dart";import "package:synchronized/synchronized.dart";+/// This class is responsible for running the face embedding model on ONNX runtime, and can be accessed through the singleton instance [FaceEmbeddingOnnx.instance].class FaceEmbeddingOnnx {static const kModelBucketEndpoint = "https://models.ente.io/";static const kRemoteBucketModelPath = "mobilefacenet_opset15.onnx";@@ -17,6 +18,8 @@ class FaceEmbeddingOnnx {static const int kInputSize = 112;static const int kEmbeddingSize = 192;+ static const int kNumChannels = 3;+ static const bool kPreWhiten = false;static final _logger = Logger('FaceEmbeddingOnnx');