3.18. Working with Camera and NetworksΒΆ

This notebook explores using a webcamera with a network.

[1]:
from conx.widgets import CameraWidget
import conx as cx
Using TensorFlow backend.
ConX, version 3.7.5
[2]:
camera = CameraWidget()
[3]:
camera
[4]:
image = camera.get_image()
image
[4]:
_images/Camera_4_0.png
[5]:
image.save("camera.jpg")
[6]:
data = camera.get_data()
[7]:
data.shape
[7]:
(240, 320, 3)
[8]:
net = cx.Network("Camera Network")
net.add(cx.ImageLayer("camera", (240, 320), 3),
        cx.Conv2DLayer("conv2d", 32, (3,3)),
        cx.MaxPool2DLayer("maxpool", (2,2)),
        cx.FlattenLayer("flatten"),
        cx.Layer("output", 10))
net.connect()
net.compile(error="mse", optimizer="adam")
[9]:
net.dataset.append(data, cx.to_categorical(1, 10))
[10]:
net.dashboard()
[11]:
net.picture(camera.get_data())
[11]:
Layer: output (output) output range: (-Infinity, +Infinity) shape = (10,) Keras class = DenseoutputLayer: flatten (hidden) output range: (-Infinity, +Infinity) Keras class = FlattenflattenLayer: maxpool (hidden) output range: (-Infinity, +Infinity) Keras class = MaxPooling2Dmaxpool320Layer: conv2d (hidden) output range: (-Infinity, +Infinity) Keras class = Conv2Dconv2d320Layer: camera (input) output range: (0.0, 1.0) shape = (240, 320, 3) Keras class = InputcameraCamera Network
[ ]: