A Flask backend with React frontend for demonstrating VABiKo archive features, including face recognition and Wikidata integration.
The application uses config.py to manage data directory paths and settings.
Edit config.py to point to your data directories:
# Data directory paths
ARCHIVE_BASE = "/path/to/your/data/clean/export_jpg"
ENTITIES_FILE = "/path/to/your/data/clean/export_model/vabiko_entities.json"You can also configure paths using environment variables:
export VABIKO_ARCHIVE_BASE="/path/to/your/archive"
export VABIKO_ENTITIES_FILE="/path/to/your/entities.json"
export FLASK_PORT=5000
export FLASK_DEBUG=True- Install Python dependencies:
pip install -r requirements.txtFor face recognition support, you may need system dependencies:
sudo apt-get update
sudo apt-get install python3-dev cmake libopenblas-dev liblapack-dev libx11-dev libgtk-3-devOr use the provided installation script:
python install_face_detection.py-
Configure data paths in
config.pyor set environment variables -
Start the Flask server:
python app.pyThe backend will run on http://localhost:5000 (or the configured port)
- Install Node.js dependencies:
npm install- Start the React development server:
npm startThe frontend will run on http://localhost:3000
- Start both backend and frontend servers
- Open
http://localhost:3000in your browser - Select an interface from the dropdown:
- Archive Browser: Enter URNs to view images and metadata
- People Browser: Browse images by depicted persons or photographers
- Person Linking: View unified person names with Wikidata links
- Face Linking: Analyze faces in images with person linking and Wikidata reference images
The Face Linking interface provides advanced facial recognition and similarity analysis:
- Automatic face detection in both archive and Wikidata images
- Rotation correction: Tests original, 90° clockwise, and 90° counter-clockwise orientations
- HOG algorithm: Uses Histogram of Oriented Gradients for face detection
- Visual indicators: Red bounding boxes for archive images, blue for Wikidata images
- Deep learning model: Uses dlib's ResNet-34 CNN trained on ~3 million faces
- 128-dimensional encodings: Each face converted to unique feature vector
- Similarity scoring: Euclidean distance converted to percentage (0-100%)
- Smart thresholds: Strong (≥80%), Moderate (60-79%), Weak (<60%)
- Real-time comparison: Archive faces matched against Wikidata reference images
- Model: dlib_face_recognition_resnet_model_v1.dat (22.5 MB)
- Accuracy: 99.38% on Labeled Faces in the Wild benchmark
- Caching: Wikidata face encodings cached locally for performance
- Automatic rotation: Handles rotated images common in historical archives
- Similarity badges: Shows match percentages directly on images (e.g., "85% match")
- Detailed analysis: Face-to-face mapping with similarity scores
- Diagnostic information: Clear feedback when no matches found
- Performance optimized: Cached encodings and parallel processing
GET /api/interfaces- List available demo interfacesGET /api/urn/<urn>- Get data for a specific URNGET /api/image/<urn>- Serve image file for a URNGET /api/list- List available URNs (first 100)
GET /api/people/depicted- List depicted persons with photo countsGET /api/people/photographers- List photographers with photo countsGET /api/linking/unified-names- List unified names with filtering optionsGET /api/linking/unified-name/<name>- Get detailed person information
GET /api/faces/linked-persons- List persons with V4 links for face analysisGET /api/faces/person/<name>- Get face detection data and similarity analysis for a personGET /api/image-with-faces/<urn>- Serve archive image with red face bounding boxesGET /api/wikidata-image/<entity_id>- Serve cached Wikidata imageGET /api/wikidata-image-with-faces/<entity_id>- Serve Wikidata image with blue face bounding boxes
The /api/faces/person/<name> endpoint returns comprehensive face analysis data:
{
"unified_name": "Person Name",
"wikidata_images": [
{
"entity_id": "Q123456",
"face_count": 1,
"has_faces": true,
"image_with_faces_url": "/api/wikidata-image-with-faces/Q123456"
}
],
"images": [
{
"urn": "urn:nbn:de:hebis:30:2-123456",
"face_count": 2,
"faces": [{"id": 0, "top": 100, "left": 50, "width": 80, "height": 90}]
}
],
"face_similarity": {
"summary": {
"total_matches": 3,
"best_similarity": 0.87,
"average_similarity": 0.73,
"has_strong_match": true
},
"similarities": [
{
"archive_face_index": 0,
"wikidata_face_index": 0,
"similarity": 0.87,
"distance": 0.13,
"archive_urn": "urn:nbn:de:hebis:30:2-123456",
"archive_image_index": 0,
"wikidata_image_index": 0
}
]
}
}The application reads from two main data sources:
-
Archive Images: Directory structure created by the reorganize script (
ARCHIVE_BASE)- Each subdirectory named with URN (using + format)
- Contains
image.jpgandmets.xmlfiles
-
Entities Metadata: JSON file with parsed metadata (
ENTITIES_FILE)- Contains array of objects with URN, titles, people, keywords, etc.
- Used for the People Browser interface
-
Persons CSV: CSV file with person linking data (
PERSONS_CSV_FILE)- Contains unified names, Wikidata links (V1-V4), and person mappings
- Used for Person Linking and Face Linking interfaces
-
Wikidata Cache: Local cache directory for Wikidata images
- Automatically created at
wikidata_cache/ - Stores fetched person images and metadata
- Automatically created at
All settings in config.py:
ARCHIVE_BASE: Path to reorganized image directoryENTITIES_FILE: Path to entities JSON fileFLASK_DEBUG: Enable/disable debug modeFLASK_PORT: Server port (default: 5000)FLASK_HOST: Server host (default: 127.0.0.1)MAX_URNS_LIST: Max URNs returned by list endpoint (default: 100)