| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- """
- System Information Panel
- Displays performance metrics and model accuracy statistics.
- """
- from PyQt5.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout, QLabel
- from PyQt5.QtGui import QFont
- from resources.styles import GROUP_BOX_STYLE, HEADER_LABEL_STYLE, STATUS_LABEL_STYLE
- class SystemInfoPanel(QGroupBox):
- """
- Panel displaying system information and statistics.
-
- Shows:
- - Performance metrics (processing time, throughput, uptime)
- - Model accuracy statistics (calculated from confidence scores)
-
- Note: Memory usage is displayed in SystemStatusPanel, not here.
- """
-
- def __init__(self):
- """Initialize the system information panel."""
- super().__init__("System Information")
- self.setStyleSheet(GROUP_BOX_STYLE)
- self.init_ui()
-
- def init_ui(self):
- """Initialize the UI components."""
- layout = QHBoxLayout()
-
- # Performance Metrics (left side)
- perf_layout = QVBoxLayout()
- perf_label = QLabel("Performance Metrics:")
- perf_label.setFont(QFont("Arial", 16, QFont.Bold))
- perf_label.setStyleSheet(HEADER_LABEL_STYLE)
- perf_layout.addWidget(perf_label)
-
- # Performance metrics
- self.metrics = {
- 'processing_time': QLabel("• Average Processing Time: --"),
- 'throughput': QLabel("• Daily Throughput: 0 fruits analyzed"),
- 'uptime': QLabel("• System Uptime: 0h 0m")
- }
-
- for metric_label in self.metrics.values():
- metric_label.setStyleSheet(STATUS_LABEL_STYLE)
- perf_layout.addWidget(metric_label)
-
- layout.addLayout(perf_layout)
-
- # Model Accuracy (right side)
- accuracy_layout = QVBoxLayout()
- accuracy_header = QLabel("Model Accuracy (Last 100 Tests):")
- accuracy_header.setFont(QFont("Arial", 16, QFont.Bold))
- accuracy_header.setStyleSheet(HEADER_LABEL_STYLE)
- accuracy_layout.addWidget(accuracy_header)
-
- # Accuracy metrics (mapped from model_type returned by DataManager)
- # Model types: 'audio', 'defect', 'locule', 'maturity', 'shape'
- self.accuracies = {
- 'audio': QLabel("• Ripeness Classification: --"),
- 'defect': QLabel("• Defect Detection: --"),
- 'locule': QLabel("• Locule Detection: --"),
- 'maturity': QLabel("• Maturity Assessment: --"),
- 'shape': QLabel("• Shape Analysis: --")
- }
-
- for accuracy_label in self.accuracies.values():
- accuracy_label.setStyleSheet(STATUS_LABEL_STYLE)
- accuracy_layout.addWidget(accuracy_label)
-
- layout.addLayout(accuracy_layout)
- self.setLayout(layout)
-
- def update_processing_time(self, avg_time: float):
- """
- Update average processing time.
-
- Args:
- avg_time: Average processing time in seconds
- """
- self.metrics['processing_time'].setText(f"• Average Processing Time: {avg_time:.1f}s per fruit")
-
- def update_throughput(self, count: int):
- """
- Update daily throughput.
-
- Args:
- count: Number of fruits analyzed today
- """
- self.metrics['throughput'].setText(f"• Daily Throughput: {count:,} fruits analyzed")
-
- def update_uptime(self, hours: int, minutes: int):
- """
- Update system uptime.
-
- Args:
- hours: Uptime hours
- minutes: Uptime minutes
- """
- self.metrics['uptime'].setText(f"• System Uptime: {hours}h {minutes}m")
-
-
- def update_accuracy(self, model: str, accuracy: float):
- """
- Update model accuracy.
-
- Args:
- model: Model name from DataManager ('audio', 'defect', 'locule', 'maturity', 'shape')
- accuracy: Accuracy percentage (0-100)
- """
- if model in self.accuracies:
- label_map = {
- 'audio': f"• Ripeness Classification: {accuracy:.1f}%",
- 'defect': f"• Defect Detection: {accuracy:.1f}%",
- 'locule': f"• Locule Detection: {accuracy:.1f}%",
- 'maturity': f"• Maturity Assessment: {accuracy:.1f}%",
- 'shape': f"• Shape Analysis: {accuracy:.1f}%"
- }
- self.accuracies[model].setText(label_map[model])
|