├── .gitignore ├── Amuse.UI ├── Amuse.UI.csproj ├── Amuse.nsi ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── Behaviors │ ├── ShiftEnterBehavior.cs │ ├── SliderMouseWheelBehavior.cs │ └── SmoothProgressBarBehavior.cs ├── Commands │ ├── AsyncRelayCommand.cs │ └── RelayCommand.cs ├── Converters │ ├── BooleanToHiddenConverter.cs │ ├── ComboBoxAllItemConverter.cs │ ├── DiffuserVisibilityConverter.cs │ ├── EnumDescriptionConverter.cs │ ├── InverseBoolConverter.cs │ ├── InverseBooleanToHiddenConverter.cs │ ├── InverseBooleanToVisibilityConverter.cs │ ├── InverseNullVisibilityConverter.cs │ ├── NullVisibilityConverter.cs │ └── PipelineVisibilityConverter.cs ├── Dialogs │ ├── AddModelDialog.xaml │ ├── AddModelDialog.xaml.cs │ ├── AddUpscaleModelDialog.xaml │ ├── AddUpscaleModelDialog.xaml.cs │ ├── CropImageDialog.xaml │ ├── CropImageDialog.xaml.cs │ ├── MessageDialog.xaml │ ├── MessageDialog.xaml.cs │ ├── TextInputDialog.xaml │ ├── TextInputDialog.xaml.cs │ ├── UpdateModelDialog.xaml │ ├── UpdateModelDialog.xaml.cs │ ├── UpdateModelMetadataDialog.xaml │ ├── UpdateModelMetadataDialog.xaml.cs │ ├── UpdateModelSettingsDialog.xaml │ ├── UpdateModelSettingsDialog.xaml.cs │ ├── UpdateUpscaleModelDialog.xaml │ ├── UpdateUpscaleModelDialog.xaml.cs │ ├── UpdateUpscaleModelSettingsDialog.xaml │ ├── UpdateUpscaleModelSettingsDialog.xaml.cs │ ├── ViewModelMetadataDialog.xaml │ └── ViewModelMetadataDialog.xaml.cs ├── Fonts │ ├── fa-brands-400.ttf │ ├── fa-duotone-900.ttf │ ├── fa-light-300.ttf │ ├── fa-regular-400.ttf │ └── fa-solid-900.ttf ├── Helpers │ └── RepositoryDownloader.cs ├── Images │ ├── Icon.ico │ ├── Icon.png │ ├── Model.png │ ├── Upscale.png │ ├── placeholder.png │ └── placeholder_sm.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Models │ ├── AmuseSettings.cs │ ├── BatchOptionsModel.cs │ ├── ImageInput.cs │ ├── ImageResult.cs │ ├── ModelFileViewModel.cs │ ├── ModelTemplateCategory.cs │ ├── ModelTemplateViewModel.cs │ ├── PromptOptionsModel.cs │ ├── SchedulerOptionsModel.cs │ ├── StableDiffusionModelSetViewModel.cs │ ├── StableDiffusionModelTemplate.cs │ ├── StableDiffusionSchedulerDefaults.cs │ ├── UpdateModelSetViewModel.cs │ ├── UpdateUpscaleModelSetViewModel.cs │ ├── UpscaleInfoModel.cs │ ├── UpscaleModelSetViewModel.cs │ ├── UpscaleModelTemplate.cs │ ├── UpscaleResult.cs │ └── ValidationResult.cs ├── Services │ ├── DialogService.cs │ ├── IDialogService.cs │ ├── IModelDownloadService.cs │ ├── IModelFactory.cs │ ├── ModelDownloadService.cs │ └── ModelFactory.cs ├── UserControls │ ├── CachedImage.cs │ ├── FilePickerTextBox.xaml │ ├── FilePickerTextBox.xaml.cs │ ├── FontAwesome.xaml │ ├── FontAwesome.xaml.cs │ ├── ImageInputControl.xaml │ ├── ImageInputControl.xaml.cs │ ├── ImageResultControl.xaml │ ├── ImageResultControl.xaml.cs │ ├── ModelPickerControl.xaml │ ├── ModelPickerControl.xaml.cs │ ├── PaintInputControl.xaml │ ├── PaintInputControl.xaml.cs │ ├── PromptControl.xaml │ ├── PromptControl.xaml.cs │ ├── SchedulerControl.xaml │ ├── SchedulerControl.xaml.cs │ ├── UpscalePickerControl.xaml │ └── UpscalePickerControl.xaml.cs ├── Utils.cs ├── Views │ ├── INavigatable.cs │ ├── ImageInpaintView.xaml │ ├── ImageInpaintView.xaml.cs │ ├── ImageToImageView.xaml │ ├── ImageToImageView.xaml.cs │ ├── LoggerView.xaml │ ├── LoggerView.xaml.cs │ ├── ModelSettingsView.xaml │ ├── ModelSettingsView.xaml.cs │ ├── PaintToImageView.xaml │ ├── PaintToImageView.xaml.cs │ ├── SettingsView.xaml │ ├── SettingsView.xaml.cs │ ├── TextToImageView.xaml │ ├── TextToImageView.xaml.cs │ ├── UpscaleView.xaml │ └── UpscaleView.xaml.cs ├── WindowLogger.cs └── appsettings.json ├── Amuse.sln ├── Assets ├── Amuse-Logo-1024.png ├── Amuse-Logo-128.png ├── Amuse-Logo-2048.png ├── Amuse-Logo-256.png ├── Amuse-Logo-512.png ├── Amuse-Logo-64.png ├── Amuse-Logo.psd ├── Icon-1024.png ├── Icon-128.png ├── Icon-2048.png ├── Icon-256.png ├── Icon-512.png └── Icon-64.png ├── Docs ├── GettingStarted.md └── ModelTemplate.md ├── LICENSE └── README.md /Amuse.UI/Amuse.UI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1.0.0 5 | WinExe 6 | net7.0-windows 7 | disable 8 | true 9 | true 10 | x64 11 | Debug;Release;Debug-DML;Debug-Cuda;Release-DML;Release-Cuda;Debug-TensorRT;Release-TensorRT 12 | Images\Icon.ico 13 | Amuse 14 | 15 | 16 | 17 | True 18 | 19 | 20 | 21 | True 22 | 23 | 24 | 25 | True 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | PreserveNewest 47 | true 48 | PreserveNewest 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /Amuse.UI/Amuse.nsi: -------------------------------------------------------------------------------- 1 | ; Amuse.nsi 2 | ; 3 | ; This script is based on Amuse.nsi but it remembers the directory, 4 | ; has uninstall support and (optionally) installs start menu shortcuts. 5 | ; 6 | ; It will install example2.nsi into a directory that the user selects. 7 | ; 8 | ; See install-shared.nsi for a more robust way of checking for administrator rights. 9 | ; See install-per-user.nsi for a file association example. 10 | 11 | ;-------------------------------- 12 | !define BUILD_VERSION "v0.1.0" 13 | !define BUILD_NAME "CPU" 14 | 15 | !define BUILD_FOLDER "D:\Build\Amuse" 16 | !define MUI_ICON "${BUILD_FOLDER}\Assets\Icon.ico" 17 | !define MUI_UNICON "${BUILD_FOLDER}\Assets\Icon.ico" 18 | 19 | !include "MUI2.nsh" 20 | 21 | ; The name of the installer 22 | Name "Amuse" 23 | 24 | ; The file to write 25 | OutFile "Amuse_${BUILD_VERSION}_${BUILD_NAME}.exe" 26 | 27 | ; Request application privileges for Windows Vista and higher 28 | RequestExecutionLevel admin 29 | 30 | ; Build Unicode installer 31 | Unicode True 32 | 33 | ; The default installation directory 34 | InstallDir $PROGRAMFILES64\Amuse 35 | 36 | ; Registry key to check for directory (so if you install again, it will 37 | ; overwrite the old one automatically) 38 | InstallDirRegKey HKLM "Software\Amuse" "Install_Dir" 39 | 40 | ;-------------------------------- 41 | 42 | ; Pages 43 | 44 | !insertmacro MUI_PAGE_DIRECTORY 45 | !insertmacro MUI_PAGE_INSTFILES 46 | 47 | !insertmacro MUI_LANGUAGE "English" 48 | 49 | UninstPage uninstConfirm 50 | UninstPage instfiles 51 | 52 | ;-------------------------------- 53 | 54 | ; The stuff to install 55 | Section "Amuse (required)" 56 | 57 | SectionIn RO 58 | 59 | ; Set output path to the installation directory. 60 | SetOutPath $INSTDIR 61 | 62 | ; Put file there 63 | File "${BUILD_FOLDER}\Amuse_${BUILD_NAME}\*.*" 64 | File "${BUILD_FOLDER}\Amuse_${BUILD_NAME}\runtimes\win-x64\native\*.*" 65 | 66 | ; Write the installation path into the registry 67 | WriteRegStr HKLM SOFTWARE\NSIS_Amuse "Install_Dir" "$INSTDIR" 68 | 69 | ; Write the uninstall keys for Windows 70 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Amuse" "DisplayName" "Amuse" 71 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Amuse" "UninstallString" '"$INSTDIR\uninstall.exe"' 72 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Amuse" "NoModify" 1 73 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\EAmuse" "NoRepair" 1 74 | WriteUninstaller "$INSTDIR\uninstall.exe" 75 | 76 | SectionEnd 77 | 78 | ; Optional section (can be disabled by the user) 79 | Section "Start Menu Shortcuts" 80 | 81 | CreateDirectory "$SMPROGRAMS\Amuse" 82 | CreateShortcut "$SMPROGRAMS\Amuse\Uninstall.lnk" "$INSTDIR\uninstall.exe" 83 | CreateShortcut "$SMPROGRAMS\Amuse\Amuse.lnk" "$INSTDIR\Amuse.exe" 84 | 85 | SectionEnd 86 | 87 | ;-------------------------------- 88 | 89 | ; Uninstaller 90 | 91 | Section "Uninstall" 92 | 93 | ; Remove registry keys 94 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Amuse" 95 | DeleteRegKey HKLM SOFTWARE\Amuse 96 | 97 | ; Remove files and uninstaller 98 | Delete $INSTDIR\*.* 99 | Delete $INSTDIR\uninstall.exe 100 | 101 | ; Remove shortcuts, if any 102 | Delete "$SMPROGRAMS\Amuse\*.lnk" 103 | 104 | ; Remove directories 105 | RMDir "$SMPROGRAMS\Amuse" 106 | RMDir "$INSTDIR" 107 | 108 | SectionEnd 109 | 110 | -------------------------------------------------------------------------------- /Amuse.UI/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Amuse.UI.Dialogs; 2 | using Amuse.UI.Models; 3 | using Amuse.UI.Services; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.Extensions.Logging; 7 | using OnnxStack.Core; 8 | using OnnxStack.ImageUpscaler; 9 | using System; 10 | using System.Windows; 11 | using System.Windows.Threading; 12 | 13 | namespace Amuse.UI 14 | { 15 | /// 16 | /// Interaction logic for App.xaml 17 | /// 18 | public partial class App : Application 19 | { 20 | private static IHost _applicationHost; 21 | 22 | public App() 23 | { 24 | var builder = Host.CreateApplicationBuilder(); 25 | builder.Logging.ClearProviders(); 26 | builder.Services.AddLogging((loggingBuilder) => loggingBuilder.AddWindowLogger()); 27 | 28 | // Add OnnxStackStableDiffusion 29 | builder.Services.AddOnnxStackStableDiffusion(); 30 | builder.Services.AddOnnxStackImageUpscaler(); 31 | builder.Services.AddOnnxStackConfig(); 32 | 33 | // Add Windows 34 | builder.Services.AddSingleton(); 35 | builder.Services.AddTransient(); 36 | builder.Services.AddTransient(); 37 | builder.Services.AddTransient(); 38 | builder.Services.AddTransient(); 39 | builder.Services.AddTransient(); 40 | builder.Services.AddTransient(); 41 | builder.Services.AddTransient(); 42 | builder.Services.AddTransient(); 43 | builder.Services.AddTransient(); 44 | builder.Services.AddTransient(); 45 | builder.Services.AddTransient (); 46 | builder.Services.AddSingleton(); 47 | builder.Services.AddSingleton(); 48 | builder.Services.AddSingleton(); 49 | 50 | // Build App 51 | _applicationHost = builder.Build(); 52 | } 53 | 54 | 55 | public static T GetService() => _applicationHost.Services.GetService(); 56 | 57 | public static void UIInvoke(Action action, DispatcherPriority priority = DispatcherPriority.Render) => Current.Dispatcher.BeginInvoke(priority, action); 58 | 59 | 60 | /// 61 | /// Raises the event. 62 | /// 63 | /// The instance containing the event data. 64 | protected override async void OnStartup(StartupEventArgs e) 65 | { 66 | base.OnStartup(e); 67 | await _applicationHost.StartAsync(); 68 | GetService().Show(); 69 | } 70 | 71 | 72 | /// 73 | /// Raises the event. 74 | /// 75 | /// The instance containing the event data. 76 | protected override async void OnExit(ExitEventArgs e) 77 | { 78 | await _applicationHost.StopAsync(); 79 | base.OnExit(e); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Amuse.UI/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /Amuse.UI/Behaviors/ShiftEnterBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Input; 5 | 6 | namespace Amuse.UI.Behaviors 7 | { 8 | /// 9 | /// Behaviour to use Shift + Enfer to add a new line to a TextBox allowing IsDefault Commands to be fired on Enter 10 | /// 11 | public class ShiftEnterBehavior 12 | { 13 | 14 | /// 15 | /// The enable property 16 | /// 17 | public static readonly DependencyProperty EnableProperty = DependencyProperty.RegisterAttached("Enable", typeof(bool), typeof(ShiftEnterBehavior), new PropertyMetadata(false, OnEnableChanged)); 18 | 19 | 20 | /// 21 | /// Gets the enable value. 22 | /// 23 | /// The object. 24 | public static bool GetEnable(DependencyObject obj) 25 | { 26 | return (bool)obj.GetValue(EnableProperty); 27 | } 28 | 29 | /// 30 | /// Sets the enable valse. 31 | /// 32 | /// The object. 33 | /// if set to true [value]. 34 | public static void SetEnable(DependencyObject obj, bool value) 35 | { 36 | obj.SetValue(EnableProperty, value); 37 | } 38 | 39 | 40 | /// 41 | /// Called when enable changed. 42 | /// 43 | /// The object. 44 | /// The instance containing the event data. 45 | private static void OnEnableChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) 46 | { 47 | if (obj is TextBox textBox) 48 | { 49 | bool attach = (bool)e.NewValue; 50 | 51 | if (attach) 52 | { 53 | textBox.PreviewKeyDown += TextBox_PreviewKeyDown; 54 | } 55 | else 56 | { 57 | textBox.PreviewKeyDown -= TextBox_PreviewKeyDown; 58 | } 59 | } 60 | } 61 | 62 | 63 | /// 64 | /// Handles the PreviewKeyDown event of the TextBox control. 65 | /// 66 | /// The source of the event. 67 | /// The instance containing the event data. 68 | private static void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) 69 | { 70 | if (e.Key == Key.Enter && Keyboard.Modifiers == ModifierKeys.Shift) 71 | { 72 | if (sender is TextBox textBox) 73 | { 74 | e.Handled = true; 75 | textBox.AppendText(Environment.NewLine); 76 | textBox.CaretIndex = textBox.Text.Length; 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Amuse.UI/Behaviors/SliderMouseWheelBehavior.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xaml.Behaviors; 2 | using System.Windows.Controls; 3 | using System.Windows.Input; 4 | 5 | namespace Amuse.UI.Behaviors 6 | { 7 | public class SliderMouseWheelBehavior : Behavior 8 | { 9 | /// 10 | /// Handles the PreviewMouseWheel event of the AssociatedObject control. 11 | /// 12 | /// The source of the event. 13 | /// The instance containing the event data. 14 | private void AssociatedObject_PreviewMouseWheel(object sender, MouseWheelEventArgs e) 15 | { 16 | var slider = (Slider)sender; 17 | if (e.Delta > 0) 18 | { 19 | var newValue = slider.Value + slider.TickFrequency; 20 | if (newValue > slider.Maximum) 21 | return; 22 | 23 | slider.Value = newValue; 24 | } 25 | else 26 | { 27 | var newValue = slider.Value - slider.TickFrequency; 28 | if (newValue < slider.Minimum) 29 | return; 30 | 31 | slider.Value = newValue; 32 | } 33 | } 34 | 35 | 36 | /// 37 | /// Called after the behavior is attached to an AssociatedObject. 38 | /// 39 | /// 40 | /// Override this to hook up functionality to the AssociatedObject. 41 | /// 42 | protected override void OnAttached() 43 | { 44 | base.OnAttached(); 45 | AssociatedObject.PreviewMouseWheel += AssociatedObject_PreviewMouseWheel; 46 | } 47 | 48 | 49 | /// 50 | /// Called when the behavior is being detached from its AssociatedObject, but before it has actually occurred. 51 | /// 52 | /// 53 | /// Override this to unhook functionality from the AssociatedObject. 54 | /// 55 | protected override void OnDetaching() 56 | { 57 | base.OnDetaching(); 58 | AssociatedObject.PreviewMouseWheel -= AssociatedObject_PreviewMouseWheel; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Amuse.UI/Behaviors/SmoothProgressBarBehavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Media.Animation; 5 | 6 | namespace Amuse.UI.Behaviors 7 | { 8 | public class SmoothProgressBarBehavior 9 | { 10 | public static double GetSmoothValue(DependencyObject obj) 11 | { 12 | return (double)obj.GetValue(SmoothValueProperty); 13 | } 14 | 15 | public static void SetSmoothValue(DependencyObject obj, double value) 16 | { 17 | obj.SetValue(SmoothValueProperty, value); 18 | } 19 | 20 | public static readonly DependencyProperty SmoothValueProperty = 21 | DependencyProperty.RegisterAttached("SmoothValue", typeof(double), typeof(SmoothProgressBarBehavior), new PropertyMetadata(0.0, changing)); 22 | 23 | private static void changing(DependencyObject d, DependencyPropertyChangedEventArgs e) 24 | { 25 | var anim = new DoubleAnimation((double)e.OldValue, (double)e.NewValue, new TimeSpan(0, 0, 0, 0, 200)); 26 | (d as ProgressBar).BeginAnimation(ProgressBar.ValueProperty, anim, HandoffBehavior.Compose); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Amuse.UI/Commands/AsyncRelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using System.Windows.Input; 5 | 6 | namespace Amuse.UI.Commands 7 | { 8 | 9 | /// 10 | /// Async Relay command implemtation 11 | /// 12 | /// 13 | public class AsyncRelayCommand : ICommand 14 | { 15 | private readonly Func execute; 16 | private readonly Func canExecute; 17 | private long isExecuting; 18 | 19 | 20 | /// 21 | /// Initializes a new instance of the class. 22 | /// 23 | /// The execute. 24 | /// The can execute. 25 | public AsyncRelayCommand(Func execute, Func canExecute = null) 26 | { 27 | this.execute = execute; 28 | this.canExecute = canExecute ?? (() => true); 29 | } 30 | 31 | /// 32 | /// Occurs when changes occur that affect whether or not the command should execute. 33 | /// 34 | public event EventHandler CanExecuteChanged 35 | { 36 | add { CommandManager.RequerySuggested += value; } 37 | remove { CommandManager.RequerySuggested -= value; } 38 | } 39 | 40 | /// 41 | /// Raises the can execute changed. 42 | /// 43 | public void RaiseCanExecuteChanged() 44 | { 45 | CommandManager.InvalidateRequerySuggested(); 46 | } 47 | 48 | /// 49 | /// Defines the method that determines whether the command can execute in its current state. 50 | /// 51 | /// Data used by the command. If the command does not require data to be passed, this object can be set to . 52 | /// 53 | /// if this command can be executed; otherwise, . 54 | /// 55 | public bool CanExecute(object parameter) 56 | { 57 | if (Interlocked.Read(ref isExecuting) != 0) 58 | return false; 59 | 60 | return canExecute(); 61 | } 62 | 63 | 64 | /// 65 | /// Defines the method to be called when the command is invoked. 66 | /// 67 | /// Data used by the command. If the command does not require data to be passed, this object can be set to . 68 | public async void Execute(object parameter) 69 | { 70 | Interlocked.Exchange(ref isExecuting, 1); 71 | RaiseCanExecuteChanged(); 72 | 73 | try 74 | { 75 | await execute(); 76 | } 77 | finally 78 | { 79 | Interlocked.Exchange(ref isExecuting, 0); 80 | RaiseCanExecuteChanged(); 81 | } 82 | } 83 | } 84 | 85 | /// 86 | /// Async Relay command with type argument implemtation 87 | /// 88 | /// 89 | public class AsyncRelayCommand : ICommand 90 | { 91 | private readonly Func execute; 92 | private readonly Func canExecute; 93 | private long isExecuting; 94 | 95 | 96 | /// 97 | /// Initializes a new instance of the class. 98 | /// 99 | /// The execute. 100 | /// The can execute. 101 | public AsyncRelayCommand(Func execute, Func canExecute = null) 102 | { 103 | this.execute = execute; 104 | this.canExecute = canExecute ?? (o => true); 105 | } 106 | 107 | /// 108 | /// Occurs when changes occur that affect whether or not the command should execute. 109 | /// 110 | public event EventHandler CanExecuteChanged 111 | { 112 | add { CommandManager.RequerySuggested += value; } 113 | remove { CommandManager.RequerySuggested -= value; } 114 | } 115 | 116 | /// 117 | /// Raises the can execute changed. 118 | /// 119 | public void RaiseCanExecuteChanged() 120 | { 121 | CommandManager.InvalidateRequerySuggested(); 122 | } 123 | 124 | /// 125 | /// Defines the method that determines whether the command can execute in its current state. 126 | /// 127 | /// Data used by the command. If the command does not require data to be passed, this object can be set to . 128 | /// 129 | /// if this command can be executed; otherwise, . 130 | /// 131 | public bool CanExecute(object parameter) 132 | { 133 | if (Interlocked.Read(ref isExecuting) != 0) 134 | return false; 135 | 136 | return canExecute(parameter is T r ? r : default); 137 | } 138 | 139 | /// 140 | /// Defines the method to be called when the command is invoked. 141 | /// 142 | /// Data used by the command. If the command does not require data to be passed, this object can be set to . 143 | public async void Execute(object parameter) 144 | { 145 | Interlocked.Exchange(ref isExecuting, 1); 146 | RaiseCanExecuteChanged(); 147 | 148 | try 149 | { 150 | await execute((T)parameter); 151 | } 152 | finally 153 | { 154 | Interlocked.Exchange(ref isExecuting, 0); 155 | RaiseCanExecuteChanged(); 156 | } 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /Amuse.UI/Commands/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Windows.Input; 4 | 5 | namespace Amuse.UI.Commands 6 | { 7 | /// 8 | /// Relay command implemtation 9 | /// 10 | /// 11 | public class RelayCommand : ICommand 12 | { 13 | readonly Action _execute; 14 | private readonly Func _canExecute; 15 | 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The execute. 20 | public RelayCommand(Action execute) : this(execute, null) { } 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// The execute. 26 | public RelayCommand(Action execute) : this(execute, null) { } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The action to execute. 32 | /// The can execute. 33 | /// execute 34 | public RelayCommand(Action execute, Func canExecute) 35 | { 36 | if (execute == null) 37 | throw new ArgumentNullException(nameof(execute)); 38 | 39 | _execute = p => execute(); 40 | _canExecute = canExecute; 41 | } 42 | 43 | /// 44 | /// Initializes a new instance of the class. 45 | /// 46 | /// The execute. 47 | /// The can execute. 48 | /// execute 49 | public RelayCommand(Action execute, Func canExecute) 50 | { 51 | if (execute == null) 52 | throw new ArgumentNullException(nameof(execute)); 53 | 54 | _execute = execute; 55 | _canExecute = canExecute; 56 | } 57 | 58 | /// 59 | /// Defines the method that determines whether the command can execute in its current state. 60 | /// 61 | /// Data used by the command. If the command does not require data to be passed, this object can be set to null. 62 | /// 63 | /// true if this command can be executed; otherwise, false. 64 | /// 65 | [DebuggerStepThrough] 66 | public bool CanExecute(object parameter) 67 | { 68 | return _canExecute == null || _canExecute(); 69 | } 70 | 71 | /// 72 | /// Occurs when changes occur that affect whether or not the command should execute. 73 | /// 74 | public event EventHandler CanExecuteChanged 75 | { 76 | add { CommandManager.RequerySuggested += value; } 77 | remove { CommandManager.RequerySuggested -= value; } 78 | } 79 | 80 | /// 81 | /// Defines the method to be called when the command is invoked. 82 | /// 83 | /// Data used by the command. If the command does not require data to be passed, this object can be set to null. 84 | public void Execute(object parameter) 85 | { 86 | _execute(parameter); 87 | } 88 | } 89 | 90 | /// 91 | /// Relay command with type argument implemtation 92 | /// 93 | /// 94 | public class RelayCommand : ICommand 95 | { 96 | readonly Action _execute; 97 | readonly Predicate _canExecute; 98 | 99 | /// 100 | /// Initializes a new instance of the class. 101 | /// 102 | /// The execute. 103 | public RelayCommand(Action execute) : this(execute, null) { } 104 | 105 | /// 106 | /// Initializes a new instance of the class. 107 | /// 108 | /// The action to execute. 109 | /// The can execute. 110 | /// execute 111 | public RelayCommand(Action execute, Predicate canExecute) 112 | { 113 | if (execute == null) 114 | throw new ArgumentNullException(nameof(execute)); 115 | 116 | _execute = execute; 117 | _canExecute = canExecute; 118 | } 119 | 120 | /// 121 | /// Defines the method that determines whether the command can execute in its current state. 122 | /// 123 | /// Data used by the command. If the command does not require data to be passed, this object can be set to null. 124 | /// 125 | /// true if this command can be executed; otherwise, false. 126 | /// 127 | [DebuggerStepThrough] 128 | public bool CanExecute(object parameter) 129 | { 130 | if (_canExecute == null) 131 | { 132 | return true; 133 | } 134 | 135 | return parameter != null && _canExecute((T)parameter); 136 | } 137 | 138 | /// 139 | /// Occurs when changes occur that affect whether or not the command should execute. 140 | /// 141 | public event EventHandler CanExecuteChanged 142 | { 143 | add { CommandManager.RequerySuggested += value; } 144 | remove { CommandManager.RequerySuggested -= value; } 145 | } 146 | 147 | /// 148 | /// Defines the method to be called when the command is invoked. 149 | /// 150 | /// Data used by the command. If the command does not require data to be passed, this object can be set to null. 151 | public void Execute(object parameter) 152 | { 153 | _execute((T)parameter); 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/BooleanToHiddenConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Amuse.UI.Converters 7 | { 8 | [ValueConversion(typeof(bool), typeof(Visibility))] 9 | public class BooleanToHiddenConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var boolValue = (bool)value; 14 | return !boolValue ? Visibility.Hidden : Visibility.Visible; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | return null; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/ComboBoxAllItemConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Windows.Data; 7 | 8 | namespace Amuse.UI.Converters 9 | { 10 | public class ComboBoxAllItemConverter : IValueConverter 11 | { 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | IEnumerable container = value as IEnumerable; 15 | if (container != null) 16 | { 17 | IEnumerable genericContainer = container.OfType(); 18 | IEnumerable emptyItem = new object[] { "All" }; 19 | return emptyItem.Concat(genericContainer); 20 | } 21 | 22 | return value; 23 | } 24 | 25 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 26 | { 27 | return value is string str && str == "All" ? null : value; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/DiffuserVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using OnnxStack.StableDiffusion.Enums; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Globalization; 5 | using System.Linq; 6 | using System.Windows; 7 | using System.Windows.Data; 8 | 9 | namespace Amuse.UI.Converters 10 | { 11 | public class DiffuserVisibilityConverter : IMultiValueConverter 12 | { 13 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | if (values.Length == 2 && values[0] is List viewTypes && values[1] is List modelTypes) 16 | { 17 | return viewTypes.Any(modelTypes.Contains) ? Visibility.Visible : Visibility.Collapsed; 18 | } 19 | 20 | return Visibility.Collapsed; 21 | } 22 | 23 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/EnumDescriptionConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Globalization; 4 | using System.Reflection; 5 | using System.Windows.Data; 6 | 7 | namespace Amuse.UI.Converters 8 | { 9 | public class EnumDescriptionConverter : IValueConverter 10 | { 11 | private string GetEnumDescription(Enum enumObj) 12 | { 13 | FieldInfo fieldInfo = enumObj.GetType().GetField(enumObj.ToString()); 14 | object[] attribArray = fieldInfo.GetCustomAttributes(false); 15 | 16 | if (attribArray.Length == 0) 17 | return enumObj.ToString(); 18 | else 19 | { 20 | DescriptionAttribute attrib = null; 21 | 22 | foreach (var att in attribArray) 23 | { 24 | if (att is DescriptionAttribute) 25 | attrib = att as DescriptionAttribute; 26 | } 27 | 28 | if (attrib != null) 29 | return attrib.Description; 30 | 31 | return enumObj.ToString(); 32 | } 33 | } 34 | 35 | object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) 36 | { 37 | if (value is not Enum myEnum) 38 | return value; 39 | 40 | string description = GetEnumDescription(myEnum); 41 | return description; 42 | } 43 | 44 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 45 | { 46 | return string.Empty; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/InverseBoolConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace Amuse.UI.Converters 6 | { 7 | /// 8 | /// Converter for converting a boolean to its inverse value 9 | /// 10 | /// 11 | [ValueConversion(typeof(bool), typeof(bool))] 12 | public class InverseBoolConverter : IValueConverter 13 | { 14 | 15 | /// 16 | /// Converts the specified value. 17 | /// 18 | /// The value. 19 | /// Type of the target. 20 | /// The parameter. 21 | /// The culture. 22 | /// 23 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 24 | { 25 | return !(bool)value; 26 | } 27 | 28 | /// 29 | /// Converts the value back. 30 | /// 31 | /// The value. 32 | /// Type of the target. 33 | /// The parameter. 34 | /// The culture. 35 | /// 36 | /// 37 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 38 | { 39 | throw new NotImplementedException(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/InverseBooleanToHiddenConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Amuse.UI.Converters 7 | { 8 | [ValueConversion(typeof(bool), typeof(Visibility))] 9 | public class InverseBooleanToHiddenConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var boolValue = (bool)value; 14 | return !boolValue ? Visibility.Visible : Visibility.Hidden; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | return null; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/InverseBooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Amuse.UI.Converters 7 | { 8 | [ValueConversion(typeof(bool), typeof(Visibility))] 9 | public class InverseBooleanToVisibilityConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var boolValue = (bool)value; 14 | return !boolValue ? Visibility.Visible : Visibility.Collapsed; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | return null; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/InverseNullVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Amuse.UI.Converters 7 | { 8 | [ValueConversion(typeof(object), typeof(bool))] 9 | public class InverseNullVisibilityConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | return value == null ? Visibility.Visible : Visibility.Collapsed; 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/NullVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace Amuse.UI.Converters 7 | { 8 | [ValueConversion(typeof(object), typeof(bool))] 9 | public class NullVisibilityConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | return value == null ? Visibility.Collapsed : Visibility.Visible; 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | throw new NotImplementedException(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Amuse.UI/Converters/PipelineVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using OnnxStack.StableDiffusion.Enums; 2 | using System; 3 | using System.Globalization; 4 | using System.Windows; 5 | using System.Windows.Data; 6 | 7 | namespace Amuse.UI.Converters 8 | { 9 | public class PipelineVisibilityConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (value is DiffuserPipelineType pipeLineValue) 14 | { 15 | Enum.TryParse(parameter.ToString(), true, out var parameterEnum); 16 | return pipeLineValue == parameterEnum ? Visibility.Visible : Visibility.Collapsed; 17 | } 18 | return Visibility.Visible; 19 | } 20 | 21 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Amuse.UI/Dialogs/AddModelDialog.xaml: -------------------------------------------------------------------------------- 1 |  20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /Amuse.UI/Dialogs/MessageDialog.xaml: -------------------------------------------------------------------------------- 1 |  17 | 18 | 19 | 20 | 21 | 22 | 34 | 35 | 26 | 29 | 30 | 31 | 32 | 33 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/FontAwesome.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/FontAwesome.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Media; 4 | 5 | namespace Amuse.UI.UserControls 6 | { 7 | /// 8 | /// Interaction logic for FontAwesome.xaml 9 | /// 10 | public partial class FontAwesome : UserControl 11 | { 12 | public FontAwesome() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | public static readonly DependencyProperty SizeProperty = 18 | DependencyProperty.Register("Size", typeof(int), typeof(FontAwesome), new PropertyMetadata(16)); 19 | 20 | public static readonly DependencyProperty IconProperty = 21 | DependencyProperty.Register("Icon", typeof(string), typeof(FontAwesome), new PropertyMetadata("\uf004")); 22 | 23 | public static readonly DependencyProperty ColorProperty = 24 | DependencyProperty.Register("Color", typeof(Brush), typeof(FontAwesome), new PropertyMetadata(Brushes.Black)); 25 | 26 | public static readonly DependencyProperty IconStyleProperty = 27 | DependencyProperty.Register("IconStyle", typeof(FontAwesomeIconStyle), typeof(FontAwesome), new PropertyMetadata(FontAwesomeIconStyle.Regular)); 28 | 29 | 30 | /// 31 | /// Gets or sets the icon. 32 | /// 33 | public string Icon 34 | { 35 | get { return (string)GetValue(IconProperty); } 36 | set { SetValue(IconProperty, value); } 37 | } 38 | 39 | 40 | /// 41 | /// Gets or sets the size. 42 | /// 43 | public int Size 44 | { 45 | get { return (int)GetValue(SizeProperty); } 46 | set { SetValue(SizeProperty, value); } 47 | } 48 | 49 | 50 | /// 51 | /// Gets or sets the color. 52 | /// 53 | public Brush Color 54 | { 55 | get { return (Brush)GetValue(ColorProperty); } 56 | set { SetValue(ColorProperty, value); } 57 | } 58 | 59 | 60 | /// 61 | /// Gets or sets the icon style. 62 | /// 63 | public FontAwesomeIconStyle IconStyle 64 | { 65 | get { return (FontAwesomeIconStyle)GetValue(IconStyleProperty); } 66 | set { SetValue(IconStyleProperty, IconStyle); } 67 | } 68 | } 69 | 70 | public enum FontAwesomeIconStyle 71 | { 72 | Regular, 73 | Light, 74 | Solid, 75 | Brands, 76 | Duotone 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/ImageResultControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Amuse.UI.Commands; 2 | using Amuse.UI.Models; 3 | using System.ComponentModel; 4 | using System.Runtime.CompilerServices; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Input; 9 | 10 | namespace Amuse.UI.UserControls 11 | { 12 | public partial class ImageResultControl : UserControl, INotifyPropertyChanged 13 | { 14 | 15 | /// Initializes a new instance of the class. 16 | public ImageResultControl() 17 | { 18 | CopyImageCommand = new AsyncRelayCommand(CopyImage); 19 | UpdateSeedCommand = new AsyncRelayCommand(UpdateSeed); 20 | InitializeComponent(); 21 | } 22 | 23 | public AsyncRelayCommand CopyImageCommand { get; } 24 | public AsyncRelayCommand UpdateSeedCommand { get; } 25 | 26 | public ImageResult Result 27 | { 28 | get { return (ImageResult)GetValue(ResultProperty); } 29 | set { SetValue(ResultProperty, value); } 30 | } 31 | 32 | public static readonly DependencyProperty ResultProperty = 33 | DependencyProperty.Register("Result", typeof(ImageResult), typeof(ImageResultControl)); 34 | 35 | 36 | public SchedulerOptionsModel SchedulerOptions 37 | { 38 | get { return (SchedulerOptionsModel)GetValue(SchedulerOptionsProperty); } 39 | set { SetValue(SchedulerOptionsProperty, value); } 40 | } 41 | 42 | public static readonly DependencyProperty SchedulerOptionsProperty = 43 | DependencyProperty.Register("SchedulerOptions", typeof(SchedulerOptionsModel), typeof(ImageResultControl)); 44 | 45 | 46 | public int ProgressMax 47 | { 48 | get { return (int)GetValue(ProgressMaxProperty); } 49 | set { SetValue(ProgressMaxProperty, value); } 50 | } 51 | 52 | public static readonly DependencyProperty ProgressMaxProperty = 53 | DependencyProperty.Register("ProgressMax", typeof(int), typeof(ImageResultControl)); 54 | 55 | 56 | public int ProgressValue 57 | { 58 | get { return (int)GetValue(ProgressValueProperty); } 59 | set { SetValue(ProgressValueProperty, value); } 60 | } 61 | 62 | public static readonly DependencyProperty ProgressValueProperty = 63 | DependencyProperty.Register("ProgressValue", typeof(int), typeof(ImageResultControl)); 64 | 65 | 66 | public bool HasResult 67 | { 68 | get { return (bool)GetValue(HasResultProperty); } 69 | set { SetValue(HasResultProperty, value); } 70 | } 71 | 72 | public static readonly DependencyProperty HasResultProperty = 73 | DependencyProperty.Register("HasResult", typeof(bool), typeof(ImageResultControl)); 74 | 75 | 76 | 77 | private Task UpdateSeed(int previousSeed) 78 | { 79 | SchedulerOptions.Seed = previousSeed; 80 | return Task.CompletedTask; 81 | } 82 | 83 | private Task CopyImage() 84 | { 85 | if (Result?.Image != null) 86 | Clipboard.SetImage(Result.Image); 87 | 88 | return Task.CompletedTask; 89 | } 90 | 91 | private async void OnPreviewKeyDown(object sender, KeyEventArgs e) 92 | { 93 | if (e.Key == Key.C && Keyboard.Modifiers == ModifierKeys.Control) 94 | { 95 | await CopyImage(); 96 | e.Handled = true; 97 | } 98 | } 99 | 100 | private void OnMouseEnter(object sender, MouseEventArgs e) 101 | { 102 | Focus(); 103 | } 104 | 105 | 106 | #region INotifyPropertyChanged 107 | public event PropertyChangedEventHandler PropertyChanged; 108 | public void NotifyPropertyChanged([CallerMemberName] string property = "") 109 | { 110 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); 111 | } 112 | #endregion 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/ModelPickerControl.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 45 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/PromptControl.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/PromptControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Amuse.UI.Commands; 2 | using Amuse.UI.Models; 3 | using System.ComponentModel; 4 | using System.Runtime.CompilerServices; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Input; 8 | 9 | namespace Amuse.UI.UserControls 10 | { 11 | /// 12 | /// Interaction logic for Parameters.xaml 13 | /// 14 | public partial class PromptControl : UserControl, INotifyPropertyChanged 15 | { 16 | /// Initializes a new instance of the class. 17 | public PromptControl() 18 | { 19 | ResetParametersCommand = new RelayCommand(ResetParameters); 20 | InitializeComponent(); 21 | } 22 | 23 | /// Gets the reset parameters command. 24 | /// The reset parameters command. 25 | public ICommand ResetParametersCommand { get; } 26 | 27 | 28 | /// 29 | /// Gets or sets the PromptOptions. 30 | /// 31 | public PromptOptionsModel PromptOptions 32 | { 33 | get { return (PromptOptionsModel)GetValue(PromptOptionsProperty); } 34 | set { SetValue(PromptOptionsProperty, value); } 35 | } 36 | 37 | 38 | /// 39 | /// The PromptOptions property 40 | /// 41 | public static readonly DependencyProperty PromptOptionsProperty = 42 | DependencyProperty.Register("PromptOptions", typeof(PromptOptionsModel), typeof(PromptControl)); 43 | 44 | 45 | public StableDiffusionModelSetViewModel SelectedModel 46 | { 47 | get { return (StableDiffusionModelSetViewModel)GetValue(SelectedModelProperty); } 48 | set { SetValue(SelectedModelProperty, value); } 49 | } 50 | 51 | public static readonly DependencyProperty SelectedModelProperty = 52 | DependencyProperty.Register("SelectedModel", typeof(StableDiffusionModelSetViewModel), typeof(PromptControl)); 53 | 54 | 55 | /// 56 | /// Resets the parameters. 57 | /// 58 | private void ResetParameters() 59 | { 60 | PromptOptions = new PromptOptionsModel(); 61 | } 62 | 63 | #region INotifyPropertyChanged 64 | public event PropertyChangedEventHandler PropertyChanged; 65 | public void NotifyPropertyChanged([CallerMemberName] string property = "") 66 | { 67 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); 68 | } 69 | #endregion 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/UpscalePickerControl.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 45 | 51 | 52 | 53 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Amuse.UI/UserControls/UpscalePickerControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using Amuse.UI.Commands; 2 | using Amuse.UI.Models; 3 | using Microsoft.Extensions.Logging; 4 | using OnnxStack.Core; 5 | using OnnxStack.ImageUpscaler.Services; 6 | using System; 7 | using System.ComponentModel; 8 | using System.Linq; 9 | using System.Runtime.CompilerServices; 10 | using System.Threading.Tasks; 11 | using System.Windows; 12 | using System.Windows.Controls; 13 | 14 | namespace Amuse.UI.UserControls 15 | { 16 | /// 17 | /// Interaction logic for UpscalePickerControl.xaml 18 | /// 19 | public partial class UpscalePickerControl : UserControl, INotifyPropertyChanged 20 | { 21 | private readonly ILogger _logger; 22 | private readonly IUpscaleService _upscaleService; 23 | 24 | /// Initializes a new instance of the class. 25 | public UpscalePickerControl() 26 | { 27 | if (!DesignerProperties.GetIsInDesignMode(this)) 28 | { 29 | _logger = App.GetService>(); 30 | _upscaleService = App.GetService(); 31 | } 32 | 33 | LoadCommand = new AsyncRelayCommand(LoadModel); 34 | UnloadCommand = new AsyncRelayCommand(UnloadModel); 35 | InitializeComponent(); 36 | } 37 | 38 | public AsyncRelayCommand LoadCommand { get; set; } 39 | public AsyncRelayCommand UnloadCommand { get; set; } 40 | 41 | public AmuseSettings UISettings 42 | { 43 | get { return (AmuseSettings)GetValue(UISettingsProperty); } 44 | set { SetValue(UISettingsProperty, value); } 45 | } 46 | public static readonly DependencyProperty UISettingsProperty = 47 | DependencyProperty.Register("UISettings", typeof(AmuseSettings), typeof(UpscalePickerControl)); 48 | 49 | 50 | /// 51 | /// Gets or sets the selected model. 52 | /// 53 | public UpscaleModelSetViewModel SelectedModel 54 | { 55 | get { return (UpscaleModelSetViewModel)GetValue(SelectedModelProperty); } 56 | set { SetValue(SelectedModelProperty, value); } 57 | } 58 | public static readonly DependencyProperty SelectedModelProperty = 59 | DependencyProperty.Register("SelectedModel", typeof(UpscaleModelSetViewModel), typeof(UpscalePickerControl)); 60 | 61 | 62 | 63 | /// 64 | /// Loads the model. 65 | /// 66 | private async Task LoadModel() 67 | { 68 | if (_upscaleService.IsModelLoaded(SelectedModel.ModelSet)) 69 | return; 70 | 71 | var elapsed = _logger.LogBegin($"'{SelectedModel.Name}' Loading..."); 72 | SelectedModel.IsLoaded = false; 73 | SelectedModel.IsLoading = true; 74 | 75 | try 76 | { 77 | if (UISettings.ModelCacheMode == ModelCacheMode.Single) 78 | { 79 | foreach (var model in UISettings.UpscaleModelSets.Where(x => x.IsLoaded)) 80 | { 81 | _logger.LogInformation($"'{model.Name}' Unloading..."); 82 | await _upscaleService.UnloadModelAsync(model.ModelSet); 83 | model.IsLoaded = false; 84 | } 85 | } 86 | 87 | SelectedModel.IsLoaded = await _upscaleService.LoadModelAsync(SelectedModel.ModelSet); 88 | } 89 | catch (Exception ex) 90 | { 91 | _logger.LogError($"An error occured while loading model '{SelectedModel.Name}' \n {ex}"); 92 | } 93 | 94 | SelectedModel.IsLoading = false; 95 | _logger.LogEnd($"'{SelectedModel.Name}' Loaded.", elapsed); 96 | } 97 | 98 | 99 | /// 100 | /// Unloads the model. 101 | /// 102 | private async Task UnloadModel() 103 | { 104 | if (!_upscaleService.IsModelLoaded(SelectedModel.ModelSet)) 105 | return; 106 | 107 | _logger.LogInformation($"'{SelectedModel.Name}' Unloading..."); 108 | SelectedModel.IsLoading = true; 109 | await _upscaleService.UnloadModelAsync(SelectedModel.ModelSet); 110 | SelectedModel.IsLoading = false; 111 | SelectedModel.IsLoaded = false; 112 | _logger.LogInformation($"'{SelectedModel.Name}' Unloaded."); 113 | } 114 | 115 | #region INotifyPropertyChanged 116 | public event PropertyChangedEventHandler PropertyChanged; 117 | public void NotifyPropertyChanged([CallerMemberName] string property = "") 118 | { 119 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); 120 | } 121 | #endregion 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Amuse.UI/Views/INavigatable.cs: -------------------------------------------------------------------------------- 1 | using Amuse.UI.Models; 2 | using System.Threading.Tasks; 3 | 4 | namespace Amuse.UI.Views 5 | { 6 | public interface INavigatable 7 | { 8 | Task NavigateAsync(ImageResult imageResult); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Amuse.UI/Views/LoggerView.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Amuse.UI/Views/LoggerView.xaml.cs: -------------------------------------------------------------------------------- 1 | using Amuse.UI.Commands; 2 | using Amuse.UI.Models; 3 | using System; 4 | using System.ComponentModel; 5 | using System.Runtime.CompilerServices; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace Amuse.UI.Views 11 | { 12 | /// 13 | /// Interaction logic for Logger.xaml 14 | /// 15 | public partial class LoggerView : UserControl, INavigatable, INotifyPropertyChanged 16 | { 17 | 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | public LoggerView() 22 | { 23 | ResetCommand = new AsyncRelayCommand(Reset, CanExecuteReset); 24 | InitializeComponent(); 25 | } 26 | 27 | public AmuseSettings UISettings 28 | { 29 | get { return (AmuseSettings)GetValue(UISettingsProperty); } 30 | set { SetValue(UISettingsProperty, value); } 31 | } 32 | public static readonly DependencyProperty UISettingsProperty = 33 | DependencyProperty.Register("UISettings", typeof(AmuseSettings), typeof(LoggerView)); 34 | 35 | public AsyncRelayCommand ResetCommand { get; } 36 | 37 | 38 | /// 39 | /// Gets or sets the log output. 40 | /// 41 | public string LogOutput 42 | { 43 | get { return (string)GetValue(LogOutputProperty); } 44 | set { SetValue(LogOutputProperty, value); } 45 | } 46 | public static readonly DependencyProperty LogOutputProperty = 47 | DependencyProperty.Register("LogOutput", typeof(string), typeof(LoggerView)); 48 | 49 | 50 | public Task NavigateAsync(ImageResult imageResult) 51 | { 52 | throw new NotImplementedException(); 53 | } 54 | 55 | 56 | /// 57 | /// Resets the log window. 58 | /// 59 | /// 60 | private Task Reset() 61 | { 62 | LogOutput = null; 63 | return Task.CompletedTask; 64 | } 65 | 66 | 67 | /// 68 | /// Determines whether this instance can execute reset. 69 | /// 70 | /// 71 | /// true if this instance can execute reset; otherwise, false. 72 | /// 73 | private bool CanExecuteReset() 74 | { 75 | return !string.IsNullOrEmpty(LogOutput); 76 | } 77 | 78 | #region INotifyPropertyChanged 79 | public event PropertyChangedEventHandler PropertyChanged; 80 | 81 | public void NotifyPropertyChanged([CallerMemberName] string property = "") 82 | { 83 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); 84 | } 85 | #endregion 86 | } 87 | 88 | 89 | } 90 | -------------------------------------------------------------------------------- /Amuse.UI/Views/SettingsView.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /Amuse.UI/WindowLogger.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Microsoft.Extensions.DependencyInjection.Extensions; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Linq; 6 | 7 | namespace Amuse.UI 8 | { 9 | 10 | /// 11 | /// Simple logger to capture output to the main windows OutputLog 12 | /// 13 | /// 14 | public sealed class WindowLogger : ILogger 15 | { 16 | private readonly string _category; 17 | 18 | public WindowLogger(string category) 19 | { 20 | _category = category.Split('.').LastOrDefault(); 21 | } 22 | 23 | /// 24 | /// Begins a logical operation scope. 25 | /// 26 | /// The type of the state to begin scope for. 27 | /// The identifier for the scope. 28 | /// 29 | /// A disposable object that ends the logical operation scope on dispose. 30 | /// 31 | public IDisposable BeginScope(TState state) where TState : notnull => default!; 32 | 33 | 34 | /// 35 | /// Checks if the given is enabled. 36 | /// 37 | /// level to be checked. 38 | /// 39 | /// if enabled; otherwise. 40 | /// 41 | public bool IsEnabled(LogLevel logLevel) => true; 42 | 43 | 44 | /// 45 | /// Writes a log entry. 46 | /// 47 | /// The type of the object to be written. 48 | /// Entry will be written on this level. 49 | /// Id of the event. 50 | /// The entry to be written. Can be also an object. 51 | /// The exception related to this entry. 52 | /// Function to create a message of the and . 53 | public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) 54 | { 55 | if (!IsEnabled(logLevel)) 56 | return; 57 | 58 | Utils.LogToWindow($"[{DateTime.Now}] [{logLevel}] [{_category}] {formatter(state, exception)}\n"); 59 | } 60 | 61 | 62 | 63 | } 64 | 65 | 66 | public static class WindowLoggerLoggerExtensions 67 | { 68 | /// 69 | /// Adds the window logger. 70 | /// 71 | /// The builder. 72 | /// 73 | public static ILoggingBuilder AddWindowLogger(this ILoggingBuilder builder) 74 | { 75 | builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); 76 | return builder; 77 | } 78 | } 79 | 80 | public sealed class WindowLoggerProvider : ILoggerProvider 81 | { 82 | 83 | /// 84 | /// Creates a new instance. 85 | /// 86 | /// The category name for messages produced by the logger. 87 | /// 88 | /// The instance of that was created. 89 | /// 90 | public ILogger CreateLogger(string categoryName) => new WindowLogger(categoryName); 91 | 92 | public void Dispose() 93 | { 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Amuse.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34202.233 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amuse.UI", "Amuse.UI\Amuse.UI.csproj", "{135BE435-46D9-4CF8-9B6F-E1F420CB005A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug-Cuda|Any CPU = Debug-Cuda|Any CPU 12 | Debug-DML|Any CPU = Debug-DML|Any CPU 13 | Debug-TensorRT|Any CPU = Debug-TensorRT|Any CPU 14 | Release|Any CPU = Release|Any CPU 15 | Release-Cuda|Any CPU = Release-Cuda|Any CPU 16 | Release-DML|Any CPU = Release-DML|Any CPU 17 | Release-TensorRT|Any CPU = Release-TensorRT|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug-Cuda|Any CPU.ActiveCfg = Debug-Cuda|Any CPU 23 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug-Cuda|Any CPU.Build.0 = Debug-Cuda|Any CPU 24 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug-DML|Any CPU.ActiveCfg = Debug-DML|Any CPU 25 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug-DML|Any CPU.Build.0 = Debug-DML|Any CPU 26 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug-TensorRT|Any CPU.ActiveCfg = Debug-TensorRT|Any CPU 27 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Debug-TensorRT|Any CPU.Build.0 = Debug-TensorRT|Any CPU 28 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release-Cuda|Any CPU.ActiveCfg = Release-Cuda|Any CPU 31 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release-Cuda|Any CPU.Build.0 = Release-Cuda|Any CPU 32 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release-DML|Any CPU.ActiveCfg = Release-DML|Any CPU 33 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release-DML|Any CPU.Build.0 = Release-DML|Any CPU 34 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release-TensorRT|Any CPU.ActiveCfg = Release-TensorRT|Any CPU 35 | {135BE435-46D9-4CF8-9B6F-E1F420CB005A}.Release-TensorRT|Any CPU.Build.0 = Release-TensorRT|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(ExtensibilityGlobals) = postSolution 41 | SolutionGuid = {F3857B76-CF15-4C44-8C23-4256CD82F51D} 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /Assets/Amuse-Logo-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo-1024.png -------------------------------------------------------------------------------- /Assets/Amuse-Logo-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo-128.png -------------------------------------------------------------------------------- /Assets/Amuse-Logo-2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo-2048.png -------------------------------------------------------------------------------- /Assets/Amuse-Logo-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo-256.png -------------------------------------------------------------------------------- /Assets/Amuse-Logo-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo-512.png -------------------------------------------------------------------------------- /Assets/Amuse-Logo-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo-64.png -------------------------------------------------------------------------------- /Assets/Amuse-Logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Amuse-Logo.psd -------------------------------------------------------------------------------- /Assets/Icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Icon-1024.png -------------------------------------------------------------------------------- /Assets/Icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Icon-128.png -------------------------------------------------------------------------------- /Assets/Icon-2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Icon-2048.png -------------------------------------------------------------------------------- /Assets/Icon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Icon-256.png -------------------------------------------------------------------------------- /Assets/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Icon-512.png -------------------------------------------------------------------------------- /Assets/Icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianleiwu/Amuse/9886184fb625c1bd7c3ae70c94e3c3d2d5c6a861/Assets/Icon-64.png -------------------------------------------------------------------------------- /Docs/ModelTemplate.md: -------------------------------------------------------------------------------- 1 | # ModelTemplate 2 | 3 | ## StableDiffuion Model 4 | 5 | 6 | ## Schema 7 | ```json 8 | { 9 | "Name": string, 10 | "ImageIcon": string(url), 11 | "Author": string, 12 | "Website": string(url), 13 | "Description": string, 14 | "Tags": [ string ], 15 | "IsUserTemplate": bool, 16 | "Template": string, 17 | "Category": enum, 18 | "StableDiffusionTemplate": { 19 | "PipelineType": enum, 20 | "ModelType": enum, 21 | "SampleSize": integer, 22 | "DiffuserTypes": [ enum ], 23 | "SchedulerDefaults": { 24 | "Steps": int, 25 | "StepsMin": int, 26 | "StepsMax": int, 27 | "Guidance": float, 28 | "GuidanceMin": float, 29 | "GuidanceMax": float, 30 | "SchedulerType": enum 31 | } 32 | }, 33 | "Repository": string(url), 34 | "RepositoryBranch": string(url), 35 | "RepositoryFiles": [ string(url) ], 36 | "PreviewImages": [ string(url) ] 37 | } 38 | ``` 39 | **Enum Reference:** 40 | [[DiffuserType]](https://github.com/saddam213/OnnxStack/blob/master/OnnxStack.StableDiffusion/Enums/DiffuserType.cs) 41 | [[ModelType]](https://github.com/saddam213/OnnxStack/blob/master/OnnxStack.StableDiffusion/Enums/ModelType.cs) 42 | [[PipelineType]](https://github.com/saddam213/OnnxStack/blob/master/OnnxStack.StableDiffusion/Enums/DiffuserPipelineType.cs) 43 | [[SchedulerType]](https://github.com/saddam213/OnnxStack/blob/master/OnnxStack.StableDiffusion/Enums/SchedulerType.cs) 44 | 45 | ## Example 46 | 47 | ```json 48 | { 49 | "Name": "LCM Dreamshaper v7", 50 | "ImageIcon": "https://raw.githubusercontent.com/luosiallen/latent-consistency-model/main/lcm_logo.png", 51 | "Author": "SimianLuo", 52 | "Website": "https://latent-consistency-models.github.io/", 53 | "Description": "Latent Consistency Model (LCM) was proposed in Latent Consistency Models: Synthesizing High-Resolution Images....", 54 | "Tags": [ "CPU", "GPU", "F32" ], 55 | "IsUserTemplate": true, 56 | "Template": "LCM", 57 | "Category": "StableDiffusion", 58 | "StableDiffusionTemplate": { 59 | "PipelineType": "LatentConsistency", 60 | "ModelType": "Base", 61 | "SampleSize": 512, 62 | "DiffuserTypes": [ 63 | "TextToImage", 64 | "ImageToImage", 65 | "ImageInpaintLegacy" 66 | ], 67 | "SchedulerDefaults": { 68 | "Steps": 4, 69 | "StepsMin": 1, 70 | "StepsMax": 50, 71 | "Guidance": 1, 72 | "GuidanceMin": 0, 73 | "GuidanceMax": 2, 74 | "SchedulerType": "LCM" 75 | } 76 | }, 77 | "Repository": "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7", 78 | "RepositoryFiles": [ 79 | "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7/resolve/onnx/unet/model.onnx", 80 | "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7/resolve/onnx/unet/model.onnx_data", 81 | "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7/resolve/onnx/text_encoder/model.onnx", 82 | "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7/resolve/onnx/vae_decoder/model.onnx", 83 | "https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7/resolve/onnx/vae_encoder/model.onnx" 84 | ], 85 | "PreviewImages": [ 86 | ] 87 | } 88 | ``` 89 | 90 | 91 | 92 | ## Upscale Model 93 | 94 | 95 | ## Schema 96 | ```json 97 | { 98 | "Name": string, 99 | "ImageIcon": string(url), 100 | "Author": string, 101 | "Website": string(url), 102 | "Description": string, 103 | "Tags": [ string ], 104 | "IsUserTemplate": bool, 105 | "Template": string, 106 | "Category": enum, 107 | "UpscaleTemplate":{ 108 | "SampleSize": int, 109 | "ScaleFactor": int, 110 | }, 111 | "Repository": string(url), 112 | "RepositoryBranch": string(url), 113 | "RepositoryFiles": [ string(url) ], 114 | "PreviewImages": [ string(url) ] 115 | } 116 | ``` 117 | 118 | 119 | ## Example 120 | 121 | ```json 122 | { 123 | "Name": "Swin2SR x4", 124 | "ImageIcon": "", 125 | "Author": "Xenova", 126 | "Description": "Swin2SR is like a magic wand for pictures and videos. It makes compressed images...", 127 | "Website": "https://arxiv.org/abs/2209.11345", 128 | "Tags": [ "CPU", "GPU", "F32" ], 129 | "IsUserTemplate": true, 130 | "Category": "Upscaler", 131 | "Template": "Upscaler", 132 | "UpscaleTemplate": { 133 | "Channels": 3, 134 | "ScaleFactor": 4, 135 | "SampleSize": 512 136 | }, 137 | "Repository": "https://huggingface.co/Xenova/swin2SR-classical-sr-x4-64", 138 | "RepositoryFiles": [ 139 | "https://huggingface.co/Xenova/swin2SR-classical-sr-x4-64/resolve/main/onnx/model.onnx" 140 | ] 141 | } 142 | ``` --------------------------------------------------------------------------------