Skip to content

Commit b6443ff

Browse files
committed
Add "Core ML" to CivitAI model formats
1 parent be07d27 commit b6443ff

5 files changed

Lines changed: 40 additions & 10 deletions

File tree

Diffusion.Civitai/CivitaiClient.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,39 @@ private async Task<T> GetResponseResults<T>(HttpClient client, string url, Cance
5656

5757
if (response.IsSuccessStatusCode)
5858
{
59-
var options = new JsonSerializerOptions
60-
{
61-
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
62-
Converters =
63-
{
64-
new JsonStringEnumConverter()
65-
}
66-
};
59+
//var options = new JsonSerializerOptions
60+
//{
61+
// PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
62+
// Converters =
63+
// {
64+
// new JsonStringEnumConverter()
65+
// }
66+
//};
67+
68+
var options = new JsonSerializerOptions();
69+
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
70+
options.Converters.Add(new JsonStringEnumConverterWithAttributeSupport());
6771

6872
using (var responseStream = await response.Content.ReadAsStreamAsync(token))
6973
{
7074
results = await JsonSerializer.DeserializeAsync<T>(responseStream, options);
75+
76+
//using var buffer = new MemoryStream();
77+
//await responseStream.CopyToAsync(buffer);
78+
//responseStream.Flush();
79+
//responseStream.Close();
80+
81+
//buffer.Position = 0;
82+
//using var fs = new FileStream($"civitai-{DateTime.Now:yyyyMMddhhmmss}.json", FileMode.Create, FileAccess.Write);
83+
//await buffer.CopyToAsync(fs);
84+
//fs.Flush();
85+
//fs.Close();
86+
87+
//buffer.Position = 0;
88+
//results = await JsonSerializer.DeserializeAsync<T>(buffer, options);
89+
90+
//buffer.Close();
91+
7192
}
7293
}
7394
else

Diffusion.Civitai/Diffusion.Civitai.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<PackageReference Include="EnumExtensions.System.Text.Json" Version="1.1.0" />
11+
</ItemGroup>
12+
913
</Project>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
namespace Diffusion.Civitai.Models;
1+
using System.Runtime.Serialization;
2+
3+
namespace Diffusion.Civitai.Models;
24

35
public enum ModelFormat
46
{
57
SafeTensor,
68
PickleTensor,
79
Diffusers,
10+
[EnumMember(Value = "Core ML")]
11+
CoreML,
812
Other
913
}

Diffusion.Toolkit/MainWindow.xaml.Models.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async void DownloadCivitaiModels()
2525

2626
var message = "This will download Civitai model info.\r\n\r\n" + "Are you sure you want to continue?";
2727

28-
var result = await _messagePopupManager.Show(message, "Download Civitai models", PopupButtons.YesNo);
28+
var result = await _messagePopupManager.ShowCustom(message, "Download Civitai models", PopupButtons.YesNo, 500, 250);
2929

3030
if (result == PopupResult.Yes)
3131
{

What's New v1.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ You can even use it on images without metadata and still use the other features
114114

115115
## Bugfixes
116116

117+
* Add "Core ML" to CivitAI model formats
117118
* Loading a large image should no longer block the UI
118119
* Folder not updating after move (#152)
119120
* Crash opening app: "An unhandled exception occured: 'N' is an invalid start of a value (#155) (thanks to kwaegel)

0 commit comments

Comments
 (0)