- Posted on
- • Artificial Intelligence
Artificial Intelligence Mini PC Projects
- Author
-
-
- User
- linuxbash
- Posts by this author
- Posts by this author
-
Artificial Intelligence Mini PC Projects: 4 Hands‑On Builds You Can Run on Linux
Got a spare mini PC gathering dust? Turn it into a private, low‑latency AI workstation that lives right on your desk. With a few Bash commands and lightweight tooling, you can run local chatbots, real‑time vision, and offline voice assistants—no cloud bills, no data leaks, no waiting for GPU queues.
Why this matters:
Privacy: Keep prompts, camera frames, and voice data on your hardware.
Latency: Process everything locally for instant feedback.
Cost & control: Reuse existing small form‑factor PCs, upgrade at your pace, and learn the stack end‑to‑end.
Below are four practical projects (with copy‑paste commands) that run great on Linux mini PCs.
What you’ll need
A mini PC (Intel NUC/UMPC, AMD Ryzen mini, or similar), 8–32 GB RAM recommended.
Optional accelerators: NVIDIA dGPU, Intel iGPU, AMD iGPU, or USB Coral TPU (optional for later).
Peripherals: USB webcam, mic, speakers/headset (for the voice project).
Disk space: 10–40 GB free for models and tooling.
System prep (one‑time)
Install common tools and multimedia/build dependencies.
- Debian/Ubuntu (apt):
sudo apt update
sudo apt install -y git curl wget unzip python3 python3-venv python3-pip build-essential ffmpeg pkg-config libssl-dev libffi-dev v4l-utils libgl1 espeak-ng portaudio19-dev sox
- Fedora/RHEL/CentOS (dnf):
sudo dnf -y groupinstall "Development Tools"
sudo dnf install -y git curl wget unzip python3 python3-venv python3-pip ffmpeg pkg-config openssl-devel libffi-devel v4l-utils mesa-libGL espeak-ng PortAudio-devel sox
- openSUSE (zypper):
sudo zypper refresh
sudo zypper install -y git curl wget unzip python3 python3-venv python3-pip ffmpeg pkg-config libopenssl-devel libffi-devel v4l-utils Mesa-libGL1 espeak-ng portaudio-devel sox gcc gcc-c++ make
Create a Python virtual environment for the Python‑based projects:
python3 -m venv ~/.venvs/ai
source ~/.venvs/ai/bin/activate
pip install --upgrade pip
Tip: To auto‑enter the venv in new shells, add this to ~/.bashrc:
[ -d ~/.venvs/ai ] && source ~/.venvs/ai/bin/activate
Project 1: A private local chatbot with Ollama (LLMs on your desk)
Run quantized language models on CPU or GPU right on your mini PC.
1) Install Ollama:
curl -fsSL https://ollama.com/install.sh | sh
2) Pull a small, fast model (good for 8–16 GB RAM systems):
ollama pull phi3:mini
3) Chat interactively:
ollama run phi3:mini
4) Bash one‑liner for quick prompts:
ollama run phi3:mini "Write a 3-line summary of ssh port forwarding."
5) Minimal helper script (save as chat.sh, then chmod +x chat.sh):
#!/usr/bin/env bash
prompt="${*:-'Summarize current directory files.'}"
printf 'You: %s\n' "$prompt"
ollama run phi3:mini "$prompt"
Notes:
For larger or more capable models, try
ollama pull llama3:8b(needs more RAM/VRAM).Performance improves with GPU drivers installed (follow your vendor’s docs).
Project 2: Real‑time USB camera detection with YOLO and OpenCV
Turn a $20 webcam into a smart detector that runs locally.
1) Ensure video and OpenGL libraries are present (already included in System prep). - If you skipped prep, install now:
- Debian/Ubuntu (apt):
sudo apt update && sudo apt install -y v4l-utils libgl1 ffmpeg
- Fedora/RHEL/CentOS (dnf):
sudo dnf install -y v4l-utils mesa-libGL ffmpeg
- openSUSE (zypper):
sudo zypper install -y v4l-utils Mesa-libGL1 ffmpeg
2) Install Python packages (CPU‑only for wide compatibility):
source ~/.venvs/ai/bin/activate
pip install --upgrade pip
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install ultralytics opencv-python
3) Test your camera:
v4l2-ctl --list-devices
Look for something like /dev/video0.
4) Save this as cam_yolo.py and run with python3 cam_yolo.py:
from ultralytics import YOLO
import cv2
cap = cv2.VideoCapture(0) # /dev/video0
if not cap.isOpened():
raise SystemExit("Camera not found. Check /dev/video* and permissions.")
model = YOLO("yolov8n.pt") # auto-downloads a small model
while True:
ok, frame = cap.read()
if not ok:
break
results = model(frame, verbose=False)
annotated = results[0].plot()
cv2.imshow("YOLO (q to quit)", annotated)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Tips:
Use a smaller model (like yolov8n) for smooth FPS on CPU.
For permissions, add your user to the video group:
sudo usermod -aG video "$USER"and re‑login.
Project 3: Offline voice assistant (Vosk STT + espeak‑ng TTS)
Always‑on, private speech‑to‑text and text‑to‑speech without the cloud.
1) Make sure audio tools are installed (already in System prep). If not:
- Debian/Ubuntu (apt):
sudo apt update && sudo apt install -y espeak-ng portaudio19-dev sox
- Fedora/RHEL/CentOS (dnf):
sudo dnf install -y espeak-ng PortAudio-devel sox
- openSUSE (zypper):
sudo zypper install -y espeak-ng portaudio-devel sox
2) Install Python packages:
source ~/.venvs/ai/bin/activate
pip install vosk pyaudio
3) Download a small Vosk English model:
mkdir -p ~/models && cd ~/models
wget https://alphacephei.com/vosk/models/vosk-model-small-en-us-0.15.zip
unzip -q vosk-model-small-en-us-0.15.zip
4) Save this as voice_assistant.py and run with python3 voice_assistant.py:
import json, queue, subprocess, sys
import sounddevice as sd # pyaudio alt not needed; we'll use PyAudio via Vosk's mic example pattern
from vosk import Model, KaldiRecognizer
# If sounddevice isn't installed, fallback to PyAudio stream:
try:
import sounddevice as sd
audio_backend = 'sounddevice'
except ImportError:
audio_backend = 'pyaudio'
model_path = sys.argv[1] if len(sys.argv) > 1 else \
str((__import__('pathlib').Path.home() / 'models' / 'vosk-model-small-en-us-0.15'))
model = Model(model_path)
samplerate = 16000
def speak(text):
subprocess.run(["espeak-ng", "-s", "170", text], check=False)
def sounddevice_loop():
q = queue.Queue()
def callback(indata, frames, time, status):
if status: print(status, file=sys.stderr)
q.put(bytes(indata))
with sd.RawInputStream(samplerate=samplerate, blocksize = 8000, dtype='int16',
channels=1, callback=callback):
rec = KaldiRecognizer(model, samplerate)
speak("Voice assistant is ready.")
while True:
data = q.get()
if rec.AcceptWaveform(data):
result = json.loads(rec.Result())["text"].strip()
if result:
print("You:", result)
if "time" in result:
import datetime
reply = "The time is " + datetime.datetime.now().strftime("%H:%M")
elif "exit" in result or "quit" in result:
speak("Goodbye.")
break
else:
reply = "I heard: " + result
print("Bot:", reply)
speak(reply)
if audio_backend == 'sounddevice':
import sounddevice as sd
sounddevice_loop()
else:
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=samplerate, input=True, frames_per_buffer=8000)
rec = KaldiRecognizer(model, samplerate)
speak("Voice assistant is ready.")
while True:
data = stream.read(8000, exception_on_overflow=False)
if rec.AcceptWaveform(data):
result = json.loads(rec.Result())["text"].strip()
if result:
print("You:", result)
if "exit" in result or "quit" in result:
speak("Goodbye.")
break
speak("I heard: " + result)
Notes:
Swap the Vosk model for your language from https://alphacephei.com/vosk/models.
For better voice quality, you can later replace espeak‑ng with a neural TTS engine; this setup is simple and works everywhere.
Project 4: Smart photo tagging with CLIP (offline embeddings)
Auto‑tag images via text‑image embeddings to quickly search your photo folders.
1) Install Python packages:
source ~/.venvs/ai/bin/activate
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
pip install open_clip_torch pillow tqdm
2) Save this as clip_tag.py and run with python3 clip_tag.py ~/Pictures:
import sys, json, os
from pathlib import Path
from PIL import Image
import torch
import open_clip
from tqdm import tqdm
device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess, tokenizer = open_clip.create_model_and_transforms("ViT-B-32", pretrained="openai")
model = model.to(device).eval()
# Define candidate tags; edit to your liking
tags = ["beach", "mountain", "city", "forest", "dog", "cat", "sunset", "snow", "food", "concert", "portrait", "car"]
text = tokenizer(tags).to(device)
def tag_image(img_path):
try:
img = preprocess(Image.open(img_path).convert("RGB")).unsqueeze(0).to(device)
with torch.no_grad():
image_features = model.encode_image(img)
text_features = model.encode_text(text)
image_features /= image_features.norm(dim=-1, keepdim=True)
text_features /= text_features.norm(dim=-1, keepdim=True)
probs = (100.0 * image_features @ text_features.T).softmax(dim=-1).squeeze()
topk = torch.topk(probs, k=5)
return [tags[i] for i in topk.indices.tolist()]
except Exception as e:
return []
root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path.home() / "Pictures"
out = {}
for p in tqdm(list(root.rglob("*"))):
if p.suffix.lower() in {".jpg", ".jpeg", ".png"}:
out[str(p)] = tag_image(p)
with open("photo_tags.json", "w") as f:
json.dump(out, f, indent=2)
print("Wrote photo_tags.json")
3) Search your photos by tag with a tiny Bash helper:
#!/usr/bin/env bash
tag="$1"
jq -r --arg t "$tag" 'to_entries[] | select(.value | index($t)) | .key' photo_tags.json
Notes:
CPU inference works; a dGPU/iGPU speeds it up if available.
Expand the tag list or generate it dynamically from file/folder names.
Bonus: Autostart services with systemd (headless friendly)
Turn any script into a service so it survives reboots.
1) Create a unit file:
sudo tee /etc/systemd/system/ai-chat.service >/dev/null <<'EOF'
[Unit]
Description=Local AI Chatbot (Ollama)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=%i
Environment=HOME=/home/%i
ExecStart=/usr/bin/ollama serve
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
2) Enable and start for your user (replace $USER if running as another user):
sudo systemctl enable ai-chat.service
sudo systemctl start ai-chat.service
3) Check logs:
journalctl -u ai-chat.service -f
Performance tips for mini PCs
Use smaller models first, then scale up.
Prefer int8/quantized variants for CPU‑only boxes.
Close desktop apps and browsers when benchmarking.
Keep your kernels, graphics stack, and microcode updated to pick up vectorization and driver fixes.
Conclusion / Call to Action
Mini PCs are perfect for practical, privacy‑preserving AI. You just built:
A local LLM chatbot with Ollama
A real‑time webcam detector with YOLO
An offline voice assistant with Vosk + espeak‑ng
A photo tagger with CLIP
Pick one project, make it your daily tool, and iterate. Want more? Add a Coral TPU for faster vision, containerize with Podman/Docker, or wire these pieces together into a single home AI hub.
If you found this useful, share your build notes or Bash tweaks—and tell me which project you want deep‑dive scripts for next.