All examplesImages Install Aner
Connect images to models and plots
Make tensor copies, video frame conversion and bounded display previews explicit.
// Shape and ownership demonstration with random CNN weights and a trivial ML self-query.
import aner.image
import aner.video
import aner.vision
import aner.tensor
import aner.nn
import aner.ml
import aner.plot
let work = image.context(workers: 1, memory_mb: 32)
let source = video.synthetic(width: 8, height: 8, frames: 1)
let frame = video.frame_slot()
if source.read_into(frame) == "ready" {
let pixels = image.from_frame(work, frame)
let owned = pixels.tensor(dtype: "Float64", layout: "NCHW", scale: 1.0 / 255.0)
print(tensor.dim(owned, 1))
let plan = vision.preprocess(width: 8, height: 8, filter: "nearest")
let input = vision.input_slot(plan)
plan.prepare_into(pixels, input)
let model = nn.cnn(channels: 3, height: 8, width: 8, seed: 42)
.conv2d(outputs: 2, padding: 1).relu().head(classes: 2)
.on(device: "cpu", precision: "Float32").prepare()
print(tensor.cols(model.logits(input.tensor())))
let features = pixels.features(dtype: "Float64")
let neighbors = ml.fit_knn(features, [[0.0]], k: 1)
print(tensor.item(neighbors.predict(features)))
pixels.plot(minimum: 0.0, maximum: 255.0, max_pixels: 64)
.title("Owned image preview").save("image-preview.svg")
}
source.close()
Make it your experiment.
Use Aner 0.1.0 or newer. Save this program as examples/image_bridges.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/image_bridges.aner
aner run examples/image_bridges.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Requires Aner 0.1.0 or newer. CPU image analysis and binary PNM work without optional image codecs. PNG, JPEG and TIFF require their compiled capabilities. Use a fresh writable directory for outputs.
aner check examples/image_bridges.aner
aner run examples/image_bridges.anerBundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution