Skip to content

Commit 8184aad

Browse files
authored
Merge pull request LykosAI#749 from ionite34/add-flux-types
Added support for downloading/browsing Flux models in the model browser...
2 parents f60ff05 + 16f6df1 commit 8184aad

File tree

10 files changed

+96
-12
lines changed

10 files changed

+96
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
88
## v2.12.0-dev.3
99
### Added
1010
- Added Settings option "Console: History Size" to adjust the number of lines stored in the console history when running packages. Defaults to 9001 lines.
11+
#### Model Browser
12+
- Added AuraFlow & Flux base model types to the CivitAI model browser
1113
#### Checkpoint Manager
1214
- Added "New Directory" and "Delete" options to the context menu of the tree view.
1315
- Added new toggle for drag & drop - when enabled, all selected models will now move together with the dragged model
1416
- Added "File Size" sorting option
1517
- Added "Hide Empty Categories" toggle
1618
- Added "Select All" button to the InfoBar (shown when at least one model is selected)
19+
- Added "unet" shared model folder for ComfyUI
1720
### Changed
1821
- The "Download Failed" message for model downloads is now persistent until dismissed
1922
### Fixed

StabilityMatrix.Avalonia/Assets/hf-packages.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,5 +922,32 @@
922922
],
923923
"Subfolder": "segm",
924924
"LicenseType": "Apache 2.0"
925+
},
926+
{
927+
"ModelCategory": "Clip",
928+
"ModelName": "CLIP L",
929+
"RepositoryPath": "comfyanonymous/flux_text_encoders",
930+
"Files": [
931+
"clip_l.safetensors"
932+
],
933+
"LicenseType": "MIT"
934+
},
935+
{
936+
"ModelCategory": "Clip",
937+
"ModelName": "T5XXL FP16",
938+
"RepositoryPath": "comfyanonymous/flux_text_encoders",
939+
"Files": [
940+
"t5xxl_fp16.safetensors"
941+
],
942+
"LicenseType": "Apache 2.0"
943+
},
944+
{
945+
"ModelCategory": "Clip",
946+
"ModelName": "T5XXL FP8 E4M3FN",
947+
"RepositoryPath": "comfyanonymous/flux_text_encoders",
948+
"Files": [
949+
"t5xxl_fp8_e4m3fn.safetensors"
950+
],
951+
"LicenseType": "Apache 2.0"
925952
}
926953
]

StabilityMatrix.Avalonia/Models/HuggingFace/HuggingFaceModelType.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public enum HuggingFaceModelType
1212
[ConvertTo<SharedFolderType>(SharedFolderType.StableDiffusion)]
1313
BaseModel,
1414

15+
[Description("CLIP / Text Encoders")]
16+
[ConvertTo<SharedFolderType>(SharedFolderType.CLIP)]
17+
Clip,
18+
1519
[Description("ControlNets (SD1.5)")]
1620
[ConvertTo<SharedFolderType>(SharedFolderType.ControlNet)]
1721
ControlNet,

StabilityMatrix.Avalonia/ViewModels/CheckpointBrowser/CheckpointBrowserCardViewModel.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,19 @@ private async Task ShowVersionDialog(CivitModel model)
253253
}
254254
else
255255
{
256-
var subFolder =
257-
viewModel?.SelectedInstallLocation
258-
?? Path.Combine(@"Models", model.Type.ConvertTo<SharedFolderType>().GetStringValue());
256+
var sharedFolder = model.Type.ConvertTo<SharedFolderType>().GetStringValue();
257+
258+
if (
259+
model.BaseModelType == CivitBaseModelType.Flux1D.GetStringValue()
260+
|| model.BaseModelType == CivitBaseModelType.Flux1S.GetStringValue()
261+
)
262+
{
263+
sharedFolder = SharedFolderType.Unet.GetStringValue();
264+
}
265+
266+
var defaultPath = Path.Combine(@"Models", sharedFolder);
267+
268+
var subFolder = viewModel?.SelectedInstallLocation ?? defaultPath;
259269
downloadPath = Path.Combine(settingsManager.LibraryDir, subFolder);
260270
}
261271

StabilityMatrix.Avalonia/ViewModels/CheckpointsPageViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ or nameof(SortConnectedModelsFirst)
380380

381381
// make sure a sort happens
382382
OnPropertyChanged(nameof(SortConnectedModelsFirst));
383+
// gotta do this one too i guess
384+
OnPropertyChanged(nameof(HideEmptyRootCategories));
383385
}
384386

385387
public void ClearSearchQuery()

StabilityMatrix.Avalonia/ViewModels/Dialogs/SelectModelVersionViewModel.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ private void LoadInstallLocations()
306306
var installLocations = new ObservableCollection<string>();
307307

308308
var rootModelsDirectory = new DirectoryPath(settingsManager.ModelsDirectory);
309-
var downloadDirectory = rootModelsDirectory.JoinDir(
310-
SelectedFile?.CivitFile.Type == CivitFileType.VAE
311-
? SharedFolderType.VAE.GetStringValue()
312-
: CivitModel.Type.ConvertTo<SharedFolderType>().GetStringValue()
309+
310+
var downloadDirectory = GetSharedFolderPath(
311+
rootModelsDirectory,
312+
SelectedFile?.CivitFile.Type,
313+
CivitModel.Type,
314+
CivitModel.BaseModelType
313315
);
314316

315317
if (!downloadDirectory.ToString().EndsWith("Unknown"))
@@ -330,4 +332,27 @@ var directory in downloadDirectory.EnumerateDirectories(
330332
AvailableInstallLocations = installLocations;
331333
SelectedInstallLocation = installLocations.FirstOrDefault();
332334
}
335+
336+
private static DirectoryPath GetSharedFolderPath(
337+
DirectoryPath rootModelsDirectory,
338+
CivitFileType? fileType,
339+
CivitModelType modelType,
340+
string? baseModelType
341+
)
342+
{
343+
if (fileType is CivitFileType.VAE)
344+
{
345+
return rootModelsDirectory.JoinDir(SharedFolderType.VAE.GetStringValue());
346+
}
347+
348+
if (
349+
baseModelType == CivitBaseModelType.Flux1D.GetStringValue()
350+
|| baseModelType == CivitBaseModelType.Flux1S.GetStringValue()
351+
)
352+
{
353+
return rootModelsDirectory.JoinDir(SharedFolderType.Unet.GetStringValue());
354+
}
355+
356+
return rootModelsDirectory.JoinDir(modelType.ConvertTo<SharedFolderType>().GetStringValue());
357+
}
333358
}

StabilityMatrix.Core/Models/Api/CivitBaseModelType.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ public enum CivitBaseModelType
88
{
99
All,
1010

11+
[StringValue("AuraFlow")]
12+
AuraFlow,
13+
14+
[StringValue("Flux.1 S")]
15+
Flux1S,
16+
17+
[StringValue("Flux.1 D")]
18+
Flux1D,
19+
1120
[StringValue("PixArt a")]
1221
PixArtA,
1322

StabilityMatrix.Core/Models/Database/LocalModelFile.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ public IEnumerable<string> GetDeleteFullPaths(string rootModelDirectory)
201201
".pt",
202202
".ckpt",
203203
".pth",
204-
".bin"
204+
".bin",
205+
".sft"
205206
];
206207
public static readonly HashSet<string> SupportedImageExtensions = [".png", ".jpg", ".jpeg", ".webp"];
207208
public static readonly HashSet<string> SupportedMetadataExtensions = [".json"];

StabilityMatrix.Core/Models/Packages/ComfyUI.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ IPrerequisiteHelper prerequisiteHelper
6969
[SharedFolderType.T2IAdapter] = ["models/controlnet/T2IAdapter"],
7070
[SharedFolderType.PromptExpansion] = ["models/prompt_expansion"],
7171
[SharedFolderType.Ultralytics] = ["models/ultralytics"],
72-
[SharedFolderType.Sams] = ["models/sams"]
72+
[SharedFolderType.Sams] = ["models/sams"],
73+
[SharedFolderType.Unet] = ["models/unet"]
7374
};
7475

7576
public override Dictionary<SharedOutputType, IReadOnlyList<string>>? SharedOutputFolders =>
@@ -372,6 +373,7 @@ private async Task SetupModelFoldersConfig(DirectoryPath installDirectory)
372373
nodeValue.Children["ultralytics_bbox"] = Path.Combine(modelsDir, "Ultralytics", "bbox");
373374
nodeValue.Children["ultralytics_segm"] = Path.Combine(modelsDir, "Ultralytics", "segm");
374375
nodeValue.Children["sams"] = Path.Combine(modelsDir, "Sams");
376+
nodeValue.Children["unet"] = Path.Combine(modelsDir, "unet");
375377
}
376378
else
377379
{
@@ -414,7 +416,8 @@ private async Task SetupModelFoldersConfig(DirectoryPath installDirectory)
414416
{ "ultralytics", Path.Combine(modelsDir, "Ultralytics") },
415417
{ "ultralytics_bbox", Path.Combine(modelsDir, "Ultralytics", "bbox") },
416418
{ "ultralytics_segm", Path.Combine(modelsDir, "Ultralytics", "segm") },
417-
{ "sams", Path.Combine(modelsDir, "Sams") }
419+
{ "sams", Path.Combine(modelsDir, "Sams") },
420+
{ "unet", Path.Combine(modelsDir, "unet") }
418421
}
419422
);
420423
}

StabilityMatrix.Core/Models/SharedFolderType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public enum SharedFolderType : ulong
4343
SVD = 1 << 27,
4444
Ultralytics = 1 << 28,
4545
Sams = 1 << 29,
46-
47-
PromptExpansion = 1 << 30
46+
PromptExpansion = 1 << 30,
47+
Unet = 1ul << 31,
4848
}

0 commit comments

Comments
 (0)