import { Modal, Select, Button, Group, Stack, Text, Center } from '@mantine/core' import { IconAlertCircle } from '@tabler/icons-react' import { useState } from 'react' import classes from './AdvancedAnalysisModal.module.css' const CLASS_METADATA = { 'Drzewa / Las': 'Trees / Forest', 'Zarośla': 'Shrubland', 'Trawa / Łąki': 'Grassland', 'Uprawy rolne': 'Crops', 'Zabudowa': 'Built area', 'Goły grunt': 'Bare Ground', 'Śnieg i lód': 'Snow & Ice', 'Woda': 'Water', 'Tereny podmokłe': 'Flooded vegetation', 'Namorzyny': 'Mangroves', 'Mchy i porosty': 'Moss & Lichen', 'Brak danych': 'No Data' }; const MASK_INFO = { water_ndwi: { name: "NDWI - Water", description: "Open water bodies", color: "#1971c2", formula: "(G - NIR)/(G + NIR)" }, water_mndwi: { name: "MNDWI - Urban Water", description: "Water in urban areas", color: "#1864ab", formula: "(G - SWIR)/(G + SWIR)" }, water_awei: { name: "AWEI - Automated", description: "Shadow suppression", color: "#0b7285", formula: "4(G-SWIR)-(0.25NIR+2.75SWIR2)" }, vegetation_ndvi: { name: "NDVI - Vegetation", description: "Plant health", color: "#2f9e44", formula: "(NIR - R)/(NIR + R)" }, vegetation_evi: { name: "EVI - Enhanced Veg", description: "Dense canopy", color: "#5c940d", formula: "2.5(NIR-R)/(NIR+6R-7.5B+1)" }, buildings_ndbi: { name: "NDBI - Built-up", description: "Urban structures", color: "#c92a2a", formula: "(SWIR - NIR)/(SWIR + NIR)" }, baresoil_bsi: { name: "BSI - Bare Soil", description: "Soil detection", color: "#d9480f", formula: "((SWIR+R)-(NIR+B))/((SWIR+R)+(NIR+B))" } }; export default function AdvancedAnalysisModal({ opened, onClose, onRunCompare, isLoading, isError, results }) { const [modelA, setModelA] = useState('terramind_v1_small_generate'); const [modelB, setModelB] = useState('terramind_v1_large_generate'); const modelOptions = [ { value: 'terramind_v1_tiny_generate', label: 'Terramind v1 Tiny' }, { value: 'terramind_v1_small_generate', label: 'Terramind v1 Small' }, { value: 'terramind_v1_base_generate', label: 'Terramind v1 Base' }, { value: 'terramind_v1_large_generate', label: 'Terramind v1 Large' }, ]; const getModelLabel = (model) => { const parts = model.split('_'); return parts[2] ? parts[2].toUpperCase() + " Model" : model; }; return ( {!results && (
Select models to compare {isError && (
{isError}
)}
)} {results && !isLoading && (
{getModelLabel(modelA)}
{getModelLabel(modelB)}
Spectral Indices Masks
{Object.entries(results.modelA.masks).map(([key, src]) => { const info = MASK_INFO[key] || { name: key, color: '#444', formula: 'N/A' }; return (
{info.name}
{info.name}
{info.description}
{info.formula}
); })}
{results.metrics && (
{results.metrics.raw && (
Metrics - Raw Segmentation (without Spectral Indices)
{results.metrics.raw.class_details && Object.keys(results.metrics.raw.class_details).length > 0 && (
Per-Class Metrics
{Object.entries(results.metrics.raw.class_details).map(([className, metrics]) => (
{CLASS_METADATA[className] || className}
IoU: {metrics.iou?.toFixed(2)}%
Precision: {metrics.precision?.toFixed(2)}%
Recall: {metrics.recall?.toFixed(2)}%
))}
)}
)} {results.metrics.corrected && (
Metrics - Corrected Segmentation (with Spectral Indices)
{results.metrics.corrected.class_details && Object.keys(results.metrics.corrected.class_details).length > 0 && (
Per-Class Metrics
{Object.entries(results.metrics.corrected.class_details).map(([className, metrics]) => (
{CLASS_METADATA[className] || className}
IoU: {metrics.iou?.toFixed(2)}%
Precision: {metrics.precision?.toFixed(2)}%
Recall: {metrics.recall?.toFixed(2)}%
))}
)}
)}
)}
)}
); } function ImageCard({ src, title, subtitle, borderColor }) { return (
{title}
{title}
{subtitle}
); } function MetricCard({ label, value, unit, color, highlight = false }) { return (
{label}
{value} {unit}
); }