Skip to content

Commit 3beeb09

Browse files
authored
Merge pull request LykosAI#1100 from ionite34/backport/main/pr-1099
[dev to main] backport: Fix comfy-zluda not showing up for workflow browser node installs & … (1099)
2 parents 7e5389f + 3edca78 commit 3beeb09

File tree

6 files changed

+84
-22
lines changed

6 files changed

+84
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
99
### Added
1010
- Added the ability to search by pasting an entire Civitai model URL into the search bar in the Civitai model browser (when the Civitai API gets fixed)
1111
### Changed
12-
- The main sidebar now remembers whether it was collapsed or expanded between restarts
12+
- The main sidebar now remembers whether it was collapsed or expanded between restarts.
13+
- Inference is now able to load image metadata from Civitai generated images via drag & drop
14+
- Updated process tracking for ComfyUI to help mitigate restart issues when using Comfy Manager
1315
- Updated pre-selected download locations for certain model types in the Civitai model browser
1416
### Fixed
1517
- Fixed missing .NET 8 dependency for SwarmUI installs in certain cases
18+
- Fixed ComfyUI-Zluda not being recognized as a valid Comfy install for the workflow browser
1619
- Fixed [#1291](https://github.com/LykosAI/StabilityMatrix/issues/1291) - Certain GPUs not being detected on Linux
1720
- Fixed [#1284](https://github.com/LykosAI/StabilityMatrix/issues/1284) - Output browser not ignoring InvokeAI thumbnails folders
1821
- Fixed [#1305](https://github.com/LykosAI/StabilityMatrix/issues/1305) - FluxGym installing incorrect packages for Blackwell GPUs

StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ public void LoadImageMetadata(LocalImageFile localImageFile)
204204
/// </summary>
205205
private void LoadImageMetadata(
206206
string imageFilePath,
207-
(string? Parameters, string? ParametersJson, string? SMProject, string? ComfyNodes) metadata
207+
(
208+
string? Parameters,
209+
string? ParametersJson,
210+
string? SMProject,
211+
string? ComfyNodes,
212+
string? CivitParameters
213+
) metadata
208214
)
209215
{
210216
// Has SMProject metadata
@@ -236,8 +242,8 @@ private void LoadImageMetadata(
236242
// Load image
237243
if (this is IImageGalleryComponent imageGalleryComponent)
238244
{
239-
Dispatcher.UIThread.Invoke(
240-
() => imageGalleryComponent.LoadImagesToGallery(new ImageSource(imageFilePath))
245+
Dispatcher.UIThread.Invoke(() =>
246+
imageGalleryComponent.LoadImagesToGallery(new ImageSource(imageFilePath))
241247
);
242248
}
243249

@@ -270,8 +276,41 @@ private void LoadImageMetadata(
270276
// Load image
271277
if (this is IImageGalleryComponent imageGalleryComponent)
272278
{
273-
Dispatcher.UIThread.Invoke(
274-
() => imageGalleryComponent.LoadImagesToGallery(new ImageSource(imageFilePath))
279+
Dispatcher.UIThread.Invoke(() =>
280+
imageGalleryComponent.LoadImagesToGallery(new ImageSource(imageFilePath))
281+
);
282+
}
283+
284+
return;
285+
}
286+
287+
// Civit generator metadata
288+
if (metadata.CivitParameters is not null)
289+
{
290+
Logger.Info("Loading Parameters from metadata");
291+
292+
if (!GenerationParameters.TryParse(metadata.CivitParameters, out var parameters))
293+
{
294+
throw new ApplicationException("Failed to parse parameters");
295+
}
296+
297+
if (this is IParametersLoadableState paramsLoadableVm)
298+
{
299+
Dispatcher.UIThread.Invoke(() => paramsLoadableVm.LoadStateFromParameters(parameters));
300+
}
301+
else
302+
{
303+
Logger.Warn(
304+
"Load parameters target {Type} does not implement IParametersLoadableState, skipping",
305+
GetType().Name
306+
);
307+
}
308+
309+
// Load image
310+
if (this is IImageGalleryComponent imageGalleryComponent)
311+
{
312+
Dispatcher.UIThread.Invoke(() =>
313+
imageGalleryComponent.LoadImagesToGallery(new ImageSource(imageFilePath))
275314
);
276315
}
277316

StabilityMatrix.Avalonia/ViewModels/Dialogs/OpenArtWorkflowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ IPackageFactory packageFactory
4747

4848
public List<InstalledPackage> AvailablePackages =>
4949
settingsManager
50-
.Settings.InstalledPackages.Where(package => package.PackageName == "ComfyUI")
50+
.Settings.InstalledPackages.Where(package => package.PackageName is "ComfyUI" or "ComfyUI-Zluda")
5151
.ToList();
5252

5353
public List<PackageExtension> MissingNodes { get; } = [];
@@ -157,7 +157,7 @@ out var manifestExtension
157157
currentSection = new OpenArtCustomNode
158158
{
159159
Title = node,
160-
IsInstalled = installedNodesNames.Contains(node)
160+
IsInstalled = installedNodesNames.Contains(node),
161161
};
162162

163163
// Add missing nodes to the list

StabilityMatrix.Core/Helper/ImageMetadata.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ public static (
7878
string? Parameters,
7979
string? ParametersJson,
8080
string? SMProject,
81-
string? ComfyNodes
81+
string? ComfyNodes,
82+
string? CivitParameters
8283
) GetAllFileMetadata(FilePath filePath)
8384
{
8485
if (filePath.Extension.Equals(".webp", StringComparison.OrdinalIgnoreCase))
8586
{
8687
var paramsJson = ReadTextChunkFromWebp(filePath, ExifDirectoryBase.TagImageDescription);
8788
var smProj = ReadTextChunkFromWebp(filePath, ExifDirectoryBase.TagSoftware);
8889

89-
return (null, paramsJson, smProj, null);
90+
return (null, paramsJson, smProj, null, null);
9091
}
9192

9293
using var stream = filePath.Info.OpenRead();
@@ -96,12 +97,14 @@ public static (
9697
var parametersJson = ReadTextChunk(reader, "parameters-json");
9798
var smProject = ReadTextChunk(reader, "smproj");
9899
var comfyNodes = ReadTextChunk(reader, "prompt");
100+
var civitParameters = ReadTextChunk(reader, "user_comment");
99101

100102
return (
101103
string.IsNullOrEmpty(parameters) ? null : parameters,
102104
string.IsNullOrEmpty(parametersJson) ? null : parametersJson,
103105
string.IsNullOrEmpty(smProject) ? null : smProject,
104-
string.IsNullOrEmpty(comfyNodes) ? null : comfyNodes
106+
string.IsNullOrEmpty(comfyNodes) ? null : comfyNodes,
107+
string.IsNullOrEmpty(civitParameters) ? null : civitParameters
105108
);
106109
}
107110

@@ -124,8 +127,8 @@ public static (
124127

125128
// Use "parameters-json" tag if exists
126129
if (
127-
textualData.FirstOrDefault(
128-
tag => tag.Description is { } desc && desc.StartsWith("parameters-json: ")
130+
textualData.FirstOrDefault(tag =>
131+
tag.Description is { } desc && desc.StartsWith("parameters-json: ")
129132
) is
130133
{ Description: { } description }
131134
)
@@ -137,8 +140,8 @@ public static (
137140

138141
// Otherwise parse "parameters" tag
139142
if (
140-
textualData.FirstOrDefault(
141-
tag => tag.Description is { } desc && desc.StartsWith("parameters: ")
143+
textualData.FirstOrDefault(tag =>
144+
tag.Description is { } desc && desc.StartsWith("parameters: ")
142145
) is
143146
{ Description: { } parameters }
144147
)

StabilityMatrix.Core/Models/Database/LocalImageFile.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ public record LocalImageFile
5151
/// </summary>
5252
public string FileNameWithoutExtension => Path.GetFileNameWithoutExtension(AbsolutePath);
5353

54-
public (string? Parameters, string? ParametersJson, string? SMProject, string? ComfyNodes) ReadMetadata()
54+
public (
55+
string? Parameters,
56+
string? ParametersJson,
57+
string? SMProject,
58+
string? ComfyNodes,
59+
string? CivitParameters
60+
) ReadMetadata()
5561
{
5662
if (AbsolutePath.EndsWith("webp"))
5763
{
@@ -61,7 +67,7 @@ public record LocalImageFile
6167
);
6268
var smProj = ImageMetadata.ReadTextChunkFromWebp(AbsolutePath, ExifDirectoryBase.TagSoftware);
6369

64-
return (null, paramsJson, smProj, null);
70+
return (null, paramsJson, smProj, null, null);
6571
}
6672

6773
using var stream = new FileStream(AbsolutePath, FileMode.Open, FileAccess.Read, FileShare.Read);
@@ -71,12 +77,14 @@ public record LocalImageFile
7177
var parametersJson = ImageMetadata.ReadTextChunk(reader, "parameters-json");
7278
var smProject = ImageMetadata.ReadTextChunk(reader, "smproj");
7379
var comfyNodes = ImageMetadata.ReadTextChunk(reader, "prompt");
80+
var civitParameters = ImageMetadata.ReadTextChunk(reader, "user_comment");
7481

7582
return (
7683
string.IsNullOrEmpty(parameters) ? null : parameters,
7784
string.IsNullOrEmpty(parametersJson) ? null : parametersJson,
7885
string.IsNullOrEmpty(smProject) ? null : smProject,
79-
string.IsNullOrEmpty(comfyNodes) ? null : comfyNodes
86+
string.IsNullOrEmpty(comfyNodes) ? null : comfyNodes,
87+
string.IsNullOrEmpty(civitParameters) ? null : civitParameters
8088
);
8189
}
8290

@@ -113,7 +121,7 @@ public static LocalImageFile FromPath(FilePath filePath)
113121
CreatedAt = filePath.Info.CreationTimeUtc,
114122
LastModifiedAt = filePath.Info.LastWriteTimeUtc,
115123
GenerationParameters = parameters,
116-
ImageSize = new Size(parameters?.Width ?? 0, parameters?.Height ?? 0)
124+
ImageSize = new Size(parameters?.Width ?? 0, parameters?.Height ?? 0),
117125
};
118126
}
119127

@@ -136,6 +144,10 @@ public static LocalImageFile FromPath(FilePath filePath)
136144
else
137145
{
138146
metadata = ImageMetadata.ReadTextChunk(reader, "parameters");
147+
if (string.IsNullOrWhiteSpace(metadata)) // if still empty, try civitai metadata (user_comment)
148+
{
149+
metadata = ImageMetadata.ReadTextChunk(reader, "user_comment");
150+
}
139151
GenerationParameters.TryParse(metadata, out genParams);
140152
}
141153

@@ -148,7 +160,7 @@ public static LocalImageFile FromPath(FilePath filePath)
148160
CreatedAt = filePath.Info.CreationTimeUtc,
149161
LastModifiedAt = filePath.Info.LastWriteTimeUtc,
150162
GenerationParameters = genParams,
151-
ImageSize = imageSize
163+
ImageSize = imageSize,
152164
};
153165
}
154166

@@ -162,7 +174,7 @@ public static LocalImageFile FromPath(FilePath filePath)
162174
ImageType = imageType,
163175
CreatedAt = filePath.Info.CreationTimeUtc,
164176
LastModifiedAt = filePath.Info.LastWriteTimeUtc,
165-
ImageSize = new Size { Height = codec.Info.Height, Width = codec.Info.Width }
177+
ImageSize = new Size { Height = codec.Info.Height, Width = codec.Info.Width },
166178
};
167179
}
168180

@@ -172,6 +184,6 @@ public static LocalImageFile FromPath(FilePath filePath)
172184
".jpg",
173185
".jpeg",
174186
".gif",
175-
".webp"
187+
".webp",
176188
];
177189
}

StabilityMatrix.Core/Models/Packages/ComfyUI.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ public override async Task RunPackage(
414414
OnExit
415415
);
416416

417+
if (Compat.IsWindows)
418+
{
419+
ProcessTracker.AttachExitHandlerJobToProcess(VenvRunner.Process);
420+
}
421+
417422
return;
418423

419424
void HandleConsoleOutput(ProcessOutput s)

0 commit comments

Comments
 (0)