put rest and sse to acceptance criteria. revise components. add system flows diagram

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-11-30 01:02:07 +02:00
parent ef75cc5877
commit 1082316660
17 changed files with 1906 additions and 434 deletions
@@ -25,7 +25,7 @@ class IGlobalPlaceRecognition(ABC):
pass
@abstractmethod
def initialize_database(self, satellite_tiles: List[SatelliteTile]) -> bool:
def load_index(self, flight_id: str, index_path: str) -> bool:
pass
@abstractmethod
@@ -45,7 +45,7 @@ class IGlobalPlaceRecognition(ABC):
- Compute image descriptors robust to season/appearance changes
- Query Faiss index of satellite tile descriptors
- Return top-k candidate tile regions for progressive refinement
- Initialize satellite descriptor database during system startup
- **Load pre-built satellite descriptor index** (index is built by satellite provider, NOT by F08)
- **Chunk semantic matching (aggregate DINOv2 features)**
- **Chunk descriptor computation for robust matching**
@@ -203,54 +203,48 @@ List[TileCandidate] # Re-ranked list
---
### `initialize_database(satellite_tiles: List[SatelliteTile]) -> bool`
### `load_index(flight_id: str, index_path: str) -> bool`
**Description**: Loads pre-built satellite descriptor database. **Note**: Semantic index building (DINOv2 descriptors) is performed by the satellite provider service, not during system startup.
**Description**: Loads pre-built satellite descriptor database from file. **Note**: The semantic index (DINOv2 descriptors + Faiss index) MUST be provided by the satellite data provider. F08 does NOT build the index - it only loads it.
**Called By**:
- F02 Flight Processor (during system initialization)
- F02 Flight Processor (during flight initialization, index_path from F04 Satellite Data Manager)
**Input**:
```python
List[SatelliteTile]:
tile_id: str
image: np.ndarray # Optional - only if building index locally
gps_center: GPSPoint
bounds: TileBounds
descriptor: Optional[np.ndarray] # Pre-computed descriptor from provider
index_path: str # Path to pre-built Faiss index file from satellite provider
```
**Output**:
```python
bool: True if database initialized successfully
bool: True if database loaded successfully
```
**Processing Flow**:
1. **Load pre-built index**: Satellite provider provides pre-computed DINOv2 descriptors
2. If descriptors provided:
- Load descriptors directly
- Build Faiss index using H04 Faiss Index Manager
3. If descriptors not provided (fallback):
- For each satellite tile:
- compute_location_descriptor(tile.image) → descriptor
- Store descriptor with tile metadata
- Build Faiss index
4. Persist index to disk for fast startup
1. Load pre-built Faiss index from index_path
2. Load tile metadata (tile_id → gps_center, bounds mapping)
3. Validate index integrity (check descriptor dimensions, tile count)
4. Return True if loaded successfully
**Satellite Provider Integration**:
- **Primary**: Satellite provider builds semantic index offline
- Provider exposes index via API or file download
- F08 loads pre-built index at startup
- **Fallback**: F08 can build index locally if provider doesn't supply it
**Satellite Provider Responsibility**:
- Satellite provider builds the semantic index offline using DINOv2 + VLAD
- Provider delivers index file along with satellite tiles
- Index format: Faiss IVF or HNSW index + tile metadata JSON
- Provider is responsible for index updates when satellite data changes
**Error Conditions**:
- Raises `IndexNotFoundError`: Index file not found
- Raises `IndexCorruptedError`: Index file corrupted or invalid format
- Raises `MetadataMismatchError`: Metadata doesn't match index
**Performance**:
- **Load pre-built index**: <10 seconds (fast startup)
- **Build index locally**: ~10-30 minutes for 10,000 tiles (fallback only)
- **Load time**: <10 seconds for 10,000+ tiles
**Test Cases**:
1. **Load pre-built index**: Completes successfully, fast startup
2. **Fallback local building**: Builds index if provider doesn't supply it
3. **Index query**: Works correctly after loading
1. **Load valid index**: Completes successfully, index operational
2. **Index not found**: Raises IndexNotFoundError
3. **Corrupted index**: Raises IndexCorruptedError
4. **Index query after load**: Works correctly
---
@@ -351,10 +345,10 @@ np.ndarray: Aggregated descriptor vector (4096-dim or 8192-dim)
2. UAV images from autumn
3. retrieve_candidate_tiles() → correct match despite appearance change
### Test 3: Database Initialization
1. Prepare 500 satellite tiles
2. initialize_database(tiles)
3. Verify Faiss index built
### Test 3: Index Loading
1. Prepare pre-built index file from satellite provider
2. load_index(index_path)
3. Verify Faiss index loaded correctly
4. Query with test image → returns matches
### Test 4: Chunk Semantic Matching