A unified Vision Language Model (VLM) server supporting multiple models for image evaluation, captioning, and analysis. Designed for Linux with AMD GPU (ROCm) support.
# Install asdf if not already installed
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
# Add to shell profile (bash)
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
source ~/.bashrc
# Install Python plugin
asdf plugin add python
# Install Python 3.11.11
asdf install python 3.11.11
# Set local version
echo "python 3.11.11" > .tool-versions
# Create venv
python -m venv venv
# Activate venv
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install PyTorch with ROCm 6.2 support
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.2
# Install other dependencies
pip install transformers pillow huggingface_hub accelerate requests
# Clone llama.cpp (if not already present)
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
# Create build directory
mkdir -p build
cd build
# Configure with ROCm support
cmake .. -DGGML_HIPBLAS=ON -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang \
-DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
-DAMDGPU_TARGETS=gfx1100
# Build (use all CPU cores)
cmake --build . --config Release -j$(nproc)
# Verify build
./bin/llama-server --help
Note: Replace gfx1100 with your GPU architecture:
gfx1100gfx1030gfx1030rocminfo | grep gfx# Check ROCm installation
rocm-smi
# Verify PyTorch ROCm support
python -c "import torch; print('CUDA available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A')"
Expected output:
CUDA available: True
Device: AMD Radeon Graphics
# Start the VLM server in interactive mode
venv/bin/python vlm_server.py --interactive
# Follow prompts to:
# 1. Enter path to image
# 2. Enter your question/prompt about the image
# 3. View model response
# Process all images in a directory
venv/bin/python vlm_server.py --mode eval --input-dir ./images
# Images are copied to rated_images/ with ratings in filename
# Example: rate_7_myimage.jpg
# Start server
venv/bin/python vlm_server.py --mode server
# Server runs at http://127.0.0.1:8080
# Use --port to change port number
Edit vlm_server.py and change the ACTIVE_MODEL variable (around line 174):
# Available options:
ACTIVE_MODEL = "joycaption" # Fast rating (Transformers)
ACTIVE_MODEL = "mistral-small-q8" # 24B model, high quality
ACTIVE_MODEL = "minicpm-v45-abliterated-q8" # Uncensored 4.5
ACTIVE_MODEL = "qwen3-vl-8b-q8" # Best 8B model
ACTIVE_MODEL = "qwen3-vl-30b-thinking-q8" # Largest, most capable
qwen3-vl-4b-q4, mistral-small-q4qwen3-vl-8b-q8, minicpm-v45-q6qwen3-vl-30b-thinking-q8, mistral-small-q8qwen3-vl-30b-thinking-q8, minicpm-v45-abliterated-f16.
├── vlm_server.py # Main VLM server with multi-model support
├── crawl_and_evaluate_integrated.py # Batch evaluation pipeline
├── crawl_and_evaluate_server.py # Server-based evaluation
├── collect_images.py # Utility to collect rated images
├── re_evaluate_images.py # Re-evaluate with different criteria
├── llama.cpp/ # llama.cpp build (for GGUF models)
│ └── build/bin/llama-server # Built server binary
├── venv/ # Python virtual environment
├── images/ # Input images directory
└── rated_images/ # Output with rated images
├── rate_7_image1.jpg
├── rate_7_image1.jpg.log # Evaluation details
└── ...
# Verify ROCm installation
rocm-smi
# Check ROCm version
apt list --installed | grep rocm
# Reinstall PyTorch with ROCm
pip uninstall torch torchvision
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.2
rocm-smi# Install build dependencies
sudo apt-get update
sudo apt-get install build-essential cmake git
# Ensure ROCm is installed
sudo apt-get install rocm-hip-sdk
# Verify ROCm compiler
/opt/rocm/llvm/bin/clang++ --version
Models are automatically downloaded from HuggingFace Hub:
~/.cache/huggingface/rm -rf ~/.cache/huggingface/hub/models--*# Check if port is in use
lsof -i :8080
# Kill existing process
pkill -f llama-server
# Check llama-server binary exists
ls -lh llama.cpp/build/bin/llama-server
| Model | Q4_K_M | Q6_K | Q8_0 | F16 |
|---|---|---|---|---|
| Qwen3-VL 4B | ~3GB | ~4GB | ~5GB | - |
| Qwen3-VL 8B | ~6GB | ~8GB | ~10GB | ~16GB |
| MiniCPM-V 4.5 | ~8GB | ~10GB | ~12GB | ~18GB |
| Mistral-Small 24B | ~14GB | ~18GB | ~24GB | - |
| Qwen3-VL 30B | ~18GB | ~24GB | ~32GB | - |
Create your own raw_prompts.py:
SYSTEM_PROMPT = "You are an expert image analyst..."
PROMPT = """
Analyze this image and provide:
1. Main subject
2. Visual quality (0-10)
3. Key details
"""
# In crawl_and_evaluate_integrated.py
BATCH_SIZE = 20 # Images per batch
MIN_RATING = 5 # Only keep images rated 5+
This project is a collection of scripts for using various VLM models. See individual model licenses:
Contributions welcome! Areas for improvement:
For issues:
rocm-smi9 commits
Python
100.0%
A unified Vision Language Model (VLM) server supporting multiple models for image evaluation, captioning, and analysis. Designed for Linux with AMD GPU (ROCm) support.
# Install asdf if not already installed
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
# Add to shell profile (bash)
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
source ~/.bashrc
# Install Python plugin
asdf plugin add python
# Install Python 3.11.11
asdf install python 3.11.11
# Set local version
echo "python 3.11.11" > .tool-versions
# Create venv
python -m venv venv
# Activate venv
source venv/bin/activate
# Upgrade pip
pip install --upgrade pip
# Install PyTorch with ROCm 6.2 support
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.2
# Install other dependencies
pip install transformers pillow huggingface_hub accelerate requests
# Clone llama.cpp (if not already present)
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp
# Create build directory
mkdir -p build
cd build
# Configure with ROCm support
cmake .. -DGGML_HIPBLAS=ON -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang \
-DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
-DAMDGPU_TARGETS=gfx1100
# Build (use all CPU cores)
cmake --build . --config Release -j$(nproc)
# Verify build
./bin/llama-server --help
Note: Replace gfx1100 with your GPU architecture:
gfx1100gfx1030gfx1030rocminfo | grep gfx# Check ROCm installation
rocm-smi
# Verify PyTorch ROCm support
python -c "import torch; print('CUDA available:', torch.cuda.is_available()); print('Device:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'N/A')"
Expected output:
CUDA available: True
Device: AMD Radeon Graphics
# Start the VLM server in interactive mode
venv/bin/python vlm_server.py --interactive
# Follow prompts to:
# 1. Enter path to image
# 2. Enter your question/prompt about the image
# 3. View model response
# Process all images in a directory
venv/bin/python vlm_server.py --mode eval --input-dir ./images
# Images are copied to rated_images/ with ratings in filename
# Example: rate_7_myimage.jpg
# Start server
venv/bin/python vlm_server.py --mode server
# Server runs at http://127.0.0.1:8080
# Use --port to change port number
Edit vlm_server.py and change the ACTIVE_MODEL variable (around line 174):
# Available options:
ACTIVE_MODEL = "joycaption" # Fast rating (Transformers)
ACTIVE_MODEL = "mistral-small-q8" # 24B model, high quality
ACTIVE_MODEL = "minicpm-v45-abliterated-q8" # Uncensored 4.5
ACTIVE_MODEL = "qwen3-vl-8b-q8" # Best 8B model
ACTIVE_MODEL = "qwen3-vl-30b-thinking-q8" # Largest, most capable
qwen3-vl-4b-q4, mistral-small-q4qwen3-vl-8b-q8, minicpm-v45-q6qwen3-vl-30b-thinking-q8, mistral-small-q8qwen3-vl-30b-thinking-q8, minicpm-v45-abliterated-f16.
├── vlm_server.py # Main VLM server with multi-model support
├── crawl_and_evaluate_integrated.py # Batch evaluation pipeline
├── crawl_and_evaluate_server.py # Server-based evaluation
├── collect_images.py # Utility to collect rated images
├── re_evaluate_images.py # Re-evaluate with different criteria
├── llama.cpp/ # llama.cpp build (for GGUF models)
│ └── build/bin/llama-server # Built server binary
├── venv/ # Python virtual environment
├── images/ # Input images directory
└── rated_images/ # Output with rated images
├── rate_7_image1.jpg
├── rate_7_image1.jpg.log # Evaluation details
└── ...
# Verify ROCm installation
rocm-smi
# Check ROCm version
apt list --installed | grep rocm
# Reinstall PyTorch with ROCm
pip uninstall torch torchvision
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.2
rocm-smi# Install build dependencies
sudo apt-get update
sudo apt-get install build-essential cmake git
# Ensure ROCm is installed
sudo apt-get install rocm-hip-sdk
# Verify ROCm compiler
/opt/rocm/llvm/bin/clang++ --version
Models are automatically downloaded from HuggingFace Hub:
~/.cache/huggingface/rm -rf ~/.cache/huggingface/hub/models--*# Check if port is in use
lsof -i :8080
# Kill existing process
pkill -f llama-server
# Check llama-server binary exists
ls -lh llama.cpp/build/bin/llama-server
| Model | Q4_K_M | Q6_K | Q8_0 | F16 |
|---|---|---|---|---|
| Qwen3-VL 4B | ~3GB | ~4GB | ~5GB | - |
| Qwen3-VL 8B | ~6GB | ~8GB | ~10GB | ~16GB |
| MiniCPM-V 4.5 | ~8GB | ~10GB | ~12GB | ~18GB |
| Mistral-Small 24B | ~14GB | ~18GB | ~24GB | - |
| Qwen3-VL 30B | ~18GB | ~24GB | ~32GB | - |
Create your own raw_prompts.py:
SYSTEM_PROMPT = "You are an expert image analyst..."
PROMPT = """
Analyze this image and provide:
1. Main subject
2. Visual quality (0-10)
3. Key details
"""
# In crawl_and_evaluate_integrated.py
BATCH_SIZE = 20 # Images per batch
MIN_RATING = 5 # Only keep images rated 5+
This project is a collection of scripts for using various VLM models. See individual model licenses:
Contributions welcome! Areas for improvement:
For issues:
rocm-smi9 commits
Python
100.0%