Skip to content

Commit

Permalink
mobile net v1 example (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
syt123450 committed Nov 5, 2018
1 parent a5a1256 commit fb3b538
Show file tree
Hide file tree
Showing 11 changed files with 347 additions and 1 deletion.
Binary file added examples/mobilenetv1/assets/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/mobilenetv1/data/coffeepot.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/mobilenetv1/data/imagenet_result.js

Large diffs are not rendered by default.

343 changes: 343 additions & 0 deletions examples/mobilenetv1/mobilenet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,343 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TensorSpace - MobileNet Demo</title>
<meta name="author" content="syt123450 / https://github.com/syt123450">
<style>

html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}

#container {
width: 100%;
height: 100%;
}

#loadingPad {
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
background-color: #031D32;
z-index: 2;
}

#loading {
position: fixed;
width: 30%;
top: 150px;
margin-left: 35%;
}

</style>
</head>
<body>

<div id="container"></div>
<div id="loadingPad">
<img id="loading" src="./assets/loading.gif">
</div>

<script src="../lib/jquery.min.js"></script>
<script src="../lib/three.min.js"></script>
<script src="../lib/stats.min.js"></script>
<script src="../lib/tween.min.js"></script>
<script src="../lib/TrackballControls.js"></script>
<script src="../lib/tf.min.js"></script>
<script src="../../build/tensorspace.js"></script>

<script src="data/imagenet_result.js"></script>

<script>

let modelContainer = document.getElementById( "container" );

let model = new TSP.models.Sequential( modelContainer, {

stats: true

} );

model.add( new TSP.layers.RGBInput( {

shape: [ 224, 224, 3 ]

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 3,
filters: 32,
strides: 2,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 64,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 2,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 128,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 128,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 2,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 256,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 256,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 2,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 512,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 512,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 512,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 512,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 512,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 512,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 2,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 1024,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.DepthwiseConv2d( {

kernelSize: 3,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.Conv2d( {

kernelSize: 1,
filters: 1024,
strides: 1,
padding: "same"

} ) );

model.add( new TSP.layers.GlobalPooling2d() );

model.add( new TSP.layers.Output1d( {

units: 1000,
paging: true,
segmentLength: 200,
outputs: result

} ) );

model.load( {

type: "keras",
url: './mobilenetv1/model.json'

} );

model.init(function() {

$.ajax( {

url: "./data/coffeepot.json",
type: 'GET',
async: true,
dataType: 'json',
success: function ( data ) {

model.predict( data );
$( "#loadingPad" ).hide();

}

} );

});

</script>

</body>
</html>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions examples/mobilenetv1/mobilenetv1/model.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/resnet50/resnet50.html
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@

model.load( {

type: "tfjs",
type: "keras",
url: './resnet50Model/model.json'

} );
Expand Down

0 comments on commit fb3b538

Please sign in to comment.