microsoft / customvision-tfjs

NPM package for TensorFlow.js models exported from Custom Vision Service
https://customvision.ai
MIT License
28 stars 22 forks source link

Object Detection not working in Browser #2

Closed aakashbhadana closed 4 years ago

aakashbhadana commented 4 years ago

I trained an Object detection model using Customvision.ai web portal and exported the model to Tensorflow.js.

I am following the code on the Github Repository https://github.com/microsoft/customvision-tfjs to use it in Browser but it's not working.

Can anyone help me with how to use it Model in Browser ?

Code that i am using :

<html>

<head>
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs/dist/tf.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://unpkg.com/@microsoft/customvision-tfjs"></script>
</head>

<body>
<img id="iamge "src="box.jpg" style="display: none;"/>
</body>
<script>
    import * as cvstfjs from '@microsoft/customvision-tfjs';

    let model = new ObjectDetectionModel();
    await model.loadModelAsync('http://localhost/od/model.json');
    const image = document.getElementById('image');
    const result = await model.executeAsync(image);
    alert(result)
</script>

</html>
amarrmb commented 4 years ago

How did you get it to work?