|
1 | 1 | using Diffuse.Common; |
| 2 | +using DiffuseApp.Common; |
2 | 3 | using System; |
3 | 4 | using System.Collections.ObjectModel; |
4 | 5 | using System.Linq; |
@@ -566,24 +567,56 @@ public bool HasLoraChanged() |
566 | 567 | return _currentLora.HasChanged(LoraAdapters); |
567 | 568 | } |
568 | 569 |
|
569 | | - } |
570 | | - |
571 | | - public class MemoryProfileModel : BaseModel |
572 | | - { |
573 | | - private int _memoryGB; |
574 | | - private MemoryMode _memoryMode; |
575 | 570 |
|
576 | | - public MemoryMode MemoryMode |
| 571 | + public void SetPipeline(PipelineModel pipeline) |
577 | 572 | { |
578 | | - get { return _memoryMode; } |
579 | | - set { SetProperty(ref _memoryMode, value); } |
580 | | - } |
581 | | - public int MemoryGB |
582 | | - { |
583 | | - get { return _memoryGB; } |
584 | | - set { SetProperty(ref _memoryGB, value); } |
| 573 | + if (pipeline == null) |
| 574 | + return; |
| 575 | + |
| 576 | + if (!ModelCollectionView.Contains(pipeline.DiffusionModel)) |
| 577 | + return; |
| 578 | + |
| 579 | + SelectedDevice = pipeline.Device; |
| 580 | + SelectedModel = pipeline.DiffusionModel; |
| 581 | + |
| 582 | + SelectedDataType = pipeline.DataType; |
| 583 | + SelectedMemoryMode = SelectedMemoryMode = MemoryModes.FirstOrDefault(x => x.MemoryMode == pipeline.MemoryMode); |
| 584 | + |
| 585 | + if (IsUpscalerSupported) |
| 586 | + { |
| 587 | + IsUpscalerEnabled = pipeline.UpscaleModel is not null; |
| 588 | + if (pipeline.UpscaleModel is not null) |
| 589 | + SelectedUpscaler = pipeline.UpscaleModel; |
| 590 | + } |
| 591 | + |
| 592 | + if (IsExtractorSupported) |
| 593 | + { |
| 594 | + IsExtractorEnabled = pipeline.ExtractModel is not null; |
| 595 | + if (pipeline.ExtractModel is not null) |
| 596 | + SelectedExtractor = pipeline.ExtractModel; |
| 597 | + } |
| 598 | + |
| 599 | + if (IsControlNetSupported) |
| 600 | + { |
| 601 | + if (pipeline.ControlNetModel is not null) |
| 602 | + SelectedControlNet = pipeline.ControlNetModel; |
| 603 | + } |
| 604 | + |
| 605 | + if (IsLoraSupported) |
| 606 | + { |
| 607 | + IsLoraEnabled = !pipeline.LoraAdapterModel.IsNullOrEmpty(); |
| 608 | + if (IsLoraEnabled) |
| 609 | + { |
| 610 | + LoraAdapters.Clear(); |
| 611 | + foreach (var loraAdapter in pipeline.LoraAdapterModel) |
| 612 | + { |
| 613 | + LoraAdapters.Add(loraAdapter); |
| 614 | + } |
| 615 | + } |
| 616 | + } |
| 617 | + |
| 618 | + ValidateSelection(); |
585 | 619 | } |
586 | 620 | } |
587 | 621 |
|
588 | | - |
589 | 622 | } |
0 commit comments