'use client'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { ClassificationResult } from './classification-result'; import { DetectionResultList } from './detection-result'; import { PerformanceMetrics } from './performance-metrics'; import { ConfidenceSlider } from './confidence-slider'; import { VideoProgress } from './video-progress'; import { InferenceOptions } from './inference-options'; import { useInferenceStore } from '@/stores/inference-store'; import { useCameraStore } from '@/stores/camera-store'; import { isClassificationTask } from '@/lib/classification'; import { useTranslation } from '@/lib/i18n'; interface InferencePanelProps { deviceId: string; } export function InferencePanel({ deviceId }: InferencePanelProps) { const { t } = useTranslation(); const { result, fps, avgLatency, isRunning, confidenceThreshold, batchResults } = useInferenceStore(); const { sourceType, batchSelectedIndex, batchImages, batchProcessedCount } = useCameraStore(); const isVideoMode = sourceType === 'video'; const isBatchMode = sourceType === 'batch_image'; const displayResult = isBatchMode ? batchResults[batchSelectedIndex] : result; const classifications = displayResult?.classifications || []; const detections = displayResult?.detections || []; // Branch on "is classification?" so detection stays the safe fall-through // under either taskType spelling (see lib/classification.ts). const isClassification = isClassificationTask(displayResult?.taskType); return (
{isVideoMode && isRunning && } {isBatchMode && batchImages.length > 0 && ( {t('inference.batchProgress')}
{t('inference.processed')} {batchProcessedCount} / {batchImages.length}
{batchImages[batchSelectedIndex] && (
{t('inference.currentImage')} {batchImages[batchSelectedIndex].filename}
)}
)} {t('inference.confidenceFilter')} {t('inference.options.title')} {isClassification ? t('inference.classificationResults') : t('inference.detectionResults')} {isClassification ? ( ) : ( )} {displayResult && ( {t('inference.details')}
{t('inference.model')} {displayResult.modelId}
{t('inference.task')} {displayResult.taskType}
{t('inference.latency')} {displayResult.latencyMs.toFixed(1)} ms
)}
); }