Skip to main content

Overview

The DigiPathAI server provides a web-based interface for viewing whole slide images and running AI-powered segmentation. Server configuration is managed through command-line options when starting main_server.py.

Command-Line Options

All server options can be specified when launching the server:
python main_server.py [options]

Host and Port Configuration

--listen
string
default:"127.0.0.1"
IP address for the server to listen on. Use 0.0.0.0 to allow external connections.
python main_server.py --listen 0.0.0.0
--port
integer
default:"8080"
Port number for the server to listen on.
python main_server.py --port 5000

Slide Directory

--slide_dir
string
default:"."
Directory containing the whole slide images. Defaults to current directory.
python main_server.py --slide_dir /path/to/slides
The slide directory is recursively scanned for compatible whole slide image formats detected by OpenSlide (.svs, .tiff, .ndpi, etc.).

Deep Zoom Parameters

Deep Zoom configuration controls how whole slide images are tiled and served to the viewer.
--size
integer
default:"254"
Tile size in pixels for Deep Zoom tiles. Standard value is 254 pixels.
python main_server.py --size 512
--overlap
integer
default:"1"
Overlap of adjacent tiles in pixels. Helps ensure smooth viewing transitions.
python main_server.py --overlap 2
--quality
integer
default:"75"
JPEG compression quality for tiles (1-100). Higher values produce better quality but larger file sizes.
python main_server.py --quality 90
--format
string
default:"jpeg"
Image format for tiles. Allowed values: jpeg or png.
python main_server.py --format png
--ignore-bounds
boolean
default:"false"
Display entire scan area instead of limiting to tissue bounds.
python main_server.py --ignore-bounds

Operating Modes

--viewer-only
boolean
default:"false"
Run in viewer-only mode, disabling AI segmentation functionality. Useful for systems without GPU or when only image viewing is needed.
python main_server.py --viewer-only
When --viewer-only is enabled, the segmentation button will be disabled in the web interface. The server will not load AI models or TensorFlow.

Additional Options

--config
string
Path to a Python configuration file. Settings in the config file can be overridden by command-line options.
python main_server.py --config myconfig.py
--debug
boolean
default:"false"
Run server in debugging mode with auto-reload and detailed error messages.
python main_server.py --debug
Debug mode is insecure and should never be used in production environments.

Configuration File

Instead of using command-line options, you can create a Python configuration file:
config.py
# Server configuration
SLIDE_DIR = '/data/slides'
VIEWER_ONLY = False

# Deep Zoom settings
DEEPZOOM_FORMAT = 'jpeg'
DEEPZOOM_TILE_SIZE = 254
DEEPZOOM_OVERLAP = 1
DEEPZOOM_LIMIT_BOUNDS = True
DEEPZOOM_TILE_QUALITY = 75

# Cache settings
SLIDE_CACHE_SIZE = 10
Then launch with:
python main_server.py --config config.py

Complete Example

Launch server with custom settings:
python main_server.py \
  --listen 0.0.0.0 \
  --port 8080 \
  --slide_dir /data/pathology/slides \
  --size 256 \
  --overlap 1 \
  --quality 85 \
  --format jpeg

Default Configuration

The following defaults are defined in main_server.py (lines 21-28):
SLIDE_DIR = 'examples'
VIEWER_ONLY = True
SLIDE_CACHE_SIZE = 10
DEEPZOOM_FORMAT = 'jpeg'
DEEPZOOM_TILE_SIZE = 254
DEEPZOOM_OVERLAP = 1
DEEPZOOM_LIMIT_BOUNDS = True
DEEPZOOM_TILE_QUALITY = 75

Troubleshooting

  • Check if the port is already in use: lsof -i :<port>
  • Verify firewall settings allow the port
  • Try changing the port with --port
  • Verify slide directory path is correct
  • Check that slides are in OpenSlide-compatible format
  • Review server console for error messages
  • Ensure slides don’t contain ‘dgai-mask’ or ‘dgai-uncertainty’ in filename (these are filtered)
  • Increase JPEG quality with --quality 90 or higher
  • Consider using PNG format with --format png (slower but lossless)
  • Adjust tile size with --size for different performance characteristics

Source Reference

Configuration options are defined in main_server.py:245-297.

Build docs developers (and LLMs) love