Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!