Ionite
1 year ago
6 changed files with 24 additions and 18 deletions
@ -1,33 +1,28 @@ |
|||||||
using System.Collections.Generic; |
using System.Text.Json; |
||||||
using System.Linq; |
|
||||||
using System.Text.Json; |
|
||||||
using System.Text.RegularExpressions; |
|
||||||
using MetadataExtractor; |
using MetadataExtractor; |
||||||
using StabilityMatrix.Avalonia.Models.Inference; |
|
||||||
using StabilityMatrix.Core.Extensions; |
using StabilityMatrix.Core.Extensions; |
||||||
|
using StabilityMatrix.Core.Models; |
||||||
using StabilityMatrix.Core.Models.FileInterfaces; |
using StabilityMatrix.Core.Models.FileInterfaces; |
||||||
|
using Directory = MetadataExtractor.Directory; |
||||||
|
|
||||||
namespace StabilityMatrix.Avalonia.Helpers; |
namespace StabilityMatrix.Core.Helper; |
||||||
|
|
||||||
public partial class ImageMetadata |
public class ImageMetadata |
||||||
{ |
{ |
||||||
private IReadOnlyList<Directory>? Directories { get; set; } |
private IReadOnlyList<Directory>? Directories { get; set; } |
||||||
|
|
||||||
public static ImageMetadata ParseFile(FilePath path) |
public static ImageMetadata ParseFile(FilePath path) |
||||||
{ |
{ |
||||||
return new ImageMetadata() { Directories = ImageMetadataReader.ReadMetadata(path) }; |
return new ImageMetadata { Directories = ImageMetadataReader.ReadMetadata(path) }; |
||||||
} |
} |
||||||
|
|
||||||
public IEnumerable<Tag>? GetTextualData() |
public IEnumerable<Tag>? GetTextualData() |
||||||
{ |
{ |
||||||
// Get the PNG-tEXt directory |
// Get the PNG-tEXt directory |
||||||
if (Directories?.FirstOrDefault(d => d.Name == "PNG-tEXt") is not { } pngText) |
return Directories? |
||||||
{ |
.Where(d => d.Name == "PNG-tEXt") |
||||||
return null; |
.SelectMany(d => d.Tags) |
||||||
} |
.Where(t => t.Name == "Textual Data"); |
||||||
|
|
||||||
// Expect the 'Textual Data' tag |
|
||||||
return pngText.Tags.Where(tag => tag.Name == "Textual Data"); |
|
||||||
} |
} |
||||||
|
|
||||||
public GenerationParameters? GetGenerationParameters() |
public GenerationParameters? GetGenerationParameters() |
@ -1,9 +1,8 @@ |
|||||||
using System.Diagnostics.CodeAnalysis; |
using System.Diagnostics.CodeAnalysis; |
||||||
using System.Linq; |
|
||||||
using System.Text.Json.Serialization; |
using System.Text.Json.Serialization; |
||||||
using System.Text.RegularExpressions; |
using System.Text.RegularExpressions; |
||||||
|
|
||||||
namespace StabilityMatrix.Avalonia.Models.Inference; |
namespace StabilityMatrix.Core.Models; |
||||||
|
|
||||||
[JsonSerializable(typeof(GenerationParameters))] |
[JsonSerializable(typeof(GenerationParameters))] |
||||||
public partial class GenerationParameters |
public partial class GenerationParameters |
Loading…
Reference in new issue