import type { DetectionModelCapability, ModelAssetRead, YoloPreflightResponse, } from '../../types' import { DETECTION_OPERATOR_PROFILES, type DetectionOperatorProfile } from './detectionProfiles' import { analysisModelAvailabilityMessage } from '../models/modelOptions' interface DetectionModelManagementProps { detectionModels: DetectionModelCapability[] modelAssets: ModelAssetRead[] loadingDetectionModels: boolean detectionModelError: string | null modelAssetError: string | null selectedDetectionModelId: string selectedModelAssetId: string detectionConfidenceThreshold: number yoloPreflight: YoloPreflightResponse | null loadingYoloPreflight: boolean yoloPreflightError: string | null onRefreshYoloPreflight: () => void onSelectModelAsset: (modelAssetId: string) => void onApplyOperatorProfile: (profile: DetectionOperatorProfile) => void } export function detectionModelLabel(model: DetectionModelCapability): string { if (model.model_id === 'yolo-configured') return 'Lokaal gebouwmodel' if (model.model_id === 'manual-fixture-detector') return 'Testmodel (alleen voor demo)' if (model.model_id === 'yolo-placeholder') return 'Gebouwmodel nog niet geconfigureerd' return model.display_name } function formatModelAssetSize(sizeBytes: number): string { if (!Number.isFinite(sizeBytes) || sizeBytes <= 0) return 'n.v.t.' const megabytes = sizeBytes / (1024 * 1024) return `${megabytes.toLocaleString('nl-BE', { maximumFractionDigits: 1 })} MB` } function statusLabel(value: string): string { if (value === 'configured' || value === 'ready') return 'gereed' if (value === 'not_configured') return 'niet geconfigureerd' if (value === 'dependency_unavailable') return 'software ontbreekt' if (value === 'accelerator_unavailable') return 'GPU niet beschikbaar' if (value === 'contract_incomplete') return 'provenance onvolledig' return value.replace(/_/g, ' ') } export function DetectionModelManagement({ detectionModels, modelAssets, loadingDetectionModels, detectionModelError, modelAssetError, selectedDetectionModelId, selectedModelAssetId, detectionConfidenceThreshold, yoloPreflight, loadingYoloPreflight, yoloPreflightError, onRefreshYoloPreflight, onSelectModelAsset, onApplyOperatorProfile, }: DetectionModelManagementProps): JSX.Element { const selectedModelAsset = modelAssets.find((asset) => asset.model_asset_id === selectedModelAssetId) ?? null const selectedOperatorProfile = DETECTION_OPERATOR_PROFILES.find( (profile) => profile.modelAssetId === selectedModelAssetId, ) ?? null const yoloRuntimeReady = Boolean( yoloPreflight?.checks.enabled && yoloPreflight.checks.dependencies_available && yoloPreflight.checks.accelerator_ready === true && yoloPreflight.checks.model_file_exists, ) return (
Technische modelinformatie {detectionModels.length} registraties
{loadingDetectionModels ? (
Analysemodellen worden gecontroleerd.

GeoIntel leest de modelregistratie en lokale bestanden.

) : null} {detectionModelError ? (
De modelregistratie is niet bereikbaar.

{detectionModelError}

) : null} {modelAssetError ? (
De lokale modelbestanden konden niet worden gelezen.

{modelAssetError}

) : null} {detectionModels.length === 0 && !loadingDetectionModels ? (
De backend meldt geen analysemodellen.

Vernieuw de status zodra de backend opnieuw bereikbaar is.

) : null}
    {detectionModels.map((model) => (
  • {detectionModelLabel(model)} {statusLabel(model.status)}

    Ondersteunde klassen: {model.supported_classes.join(', ') || 'niet opgegeven'}

    {analysisModelAvailabilityMessage(model)}

    Technische identificatie
    Model-ID: {model.model_id} Framework: {model.framework} Taaktype: {model.task_type}
  • ))}
{selectedDetectionModelId === 'yolo-configured' ? (
Modelkeuze voor beheerders {selectedOperatorProfile?.displayName ?? selectedModelAsset?.display_name ?? 'Geen lokaal model'}

Lokaal modelbestand

GeoIntel kiest automatisch het actieve lokale model. Een andere keuze geldt alleen voor deze analyse.

{selectedModelAsset ? 'model gekozen' : 'geen model gekozen'}
{DETECTION_OPERATOR_PROFILES.map((profile) => { const profileAsset = modelAssets.find((asset) => asset.model_asset_id === profile.modelAssetId) const profileSelected = selectedModelAssetId === profile.modelAssetId && Math.abs(detectionConfidenceThreshold - profile.confidenceThreshold) < 0.0001 return (
{profile.displayName} {profile.independentTestProven ? 'onafhankelijk getoetst' : 'historisch, geen releasebewijs'}

{profile.description}

drempel {profile.confidenceThreshold.toFixed(2)} historische precisie {profile.precision.toFixed(3)} historische herkenningsgraad {profile.recall.toFixed(3)} historische F1 {profile.f1.toFixed(3)} positieve controles {profile.positiveSampleCount} ergste achtergrondmonster {profile.maxBackgroundDetections} van{' '} {profile.backgroundSampleCount}

Achtergrondtoets: {profile.backgroundGate}. Meting: {profile.evidenceReference}.

{profile.limitationMessage}

) })}
{modelAssets.length === 0 && !loadingDetectionModels ? (
Geen lokaal modelbestand gevonden.

Plaats een gecontroleerd model in de modelmap of configureer het bestaande YOLO-modelpad.

) : null} {selectedModelAsset ? (
Bestands- en integriteitsgegevens

Bestand: {selectedModelAsset.filename}

Status: {statusLabel(selectedModelAsset.status)}

Actief servermodel: {selectedModelAsset.active ? 'ja' : 'nee'}

Automatisch downloaden: {selectedModelAsset.will_download_models ? 'ja' : 'nee'}

Grootte: {formatModelAssetSize(selectedModelAsset.size_bytes)}

SHA-256: {selectedModelAsset.sha256.slice(0, 12)}

Pad: {selectedModelAsset.model_path}

) : null}
) : null}
Technische runtimecontrole {yoloRuntimeReady ? 'gereed' : statusLabel(yoloPreflight?.status ?? 'niet geladen')}

YOLO-runtimecontrole

Deze alleen-lezen controle start geen analyse en downloadt geen modelbestanden.

{loadingYoloPreflight ? (
De YOLO-runtime wordt gecontroleerd.

GeoIntel controleert configuratie, optionele software en lokale bestanden.

) : null} {yoloPreflightError ? (
De YOLO-runtimecontrole is niet beschikbaar.

{yoloPreflightError}

) : null} {!yoloPreflight && !loadingYoloPreflight && !yoloPreflightError ? (
Nog geen runtimecontrole geladen.

Vernieuw de controle voordat je een lokaal model gebruikt.

) : null}
{yoloPreflight ? (
YOLO ingeschakeld {yoloPreflight.checks.enabled ? 'ja' : 'nee'}
Benodigde software {yoloPreflight.checks.dependencies_available === true ? 'beschikbaar' : yoloPreflight.checks.dependencies_available === false ? 'ontbreekt' : 'niet gecontroleerd'}
Lokaal modelbestand {yoloPreflight.checks.model_file_exists === true ? 'gevonden' : yoloPreflight.checks.model_path_set ? 'ontbreekt' : 'niet geconfigureerd'}
GPU-versnelling {yoloPreflight.runtime.cuda_available === true ? 'beschikbaar' : yoloPreflight.runtime.cuda_available === false ? 'niet beschikbaar' : 'niet gecontroleerd'}
Beeldtegels {yoloPreflight.checks.manifest_valid === true ? 'geldig' : yoloPreflight.checks.manifest_path_set ? 'ongeldig' : 'niet opgegeven'}
0 ? 'lab-readiness-item lab-readiness-item-ready' : 'lab-readiness-item'}> Aantal beeldtegels {yoloPreflight.tile_count} / {yoloPreflight.max_tiles}
Versies en serverpaden
PyTorch: {yoloPreflight.runtime.torch_version ?? 'n.v.t.'} Ultralytics: {yoloPreflight.runtime.ultralytics_version ?? 'n.v.t.'} YOLO-configuratiemap: {yoloPreflight.runtime.yolo_config_dir ?? 'n.v.t.'} Modelmap: {yoloPreflight.runtime.model_directory ?? 'n.v.t.'} Model-ID: {yoloPreflight.model_asset_id ?? 'n.v.t.'}
) : null}
) }