Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Loading custom model doesn't work (Teachable machine w/ Tensorflow & React native Expo CLI)

I am trying to load a custom model trained on TeachableMachine into my React native app, the mobilenet model does work, but when I try to load my own custom model it stays undefined and it won't resolve the loading phase of the model.

Relevant Code:

import React, { useEffect, useState } from "react";

import { ActivityIndicator, Text } from "react-native";

import { MainContainer } from "../utils/styles";

import * as tf from "@tensorflow/tfjs";
import { fetch } from "@tensorflow/tfjs-react-native";
import * as jpeg from "jpeg-js";
// import * as mobilenet from "@tensorflow-models/mobilenet";

...
  const getPrediction = async () => {
    try {
      await tf.ready();
      // const model = await mobilenet.load();
        const model = await tf.loadLayersModel(
          "https://teachablemachine.withgoogle.com/models/ULiD4t_yQ/model.json"
        );
      const response = await fetch(image, {}, { isBinary: true });
      const rawImageData = await response.arrayBuffer();
      const imageTensor = await imageToTensor(rawImageData);
      const prediction = await model.classify(imageTensor);
      setPrediction(prediction);
      setIsLoading(false);
    } catch (e) {
      console.log(e);
    }
  };

  useEffect(() => {
    getPrediction();
  }, []);

...

Teachablemachine provides free cloud hosting of the model, and by tutorials I've seen online tf.loadLayersModel should work with a browser link linked to my model.json.

Error:

model.classify is not a function. (In 'model.classify(imageTensor)', 'model.classify' is undefined)

I tried to load the files locally and pass them to the loadLayersModel function but it doesn't work as well.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda