Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 396b210

Browse files
committed
Move records to models folder
1 parent bf58953 commit 396b210

File tree

10 files changed

+62
-115
lines changed

10 files changed

+62
-115
lines changed

OnnxStack.WebUI/Hubs/StableDiffusionHub.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,4 @@ private string CreateOutputUrl(string folder, string file)
226226
return $"/images/results/{folder}/{file}";
227227
}
228228
}
229-
230-
public record ProgressResult(int Progress, int Total);
231-
public record TextToImageResult(string ImageName, string ImageUrl, ImageBlueprint Blueprint, string BlueprintName, string BlueprintUrl, int Elapsed);
232-
public record FileInfoResult(string Image, string ImageUrl, string ImageFile, string Blueprint, string BlueprintUrl, string BlueprintFile);
233-
234-
public record ImageBlueprint(PromptOptions Prompt, SchedulerOptions Options)
235-
{
236-
public DateTime Timestamp { get; } = DateTime.UtcNow;
237-
}
238229
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace OnnxStack.WebUI.Models
2+
{
3+
public record FileInfoResult(string Image, string ImageUrl, string ImageFile, string Blueprint, string BlueprintUrl, string BlueprintFile);
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using OnnxStack.StableDiffusion.Config;
2+
3+
namespace OnnxStack.WebUI.Models
4+
{
5+
public record ImageBlueprint(PromptOptions Prompt, SchedulerOptions Options)
6+
{
7+
public DateTime Timestamp { get; } = DateTime.UtcNow;
8+
}
9+
}

OnnxStack.WebUI/Models/ModalResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Newtonsoft.Json;
33

4-
namespace OnnxStack.Web.Models
4+
namespace OnnxStack.WebUI.Models
55
{
66
public class ModalResult : ActionResult
77
{
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace OnnxStack.WebUI.Models
2+
{
3+
public record ProgressResult(int Progress, int Total);
4+
}

OnnxStack.WebUI/Models/TextToImageOptions.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace OnnxStack.WebUI.Models
2+
{
3+
public record TextToImageResult(string ImageName, string ImageUrl, ImageBlueprint Blueprint, string BlueprintName, string BlueprintUrl, int Elapsed);
4+
}

OnnxStack.WebUI/Pages/StableDiffusion/Index.cshtml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Microsoft.AspNetCore.Mvc.RazorPages;
33
using OnnxStack.Web.Models;
4+
using OnnxStack.WebUI.Models;
45

56
namespace OnnxStack.WebUI.Pages.StableDiffusion
67
{

OnnxStack.WebUI/Pages/StableDiffusion/TextToImage.cshtml

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<div class="d-flex flex-fill">
2626

2727
@* Controls *@
28-
<div class="d-flex flex-column w-100 me-2 p-2 border border-1 border-dark" style="max-width:500px;overflow:hidden">
28+
<div class="d-flex flex-column w-100 me-2 p-2 border border-1 border-dark" style="max-width:440px;overflow:hidden">
2929

3030
<h4 class="pb-0 mb-0">Text To Image</h4>
3131
<small>Text to image transforms textual descriptions into visual content</small>
@@ -40,13 +40,13 @@
4040
<div class="d-flex flex-column flex-grow-0 gap-2 p-1 w-100">
4141
<div class="d-flex flex-column">
4242
<small>Prompt</small>
43-
@Html.TextAreaFor(m => m.Options.Prompt, new { @class = "form-control form-control-sm p-1", @rows = 3 })
44-
@Html.ValidationMessageFor(m => m.Options.Prompt, "", new { @class = "text-danger" })
43+
@Html.TextAreaFor(m => m.Prompt.Prompt, new { @class = "form-control form-control-sm p-1", @rows = 3 })
44+
@Html.ValidationMessageFor(m => m.Prompt.Prompt, "", new { @class = "text-danger" })
4545
</div>
4646
<div class="d-flex flex-column">
4747
<small>Negative Prompt</small>
48-
@Html.TextAreaFor(m => m.Options.NegativePrompt, new { @class = "form-control form-control-sm", @rows = 3 })
49-
@Html.ValidationMessageFor(m => m.Options.NegativePrompt, "", new { @class = "text-danger" })
48+
@Html.TextAreaFor(m => m.Prompt.NegativePrompt, new { @class = "form-control form-control-sm", @rows = 2 })
49+
@Html.ValidationMessageFor(m => m.Prompt.NegativePrompt, "", new { @class = "text-danger" })
5050
</div>
5151
</div>
5252

@@ -72,20 +72,21 @@
7272
<div class="d-flex flex-row gap-2">
7373
<div class="w-100">
7474
<small>Scheduler</small>
75-
@Html.DropDownListFor( m => m.Options.SchedulerType,Html.GetEnumSelectList<SchedulerType>(), new { @class = "form-control form-select-sm"})
75+
@Html.DropDownListFor( m => m.Prompt.SchedulerType,Html.GetEnumSelectList<SchedulerType>(), new { @class = "form-control form-select-sm"})
7676
</div>
77-
<div class="w-75">
77+
<div class="w-100">
78+
<small>Seed <i>(0 = Random)</i></small>
79+
@Html.TextBoxFor( m => m.Options.Seed, new { @class = "form-control form-control-sm"})
80+
</div>
81+
<div class="w-50">
7882
<small>Width</small>
7983
@Html.DropDownListFor( m => m.Options.Width, new SelectList(ValidSizes), new { @class = "form-control form-select-sm"})
8084
</div>
81-
<div class="w-75">
85+
<div class="w-50">
8286
<small>Height</small>
8387
@Html.DropDownListFor( m => m.Options.Height, new SelectList(ValidSizes), new { @class = "form-control form-select-sm"})
8488
</div>
85-
<div class="w-100">
86-
<small>Seed <i>(0 = Random)</i></small>
87-
@Html.TextBoxFor( m => m.Options.Seed, new { @class = "form-control form-control-sm"})
88-
</div>
89+
8990
</div>
9091

9192
<div class="d-flex flex-row gap-2">
@@ -128,15 +129,15 @@
128129
<div class="w-100">
129130
<div class="d-flex flex-row align-items-center mt-3">
130131
<input type="checkbox" asp-for="@Model.Options.UseKarrasSigmas" />
131-
<small class="ms-1">UseKarrasSigmas</small>
132+
<small class="ms-1">Karras Sigmas</small>
132133
</div>
133134
</div>
134135

135136
</div>
136137

137138
<div class="d-flex flex-row align-items-center gap-2">
138139
<div class="w-100">
139-
<small>BetaScheduleType</small>
140+
<small>BetaSchedule</small>
140141
@Html.DropDownListFor( m => m.Options.BetaSchedule, Html.GetEnumSelectList<BetaScheduleType>(), new { @class = "form-control form-select-sm"})
141142
</div>
142143
<div class="w-100">
@@ -156,15 +157,15 @@
156157
<div class="d-flex flex-row align-items-center gap-2">
157158

158159
<div class="w-100">
159-
<small>VarianceType</small>
160+
<small>Variance</small>
160161
@Html.DropDownListFor( m => m.Options.VarianceType, Html.GetEnumSelectList<VarianceType>(), new { @class = "form-control form-select-sm"})
161162
</div>
162163
<div class="w-100">
163-
<small>PredictionType</small>
164+
<small>Prediction</small>
164165
@Html.DropDownListFor( m => m.Options.PredictionType, Html.GetEnumSelectList<PredictionType>(), new { @class = "form-control form-select-sm"})
165166
</div>
166167
<div class="w-100">
167-
<small>AlphaTransformType</small>
168+
<small>AlphaTransform</small>
168169
@Html.DropDownListFor( m => m.Options.AlphaTransformType, Html.GetEnumSelectList<AlphaTransformType>(), new { @class = "form-control form-select-sm"})
169170
</div>
170171
<div class="w-100">
@@ -199,7 +200,7 @@
199200

200201
<div class="d-flex flex-column flex-grow-0 w-100">
201202
<div class="d-flex flex-row gap-2 justify-content-between" autocomplete="off">
202-
<div class="d-flex flex-column justify-content-end w-50">
203+
<div class="d-flex flex-column justify-content-end w-75">
203204
<div class="d-flex flex-row gap-2">
204205
<button type="button" class="btn-cancel btn btn-warning w-100" disabled>Cancel</button>
205206
<button id="btn-txt2img-execute" type="button" class="btn btn-success w-100">Generate</button>
@@ -223,31 +224,8 @@
223224
</div>
224225

225226
</div>
226-
227-
228-
229-
230-
231-
232-
233-
234-
235-
236-
237-
238-
239-
240-
241-
242-
243-
244-
245-
246-
247-
248227
</form>
249228

250-
251229
</div>
252230
</div>
253231

@@ -281,24 +259,24 @@
281259
<script id="outputResultTemplate" type="text/html">
282260
<div class="d-flex flex-column border border-1 border-dark p-1" style="min-width:256px;">
283261
<div style="overflow:hidden;text-align:center">
284-
<img id="img-result" width="{{width}}" height="{{height}}" src="{{outputImageUrl}}" />
262+
<img id="img-result" width="{{width}}" height="{{height}}" src="{{imageUrl}}" alt="{{imageName}}"/>
285263
</div>
286264
<div class="d-flex flex-row flex-wrap-reverse justify-content-around pt-2" style="max-width:{{width}}px">
287265
<div class="d-flex flex-row align-items-center">
288266
<small class="result-info">Scheduler:</small>
289-
<span>{{outputOptions.schedulerType}}</span>
267+
<span>{{blueprint.prompt.schedulerType}}</span>
290268
</div>
291269
<div class="d-flex flex-row align-items-center">
292270
<small class="result-info">Steps:</small>
293-
<span>{{outputOptions.inferenceSteps}}</span>
271+
<span>{{blueprint.options.inferenceSteps}}</span>
294272
</div>
295273
<div class="d-flex flex-row align-items-center">
296274
<small class="result-info">Guidance:</small>
297-
<span>{{outputOptions.guidanceScale}}</span>
275+
<span>{{blueprint.options.guidanceScale}}</span>
298276
</div>
299277
<div class="d-flex flex-row align-items-center">
300278
<small class="result-info">Seed:</small>
301-
<span>{{outputOptions.seed}}</span>
279+
<span>{{blueprint.options.seed}}</span>
302280
</div>
303281
<div class="d-flex flex-row align-items-center">
304282
<small class="result-info">Elapsed:</small>
@@ -307,12 +285,12 @@
307285
</div>
308286
<div class="d-flex flex-row gap-2 pt-2">
309287
<div class="btn-group dropend w-100">
310-
<a class="btn btn-sm btn-success w-100" href="{{outputImageUrl}}" download="{{outputImage}}">Download</a>
288+
<a class="btn btn-sm btn-success w-100" href="{{imageUrl}}" download="{{imageName}}">Download</a>
311289
<button type="button" class="btn btn-sm btn-success dropdown-toggle dropdown-toggle-split w-25" data-bs-toggle="dropdown" aria-expanded="false">
312290
</button>
313291
<ul class="dropdown-menu">
314-
<li><a class="dropdown-item" href="{{outputImageUrl}}" download="{{outputImage}}">Download PNG</a></li>
315-
<li><a class="dropdown-item" href="{{outputOptionsUrl}}" download="{{OutputOptions}}">Download JSON</a></li>
292+
<li><a class="dropdown-item" href="{{imageUrl}}" download="{{imageName}}">Download PNG</a></li>
293+
<li><a class="dropdown-item" href="{{blueprintUrl}}" download="{{blueprintName}}">Download JSON</a></li>
316294
</ul>
317295
</div>
318296
<button type="button" class="btn btn-sm btn-info w-100" disabled>Image To Image</button>
@@ -339,8 +317,7 @@
339317
const onResponse = (response) => {
340318
if (!response)
341319
return;
342-
343-
console.log(response);
320+
console.log(response)
344321
updateResultImage(response);
345322
processEnd();
346323
}
@@ -354,12 +331,10 @@
354331
}
355332
356333
const onProgress = (response) => {
357-
console.log(response);
358334
updateProgress(response);
359335
}
360336
361337
const onCanceled = (response) => {
362-
console.log(response);
363338
updatePlaceholderImage();
364339
processEnd();
365340
}
@@ -372,7 +347,7 @@
372347
processBegin();
373348
updatePlaceholderImage();
374349
diffusionProcess = await connection
375-
.stream("ExecuteTextToImage", diffusionParams)
350+
.stream("ExecuteTextToImage", diffusionParams, diffusionParams) //TODO: split params
376351
.subscribe({
377352
next: onResponse,
378353
complete: onResponse,

OnnxStack.WebUI/Pages/StableDiffusion/TextToImage.cshtml.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.AspNetCore.Mvc;
22
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using OnnxStack.WebUI.Models;
3+
using OnnxStack.StableDiffusion.Config;
44

55
namespace OnnxStack.WebUI.Pages.StableDiffusion
66
{
@@ -14,13 +14,19 @@ public TextToImageModel(ILogger<IndexModel> logger)
1414
}
1515

1616
[BindProperty]
17-
public TextToImageOptions Options { get; set; }
17+
public PromptOptions Prompt { get; set; }
18+
19+
[BindProperty]
20+
public SchedulerOptions Options { get; set; }
1821

1922
public void OnGet()
2023
{
21-
Options = new TextToImageOptions
24+
Prompt = new PromptOptions
25+
{
26+
};
27+
28+
Options = new SchedulerOptions
2229
{
23-
Prompt = "photo of a cat"
2430
};
2531
}
2632
}

0 commit comments

Comments
 (0)