Last active
August 9, 2017 19:40
-
-
Save owulveryck/1f3fc2366e5a35ab119633d57ad074b6 to your computer and use it in GitHub Desktop.
Inception v3 in GO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func constructGraphToNormalizeImage() (graph *tf.Graph, input, output tf.Output, err error) { | |
const ( | |
H, W = 299, 299 | |
Mean = float32(0) | |
Scale = float32(255) | |
) | |
s := op.NewScope() | |
input = op.Placeholder(s, tf.String) | |
output = op.Div(s, | |
op.Sub(s, | |
op.ResizeBilinear(s, | |
op.ExpandDims(s, | |
op.Cast(s, | |
op.DecodeJpeg(s, input, op.DecodeJpegChannels(3)), tf.Float), | |
op.Const(s.SubScope("make_batch"), int32(0))), | |
op.Const(s.SubScope("size"), []int32{H, W})), | |
op.Const(s.SubScope("mean"), Mean)), | |
op.Const(s.SubScope("scale"), Scale)) | |
graph, err = s.Finalize() | |
return graph, input, output, err | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tick := time.Tick(1000 * time.Millisecond) | |
for { | |
err = cam.WaitForFrame(timeout) | |
// ... process error | |
frame, err := cam.ReadFrame() | |
if len(frame) != 0 { | |
select { | |
case <-tick: | |
// ... process the image and display the result | |
default: | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment