-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplifies system stats and moves them to a widget
- Loading branch information
Showing
2 changed files
with
34 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import psutil | ||
import torch | ||
|
||
from airunner.widgets.base_widget import BaseWidget | ||
from airunner.widgets.status.templates.status_ui import Ui_status_widget | ||
|
||
|
||
class StatusWidget(BaseWidget): | ||
widget_class_ = Ui_status_widget | ||
|
||
def update_system_stats(self, queue_size): | ||
has_cuda = torch.cuda.is_available() | ||
nsfw_status = f"NSFW Filter {'On' if self.settings_manager.nsfw_filter else 'Off'}" | ||
queue_stats = f"Queued items: {queue_size}" | ||
cuda_status = f"Using {'GPU' if has_cuda else 'CPU'}" | ||
vram_stats = f"VRAM allocated {torch.cuda.memory_allocated() / 1024 ** 3:.1f}GB cached {torch.cuda.memory_cached() / 1024 ** 3:.1f}GB" | ||
ram_stats = f"RAM {psutil.virtual_memory().percent:.1f}%" | ||
self.ui.nsfw_status.setText(nsfw_status) | ||
self.ui.cuda_status.setText(cuda_status) | ||
self.ui.queue_stats.setText(queue_stats) | ||
self.ui.vram_stats.setText(vram_stats) | ||
self.ui.ram_stats.setText(ram_stats) | ||
|
||
enabled_css = "QLabel { color: #00ff00; }" | ||
disabled_css = "QLabel { color: #ff0000; }" | ||
|
||
self.ui.nsfw_status.setStyleSheet(enabled_css if self.settings_manager.nsfw_filter else disabled_css) | ||
self.ui.cuda_status.setStyleSheet(enabled_css if has_cuda else disabled_css) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters