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

Commit b9b9b97

Browse files
committed
Rename ProcessType to DiffuserType
1 parent 8f65278 commit b9b9b97

File tree

7 files changed

+22
-16
lines changed

7 files changed

+22
-16
lines changed

OnnxStack.StableDiffusion/Common/IModelOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public interface IModelOptions : IOnnxModel
1515
int TokenizerLimit { get; set; }
1616
int InputTokenLimit { get; set; }
1717
int EmbeddingsLength { get; set; }
18-
List<ProcessType> Diffusers { get; set; }
18+
List<DiffuserType> Diffusers { get; set; }
1919
ImmutableArray<int> BlankTokenValueArray { get; set; }
2020
}
2121
}

OnnxStack.StableDiffusion/Config/ModelOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ModelOptions : IModelOptions, IOnnxModelSetConfig
1919
public int TokenizerLimit { get; set; }
2020
public int EmbeddingsLength { get; set; }
2121
public float ScaleFactor { get; set; }
22-
public List<ProcessType> Diffusers { get; set; } = new List<ProcessType>();
22+
public List<DiffuserType> Diffusers { get; set; } = new List<DiffuserType>();
2323

2424
public int DeviceId { get; set; }
2525
public int InterOpNumThreads { get; set; }

OnnxStack.StableDiffusion/Config/PromptOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace OnnxStack.StableDiffusion.Config
66
{
77
public class PromptOptions
88
{
9-
public ProcessType ProcessType { get; set; }
9+
public DiffuserType DiffuserType { get; set; }
1010

1111
[Required]
1212
[StringLength(512, MinimumLength = 4)]
@@ -24,7 +24,7 @@ public class PromptOptions
2424
public bool HasInputImageMask => InputImageMask?.HasImage ?? false;
2525
}
2626

27-
public enum ProcessType
27+
public enum DiffuserType
2828
{
2929
TextToImage = 0,
3030
ImageToImage = 1,

OnnxStack.StableDiffusion/Config/StableDiffusionConfig.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ public void Initialize()
2424
foreach (var modelSet in OnnxModelSets)
2525
{
2626
modelSet.InitBlankTokenArray();
27-
foreach (var model in modelSet.ModelConfigurations.Where(x => x.Type == OnnxModelType.Tokenizer && string.IsNullOrEmpty(x.OnnxModelPath)))
28-
model.OnnxModelPath = defaultTokenizer;
27+
foreach (var model in modelSet.ModelConfigurations)
28+
{
29+
if (model.Type == OnnxModelType.Tokenizer && string.IsNullOrEmpty(model.OnnxModelPath))
30+
model.OnnxModelPath = defaultTokenizer;
31+
32+
if (!File.Exists(model.OnnxModelPath))
33+
modelSet.IsEnabled = false;
34+
}
2935
}
3036
}
3137
}

OnnxStack.StableDiffusion/Services/StableDiffusionService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ public async Task<Stream> GenerateAsStreamAsync(IModelOptions model, PromptOptio
146146

147147
private async Task<DenseTensor<float>> RunAsync(IModelOptions modelOptions, PromptOptions promptOptions, SchedulerOptions schedulerOptions, Action<int, int> progress = null, CancellationToken cancellationToken = default)
148148
{
149-
return promptOptions.ProcessType switch
149+
return promptOptions.DiffuserType switch
150150
{
151-
ProcessType.TextToImage => await _textDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
152-
ProcessType.ImageToImage => await _imageDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
153-
ProcessType.ImageInpaint => await _inpaintDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
154-
ProcessType.ImageInpaintLegacy => await _inpaintLegacyDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
151+
DiffuserType.TextToImage => await _textDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
152+
DiffuserType.ImageToImage => await _imageDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
153+
DiffuserType.ImageInpaint => await _inpaintDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
154+
DiffuserType.ImageInpaintLegacy => await _inpaintLegacyDiffuser.DiffuseAsync(modelOptions, promptOptions, schedulerOptions, progress, cancellationToken),
155155
_ => throw new NotImplementedException()
156156
};
157157
}

OnnxStack.WebUI/Hubs/StableDiffusionHub.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public async IAsyncEnumerable<StableDiffusionResult> OnExecuteImageInpaint(Promp
126126
private async Task<StableDiffusionResult> GenerateTextToImageResult(PromptOptions promptOptions, SchedulerOptions schedulerOptions, CancellationToken cancellationToken)
127127
{
128128
var timestamp = Stopwatch.GetTimestamp();
129-
promptOptions.ProcessType = ProcessType.TextToImage;
129+
promptOptions.DiffuserType = DiffuserType.TextToImage;
130130
schedulerOptions.Seed = GenerateSeed(schedulerOptions.Seed);
131131

132132
//1. Create filenames
@@ -166,7 +166,7 @@ private async Task<StableDiffusionResult> GenerateTextToImageResult(PromptOption
166166
private async Task<StableDiffusionResult> GenerateImageToImageResult(PromptOptions promptOptions, SchedulerOptions schedulerOptions, CancellationToken cancellationToken)
167167
{
168168
var timestamp = Stopwatch.GetTimestamp();
169-
promptOptions.ProcessType = ProcessType.ImageToImage;
169+
promptOptions.DiffuserType = DiffuserType.ImageToImage;
170170
schedulerOptions.Seed = GenerateSeed(schedulerOptions.Seed);
171171

172172
//1. Create filenames
@@ -213,7 +213,7 @@ private async Task<StableDiffusionResult> GenerateImageToImageResult(PromptOptio
213213
private async Task<StableDiffusionResult> GenerateImageInpaintResult(PromptOptions promptOptions, SchedulerOptions schedulerOptions, CancellationToken cancellationToken)
214214
{
215215
var timestamp = Stopwatch.GetTimestamp();
216-
promptOptions.ProcessType = ProcessType.ImageInpaint;
216+
promptOptions.DiffuserType = DiffuserType.ImageInpaint;
217217
schedulerOptions.Seed = GenerateSeed(schedulerOptions.Seed);
218218

219219
// 1. Create filenames

OnnxStack.WebUI/Models/ImageBlueprint.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public ImageBlueprint(PromptOptions prompt, SchedulerOptions options, string out
1515
Prompt = prompt.Prompt;
1616
NegativePrompt = prompt.NegativePrompt;
1717
SchedulerType = prompt.SchedulerType;
18-
ProcessType = prompt.ProcessType;
18+
DiffuserType = prompt.DiffuserType;
1919
}
2020

2121
public DateTime Timestamp { get; }
2222
public string Prompt { get; }
2323
public string NegativePrompt { get; }
2424
public SchedulerType SchedulerType { get; }
25-
public ProcessType ProcessType { get; }
25+
public DiffuserType DiffuserType { get; }
2626
public string MaskImageUrl { get; }
2727
public string InputImageUrl { get; }
2828
public string OutputImageUrl { get; }

0 commit comments

Comments
 (0)