Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda