Enjoy these free Code Nuggets?

Your support helps us create more high-quality content and unlocks exclusive premium nuggets via a personal activation link.

Support Our Work & Get Exclusive Access
🤖 New — AI Training

Learn to code with AI, not just about it.

Beyond free snippets, we run hands-on training in AI-assisted coding — teaching developers, teams and beginners how to build real software faster using modern AI tools. You bring the ideas; we show you how to ship them with an AI pair-programmer at your side.

  • ✔ Prompting & pairing with AI coding assistants to write, debug and refactor real code
  • ✔ Turning plain-English ideas into working apps, scripts and automations
  • ✔ Reviewing AI output safely — spotting bugs, security gaps and hallucinations
  • ✔ Live cohorts, team workshops and 1-on-1 mentoring — remote or on-site in Kenya
ai-pair-session.md

# You describe it…

"Build me a booking form that emails the client."

# …the AI drafts it…

▸ generating form + mailer…

â–¸ 24 lines written, 0 errors

# …and we teach you to lead it.

✱ You stay the engineer. AI is the tool.

AI & Machine Learning nuggets

5 nuggets found

Clear filter

PlatePoa ALPR: OpenCV & PyTorch License Plate Extraction Pipeline (Premium)

Automated License Plate Recognition (ALPR) model running YOLOv8 detection, homography perspective deskewing, and EasyOCR character parsing optimized for East African registration plates.

# PlatePoa AI Vehicle Plate Extractor
import cv2
import torch
import numpy as np

def extract_plate_number(image_path, model, ocr_reader):
    img = cv2.imread(image_path)
    results = model(img)
    
    for r in results:
        boxes = r.boxes.xyxy.cpu().numpy()
        for box in boxes:...

TB Detection AI: DenseNet-121 Chest X-Ray Diagnostic Assistant (Premium)

Medical computer vision model predicting pulmonary Tuberculosis opacity from DICOM/PNG chest X-rays with Grad-CAM visual heatmaps for radiologist validation.

# TB Detection AI Model Inference
import torch
import torchvision.transforms as transforms
from PIL import Image

def predict_tb(image_path, model):
    transform = transforms.Compose([
        transforms.Resize((224, 224)),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.485, 0....

A Minimal Image Classifier with Keras (Premium)

You do not need a research lab to train a working classifier. This compact Keras model learns to tell classes apart from a folder of labelled images and reports its...

import tensorflow as tf
from tensorflow.keras import layers, models

model = models.Sequential([
    layers.Rescaling(1./255, input_shape=(128, 128, 3)),
    layers.Conv2D(32, 3, activation="relu"),
    layers.MaxPooling2D(),
    layers.Conv2D(64, 3, activation="relu"),
    layers.MaxPooling2D(),...

Building an Image Preprocessing Pipeline with tf.data (Premium)

Clean, well-batched input is half the battle in machine learning. tf.data loads images from disk, resizes and augments them, then prefetches batches so your GPU never sits idle.

import tensorflow as tf

AUTOTUNE = tf.data.AUTOTUNE

train_ds = tf.keras.utils.image_dataset_from_directory(
    "data/train", image_size=(128, 128), batch_size=32, label_mode="int")

augment = tf.keras.Sequential([
    tf.keras.layers.RandomFlip("horizontal"),
    tf.keras.layers.RandomRotation(0....

Serving a Trained Model Behind a REST Endpoint (Premium)

A model is only useful once other apps can call it. FastAPI wraps your saved model in a tiny JSON API: load once at startup, then return predictions on every...

from fastapi import FastAPI, UploadFile
import tensorflow as tf
import numpy as np
from PIL import Image
import io

app = FastAPI()
model = tf.keras.models.load_model("model.keras")   # loaded once
CLASSES = ["normal", "review", "urgent"]

@app.post("/predict")
async def predict(file: UploadFile):...