├── .gitignore
├── .gitmodules
├── LICENSE.txt
├── docs
├── interrogation example.png
├── main window.png
├── project settings.png
├── settings.png
└── yolo mask generation.png
├── publish.ps1
├── readme.md
└── src
├── .gitignore
├── ImageUtil
├── ImageConverter.cs
├── ImageUtil.csproj
├── Interrogation
│ ├── CogVLM2Interrogator.cs
│ ├── ConfiguredInterrogationContext.cs
│ ├── INaturalLanguageInterrogator.cs
│ ├── ITagInterrogator.cs
│ ├── JoyCaptionAlphaOne.cs
│ ├── JoyCaptionAlphaTwo.cs
│ ├── JoyCaptionBetaOne.cs
│ ├── JoyCaptionPreAlpha.cs
│ └── SWTagger.cs
├── KumikoWrapper.cs
├── MetaTags.cs
├── PythonImageEngine.cs
├── PythonUtilities.cs
├── PythonWrapper.cs
├── Utility.cs
└── python
│ ├── cogvlm2
│ ├── interrogate.py
│ └── requirements.txt
│ ├── joycaption
│ └── interrogate.py
│ ├── joycaptionalphaone
│ └── interrogate.py
│ ├── joycaptionalphatwo
│ └── interrogate.py
│ ├── joycaptionbetaone
│ └── interrogate.py
│ ├── sw
│ └── interrogate.py
│ └── utilities
│ ├── main.py
│ └── requirements.txt
├── SdWebUiApi
├── Api
│ └── DefaultApi.cs
├── Client
│ ├── ApiClient.cs
│ ├── ApiException.cs
│ ├── ApiResponse.cs
│ ├── ClientUtils.cs
│ ├── Configuration.cs
│ ├── ExceptionFactory.cs
│ ├── GlobalConfiguration.cs
│ ├── HttpMethod.cs
│ ├── IApiAccessor.cs
│ ├── IAsynchronousClient.cs
│ ├── IReadableConfiguration.cs
│ ├── ISynchronousClient.cs
│ ├── Multimap.cs
│ ├── OpenAPIDateConverter.cs
│ ├── RequestOptions.cs
│ └── RetryConfiguration.cs
├── InterrogateMethod.cs
├── InterrogateResult.cs
├── MaskedContent.cs
├── Model
│ ├── AbstractOpenAPISchema.cs
│ ├── BodyDetectControlnetDetectPost.cs
│ ├── BodyRembgRemoveRembgPost.cs
│ ├── CreateResponse.cs
│ ├── EmbeddingItem.cs
│ ├── EmbeddingsResponse.cs
│ ├── Estimation.cs
│ ├── ExtrasBatchImagesRequest.cs
│ ├── ExtrasBatchImagesResponse.cs
│ ├── ExtrasSingleImageRequest.cs
│ ├── ExtrasSingleImageResponse.cs
│ ├── FaceRestorerItem.cs
│ ├── FileData.cs
│ ├── Flags.cs
│ ├── HTTPValidationError.cs
│ ├── HypernetworkItem.cs
│ ├── ImageToImageResponse.cs
│ ├── InterrogateRequest.cs
│ ├── LatentUpscalerModeItem.cs
│ ├── LocationInner.cs
│ ├── MemoryResponse.cs
│ ├── ModulesApiModelsProgressResponse.cs
│ ├── ModulesProgressProgressResponse.cs
│ ├── Options.cs
│ ├── PNGInfoRequest.cs
│ ├── PNGInfoResponse.cs
│ ├── Person.cs
│ ├── PoseData.cs
│ ├── PredictBody.cs
│ ├── PreprocessResponse.cs
│ ├── ProgressRequest.cs
│ ├── PromptStyleItem.cs
│ ├── QuicksettingsHint.cs
│ ├── RealesrganItem.cs
│ ├── Request.cs
│ ├── ResetBody.cs
│ ├── SDModelItem.cs
│ ├── SDVaeItem.cs
│ ├── SamplerItem.cs
│ ├── ScriptArg.cs
│ ├── ScriptInfo.cs
│ ├── ScriptsList.cs
│ ├── StableDiffusionProcessingImg2Img.cs
│ ├── StableDiffusionProcessingTxt2Img.cs
│ ├── TextToImageResponse.cs
│ ├── TrainResponse.cs
│ ├── UpscalerItem.cs
│ └── ValidationError.cs
├── RemBgModels.cs
├── RemBgResult.cs
├── SamplingMethod.cs
└── SdWebUiApi.csproj
├── StableDiffusionTagManager.sln
├── StableDiffusionTagManager
├── .gitignore
├── App.axaml
├── App.axaml.cs
├── Assets
│ └── logo.ico
├── Attributes
│ ├── ServiceAttribute.cs
│ └── SupportedPlatformsAttribute.cs
├── Behaviors
│ └── CloseWindowOnEventBehavior.cs
├── Collections
│ └── OrderedSetObservableCollection.cs
├── Controls
│ ├── AdvancedImageBox.axaml
│ ├── AdvancedImageBox.axaml.cs
│ ├── HeaderControl.cs
│ ├── IDialogWithResult.cs
│ ├── ImageBoxWithControls.axaml
│ ├── ImageBoxWithControls.axaml.cs
│ ├── TagAutoCompleteBox.axaml
│ └── TagAutoCompleteBox.axaml.cs
├── Converters
│ ├── BitmapPixelSizeConverter.cs
│ ├── ColorBrushConverter.cs
│ ├── ImageViewerModeToBoolConverter.cs
│ ├── InterrogateMethodToBooleanConverter.cs
│ ├── MaskedContentToStringConverter.cs
│ ├── ReviewModeToBoolConverter.cs
│ └── TagCollectionBackgroundConverter.cs
├── Extensions
│ ├── BitmapExtensions.cs
│ ├── ByteArrayExtensions.cs
│ ├── IEnumerableExtensions.cs
│ ├── LockedFramebufferExtensions.cs
│ ├── MaskResult.cs
│ ├── PixelFormatExtensions.cs
│ └── StringExtensions.cs
├── Models
│ ├── ImageAspectRatioSet.cs
│ ├── ImageFilterMode.cs
│ ├── ImageResolution.cs
│ ├── Project.cs
│ ├── Settings.cs
│ ├── TagCategorySet.cs
│ ├── TagCollection.cs
│ ├── TagCountModel.cs
│ └── XmlSettingsFile.cs
├── Program.cs
├── Roots.xml
├── ServiceCollectionExtensions.cs
├── Services
│ ├── ComicPanelExtractor.cs
│ ├── DialogHandler.cs
│ ├── ViewModelFactory.cs
│ └── WebApiFactory.cs
├── StableDiffusionTagManager.csproj
├── Styles
│ ├── Controls
│ │ ├── Checkbox.axaml
│ │ ├── Dialog.axaml
│ │ ├── HeaderControl.axaml
│ │ ├── InputForm.axaml
│ │ ├── NumericUpDown.axaml
│ │ ├── Overlay.axaml
│ │ ├── Tag.axaml
│ │ └── Toolbar.axaml
│ ├── Icons.axaml
│ └── Styles.axaml
├── ViewLocator.cs
├── ViewModels
│ ├── CheckBoxViewModel.cs
│ ├── DefaultNaturalLanguageInterrogationViewModel.cs
│ ├── DefaultTagInterrogationViewModel.cs
│ ├── DropdownSelectItem.cs
│ ├── INaturalLanguageInterrogatorViewModelFactory.cs
│ ├── ITaggerViewModelFactory.cs
│ ├── ImageReviewViewModel.cs
│ ├── ImageWithTagsViewModel.cs
│ ├── InterrogationDialogViewModel.cs
│ ├── InterrogatorViewModel.cs
│ ├── JoyCaptionAlphaTwoNaturalLanguageInterrogationViewModel.cs
│ ├── JoyCaptionAlphaTwoTagInterrogationViewModel.cs
│ ├── JoyCaptionBetaOneNaturalLanguageInterrogationViewModel.cs
│ ├── JoyCaptionBetaOneTagInterrogationViewModel.cs
│ ├── MainWindowViewModel.cs
│ ├── TagCollectionViewModel.cs
│ ├── TagCountLetterGroupViewModel.cs
│ ├── TagCountViewModel.cs
│ ├── TagPrioritySetButtonViewModel.cs
│ ├── TagPrioritySetViewModel.cs
│ ├── TagViewModel.cs
│ ├── ViewModelBase.cs
│ ├── YOLOModelSelectorDialogViewModel.cs
│ └── YOLOModelSelectorViewModel.cs
├── Views
│ ├── ColorPickerDialog.axaml
│ ├── ColorPickerDialog.axaml.cs
│ ├── DefaultNaturalLanguageInterrogationView.axaml
│ ├── DefaultNaturalLanguageInterrogationView.axaml.cs
│ ├── DefaultTagInterrogationView.axaml
│ ├── DefaultTagInterrogationView.axaml.cs
│ ├── DropdownSelectDialog.axaml
│ ├── DropdownSelectDialog.axaml.cs
│ ├── ExpandImageDialog.axaml
│ ├── ExpandImageDialog.axaml.cs
│ ├── ImageReviewDialog.axaml
│ ├── ImageReviewDialog.axaml.cs
│ ├── ImageTouchupDialog.axaml
│ ├── ImageTouchupDialog.axaml.cs
│ ├── ImageViewerWindow.axaml
│ ├── ImageViewerWindow.axaml.cs
│ ├── InterrogationDialog.axaml
│ ├── InterrogationDialog.axaml.cs
│ ├── JoyCaptionAlphaTwoNaturalLanguageInterrogationView.axaml
│ ├── JoyCaptionAlphaTwoNaturalLanguageInterrogationView.axaml.cs
│ ├── JoyCaptionAlphaTwoTagInterrogationView.axaml
│ ├── JoyCaptionAlphaTwoTagInterrogationView.axaml.cs
│ ├── JoyCaptionBetaOneNaturalLanguageInterrogationView.axaml
│ ├── JoyCaptionBetaOneNaturalLanguageInterrogationView.axaml.cs
│ ├── JoyCaptionBetaOneTagInterrogationView.axaml
│ ├── JoyCaptionBetaOneTagInterrogationView.axaml.cs
│ ├── MainWindow.axaml
│ ├── MainWindow.axaml.cs
│ ├── NewItemNameDialog.axaml
│ ├── NewItemNameDialog.axaml.cs
│ ├── ProjectSettingsDialog.axaml
│ ├── ProjectSettingsDialog.axaml.cs
│ ├── SettingsDialog.axaml
│ ├── SettingsDialog.axaml.cs
│ ├── TagPrioritySetManagerDialog.axaml
│ ├── TagPrioritySetManagerDialog.axaml.cs
│ ├── TagSearchDialog.axaml
│ ├── TagSearchDialog.axaml.cs
│ ├── TextInputDialog.axaml
│ ├── TextInputDialog.axaml.cs
│ ├── YOLOModelSelectorDialog.axaml
│ ├── YOLOModelSelectorDialog.axaml.cs
│ ├── YOLOModelSelectorView.axaml
│ └── YOLOModelSelectorView.axaml.cs
└── app.manifest
└── TagUtil
├── FolderTagSets.cs
├── ImageData.cs
├── StringExtensions.cs
├── TagSet.cs
└── TagUtil.csproj
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "submodules/kumiko"]
2 | path = submodules/kumiko
3 | url = https://github.com/njean42/kumiko.git
4 |
--------------------------------------------------------------------------------
/docs/interrogation example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PMahern/StableDiffusionTagManager/687d4d433c96565bd5c7ea6089ddb4141da9197c/docs/interrogation example.png
--------------------------------------------------------------------------------
/docs/main window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PMahern/StableDiffusionTagManager/687d4d433c96565bd5c7ea6089ddb4141da9197c/docs/main window.png
--------------------------------------------------------------------------------
/docs/project settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PMahern/StableDiffusionTagManager/687d4d433c96565bd5c7ea6089ddb4141da9197c/docs/project settings.png
--------------------------------------------------------------------------------
/docs/settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PMahern/StableDiffusionTagManager/687d4d433c96565bd5c7ea6089ddb4141da9197c/docs/settings.png
--------------------------------------------------------------------------------
/docs/yolo mask generation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PMahern/StableDiffusionTagManager/687d4d433c96565bd5c7ea6089ddb4141da9197c/docs/yolo mask generation.png
--------------------------------------------------------------------------------
/publish.ps1:
--------------------------------------------------------------------------------
1 | $versionsuffix = "0.22.0"
2 | $projectpath = "src/StableDiffusionTagManager/StableDiffusionTagManager.csproj"
3 | $platforms = "win10-x64", "linux-x64", "osx-x64"
4 |
5 | function publish($platform) {
6 | dotnet publish $projectpath -c Release -r $platform /p:PublishSingleFile=true --version-suffix $versionsuffix -o "publish\$($platform)"
7 | }
8 |
9 | foreach($platform in $platforms) {
10 | publish($platform)
11 | }
12 |
13 |
14 | $osxzip = "publish\sdtm-osx-x64-$($versionsuffix).zip"
15 | $windowszip = "publish\sdtm-win10-x64-$($versionsuffix).zip"
16 | $linuxtemptar = "publish\temp.tar"
17 | $linuxtargz = "publish\sdtm-linux-x64-$($versionsuffix).tgz"
18 |
19 | if(Test-Path $osxzip) {
20 | Remove-Item $osxzip
21 | }
22 | if(Test-Path $windowszip) {
23 | Remove-Item $windowszip
24 | }
25 | if(Test-Path $linuxtemptar) {
26 | Remove-Item $linuxtemptar
27 | }
28 | if(Test-Path $linuxtargz) {
29 | Remove-Item $linuxtargz
30 | }
31 |
32 | $originalDir = Get-Location
33 | Set-Location .\publish\osx-x64
34 | 7z a -tzip ..\..\$osxzip "*"
35 | Set-Location $originalDir\publish\win10-x64
36 | 7z a -tzip ..\..\$windowszip "*"
37 | Set-Location $originalDir\publish\linux-x64
38 | 7z a ..\..\$linuxtemptar "*"
39 | 7z a ..\..\$linuxtargz ..\..\$linuxtemptar
40 | Remove-Item ..\..\$linuxtemptar
41 | Set-Location $originalDir
--------------------------------------------------------------------------------
/src/ImageUtil/ImageConverter.cs:
--------------------------------------------------------------------------------
1 | using SixLabors.ImageSharp;
2 |
3 | namespace ImageUtil
4 | {
5 | public static class ImageConverter
6 | {
7 | public static void ConvertImageFileToPng(string filename)
8 | {
9 | var image = Image.Load(filename);
10 |
11 | var newFileName = Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)}.png");
12 |
13 | image.Save(newFileName);
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/ImageUtil/ImageUtil.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | PreserveNewest
41 | Assets\python\%(RecursiveDir)%(FileName)%(Extension)
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/ImageUtil/Interrogation/CogVLM2Interrogator.cs:
--------------------------------------------------------------------------------
1 |
2 | using System.Runtime.InteropServices;
3 |
4 | namespace ImageUtil.Interrogation
5 | {
6 | public class CogVLM2Interrogator : INaturalLanguageInterrogator
7 | {
8 | private readonly string model;
9 | private PythonImageEngine pythonImageEngine;
10 | private bool initialized = false;
11 | private bool disposed = false;
12 |
13 | public async Task Initialize(Action updateCallBack, Action consoleCallBack)
14 | {
15 | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
16 | {
17 | throw new Exception("Attempted to initialize CogVLM2 interrogator on non linux platform. CogVLM2 is only supported on Linux.");
18 | }
19 |
20 | if (!initialized)
21 | {
22 | var relativeWorkingDirectory = Path.Join("taggers", "cogvlm2");
23 | var absoluteWorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativeWorkingDirectory);
24 | var assetDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.Join("Assets", "python", "cogvlm2"));
25 |
26 | Directory.CreateDirectory(absoluteWorkingDirectory);
27 |
28 | File.Copy(Path.Combine(assetDirectory, "interrogate.py"), Path.Join(absoluteWorkingDirectory, "interrogate.py"), true);
29 | File.Copy(Path.Combine(assetDirectory, "requirements.txt"), Path.Join(absoluteWorkingDirectory, "requirements.txt"), true);
30 |
31 | await Utility.CreateVenv(absoluteWorkingDirectory, updateCallBack, consoleCallBack, "requirements.txt");
32 |
33 | pythonImageEngine = new PythonImageEngine("interrogate.py", "", relativeWorkingDirectory, true);
34 | }
35 | initialized = true;
36 | }
37 |
38 | public async Task CaptionImage(string prompt, byte[] imageData, Action consoleCallBack)
39 | {
40 | if (!initialized)
41 | throw new InvalidOperationException("Tried to access an uninitialized CogVLM2Interrogator.");
42 |
43 | if (disposed)
44 | throw new ObjectDisposedException("Tried to access a disposed CogVLM2Interrogator.");
45 | await pythonImageEngine.SendString(prompt);
46 |
47 | await pythonImageEngine.SendImage(imageData, consoleCallBack);
48 | return await pythonImageEngine.WaitForGenerationResultString(consoleCallBack);
49 | }
50 |
51 | public void Dispose()
52 | {
53 | disposed = true;
54 | pythonImageEngine.Dispose();
55 | }
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/src/ImageUtil/Interrogation/ConfiguredInterrogationContext.cs:
--------------------------------------------------------------------------------
1 | namespace ImageUtil.Interrogation
2 | {
3 | public class ConfiguredInterrogationContext : IDisposable
4 | {
5 | bool isDisposed = false;
6 | private readonly IDisposable wrapped;
7 |
8 | public Func, Action, Task> InitializeOperation { get; }
9 | public Func, Action, Task> InterrogateOperation { get; }
10 |
11 | public ConfiguredInterrogationContext(IDisposable wrapped,
12 | Func, Action, Task> initializeOperation,
13 | Func, Action, Task> interrogateOperation)
14 | {
15 | this.wrapped = wrapped;
16 | InitializeOperation = initializeOperation;
17 | InterrogateOperation = interrogateOperation;
18 | }
19 |
20 | public void Dispose()
21 | {
22 | if(isDisposed)
23 | {
24 | throw new ObjectDisposedException("Attempted to dispose of an already disposed interrogation context.");
25 | }
26 | isDisposed = true;
27 | wrapped.Dispose();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/ImageUtil/Interrogation/INaturalLanguageInterrogator.cs:
--------------------------------------------------------------------------------
1 | namespace ImageUtil
2 | {
3 | public interface INaturalLanguageInterrogator : IDisposable
4 | {
5 | Task Initialize(Action updateCallBack, Action consoleCallBack);
6 | Task CaptionImage(TArgs args, byte[] imageData, Action consoleCallBack);
7 | }
8 | }
--------------------------------------------------------------------------------
/src/ImageUtil/Interrogation/ITagInterrogator.cs:
--------------------------------------------------------------------------------
1 | namespace ImageUtil
2 | {
3 | public interface ITagInterrogator : IDisposable
4 | {
5 | Task Initialize(Action updateCallBack, Action consoleCallBack);
6 | Task> TagImage(TArgs args, byte[] imageData, Action consoleCallBack);
7 | }
8 | }
--------------------------------------------------------------------------------
/src/ImageUtil/Interrogation/JoyCaptionPreAlpha.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace ImageUtil
4 | {
5 | public class JoyCaptionPreAlpha : INaturalLanguageInterrogator
6 | {
7 | private readonly string model;
8 | private PythonImageEngine pythonImageEngine;
9 | private bool initialized = false;
10 | private bool disposed = false;
11 |
12 | public async Task Initialize(Action updateCallBack, Action consoleCallBack)
13 | {
14 | if (!initialized)
15 | {
16 | string repoUrl = "https://huggingface.co/spaces/fancyfeast/joy-caption-pre-alpha";
17 | var absoluteWorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.Join("taggers", "joycaption"));
18 |
19 | await Utility.CloneRepo(repoUrl, absoluteWorkingDirectory, updateCallBack);
20 |
21 | File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "python", "joycaption", "interrogate.py"), Path.Join(absoluteWorkingDirectory, "interrogate.py"), true);
22 |
23 | var additionalPackages = new List { "Pillow", "spaces", "protobuf", "bitsandbytes" };
24 |
25 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
26 | {
27 | additionalPackages.Add("torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124");
28 | }
29 |
30 | await Utility.CreateVenv(absoluteWorkingDirectory, updateCallBack, consoleCallBack, "requirements.txt", additionalPackages);
31 |
32 | pythonImageEngine = new PythonImageEngine("interrogate.py", "", Path.Join("taggers", "joycaption"), true);
33 | }
34 | initialized = true;
35 | }
36 |
37 | public async Task CaptionImage(string prompt, byte[] imageData, Action consoleCallBack)
38 | {
39 | if (!initialized)
40 | throw new InvalidOperationException("Tried to access an uninitialized Joy Captioner.");
41 |
42 | if (disposed)
43 | throw new ObjectDisposedException("Tried to access a disposed Joy Captioner.");
44 |
45 | await pythonImageEngine.SendString(prompt);
46 |
47 | await pythonImageEngine.SendImage(imageData, consoleCallBack);
48 | return await pythonImageEngine.WaitForGenerationResultString(consoleCallBack);
49 | }
50 |
51 | public void Dispose()
52 | {
53 | disposed = true;
54 | pythonImageEngine.Dispose();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/ImageUtil/Interrogation/SWTagger.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System.Text.RegularExpressions;
3 |
4 | namespace ImageUtil
5 | {
6 | public class SWTagger : ITagInterrogator
7 | {
8 | private readonly string model;
9 | private PythonImageEngine pythonImageEngine;
10 | private bool initialized = false;
11 | private bool disposed = false;
12 |
13 | public SWTagger(string model)
14 | {
15 | this.model = model;
16 | }
17 |
18 | public void Dispose()
19 | {
20 | disposed = true;
21 | pythonImageEngine?.Dispose();
22 | }
23 |
24 | public async Task Initialize(Action updateCallBack, Action consoleCallBack)
25 | {
26 | if (!initialized)
27 | {
28 | string repoUrl = "https://huggingface.co/spaces/SmilingWolf/wd-tagger";
29 | var absoluteWorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.Join("taggers", "sw"));
30 |
31 | await Utility.CloneRepo(repoUrl, absoluteWorkingDirectory, updateCallBack);
32 |
33 | File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "python", "sw", "interrogate.py"), Path.Join(absoluteWorkingDirectory, "interrogate.py"), true);
34 |
35 | var additionalPackages = new List { "gradio" };
36 | await Utility.CreateVenv(absoluteWorkingDirectory, updateCallBack, consoleCallBack, "requirements.txt", additionalPackages);
37 |
38 | pythonImageEngine = new PythonImageEngine("interrogate.py", $"{model} 0.5", Path.Join("taggers", "sw"), true);
39 | }
40 | initialized = true;
41 | }
42 |
43 | public async Task> TagImage(float threshold, byte[] imageData, Action consoleCallBack)
44 | {
45 | if (!initialized)
46 | throw new InvalidOperationException("Tried to access an unitialized SW Tagger.");
47 |
48 | if (disposed)
49 | throw new ObjectDisposedException("Tried to access a disposed SW Tagger.");
50 |
51 | await pythonImageEngine.SendImage(imageData, consoleCallBack);
52 | var output = await pythonImageEngine.WaitForGenerationResultString(consoleCallBack);
53 | // We use Trim to remove any leading white spaces
54 | var match = Regex.Match(output, @"^\('([^']*)',");
55 |
56 | if (match.Success)
57 | {
58 | string listPart = match.Groups[1].Value;
59 | return new List(listPart.Split(new[] { ", " }, StringSplitOptions.None));
60 | }
61 | else
62 | {
63 | return new List();
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/ImageUtil/PythonWrapper.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Runtime.InteropServices;
3 | using System.Text;
4 |
5 | namespace ImageUtil
6 | {
7 | public static class PythonWrapper
8 | {
9 | public static async Task RunPythonScript(string scriptPath, string arguments, byte[] data, string workingdirectory, bool isvenv = false)
10 | {
11 | var sb = new StringBuilder();
12 |
13 | using (Process p = new Process())
14 | {
15 | ProcessStartInfo info = new ProcessStartInfo();
16 |
17 | var pythonExe = "python";
18 | var absoluteWorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, workingdirectory);
19 | if (isvenv)
20 | {
21 | pythonExe = Path.Join(absoluteWorkingDirectory, (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
22 | Path.Join("venv", "Scripts", "python.exe") :
23 | Path.Join("venv", "bin", "python")));
24 | }
25 |
26 | info.FileName = pythonExe;
27 | info.Arguments = $"{scriptPath} {arguments}";
28 | info.RedirectStandardInput = true;
29 | info.UseShellExecute = false;
30 | info.CreateNoWindow = true;
31 | info.WorkingDirectory = absoluteWorkingDirectory;
32 | info.RedirectStandardOutput = true;
33 | info.RedirectStandardError = true;
34 |
35 | p.OutputDataReceived += (sender, args) =>
36 | {
37 | if (args.Data != null && !string.IsNullOrWhiteSpace(args.Data))
38 | sb.AppendLine(args.Data);
39 | };
40 |
41 | p.ErrorDataReceived += (sender, args) =>
42 | {
43 | if (args.Data != null && !string.IsNullOrWhiteSpace(args.Data))
44 | sb.AppendLine(args.Data);
45 | };
46 |
47 | p.StartInfo = info;
48 | p.Start();
49 |
50 | p.BeginOutputReadLine();
51 | p.BeginErrorReadLine();
52 |
53 | try
54 | {
55 | if (data != null)
56 | {
57 | using (Stream stdin = p.StandardInput.BaseStream)
58 | {
59 | stdin.Write(data, 0, data.Length);
60 | stdin.Flush();
61 | stdin.Close();
62 | }
63 | }
64 | }
65 | catch (Exception)
66 | {
67 | throw new Exception($"Python script failed. Full output is {sb.ToString()}");
68 | }
69 |
70 | await p.WaitForExitAsync();
71 |
72 | if (p.ExitCode != 0)
73 | {
74 | throw new Exception($"Python script failed with exit code {p.ExitCode}. Full output is {sb.ToString()}");
75 | }
76 | }
77 |
78 | return sb.ToString();
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/ImageUtil/python/cogvlm2/interrogate.py:
--------------------------------------------------------------------------------
1 | """
2 | Original source taken from https://github.com/THUDM/CogVLM2/blob/main/basic_demo/cli_demo.py modified to support StableDiffusionTagManager and always load 4bit
3 | """
4 |
5 | import torch
6 | from PIL import Image
7 | from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
8 | import sys
9 | import base64
10 | from io import BytesIO
11 |
12 | MODEL_PATH = "THUDM/cogvlm2-llama3-chat-19B"
13 | DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
14 | TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[
15 | 0] >= 8 else torch.float16
16 |
17 | tokenizer = AutoTokenizer.from_pretrained(
18 | MODEL_PATH,
19 | trust_remote_code=True
20 | )
21 |
22 | model = AutoModelForCausalLM.from_pretrained(
23 | MODEL_PATH,
24 | torch_dtype=TORCH_TYPE,
25 | trust_remote_code=True,
26 | quantization_config=BitsAndBytesConfig(load_in_4bit=True),
27 | low_cpu_mem_usage=True
28 | ).eval()
29 |
30 | def main():
31 | while True:
32 | promptdata = sys.stdin.readline().strip()
33 |
34 | imagedata = sys.stdin.readline().strip()
35 | binary_data = base64.b64decode(imagedata)
36 | image_bytes = BytesIO(binary_data)
37 |
38 | with Image.open(image_bytes).convert("RGB") as image:
39 | history = []
40 |
41 | input_by_model = model.build_conversation_input_ids(
42 | tokenizer,
43 | query=promptdata,
44 | history=history,
45 | images=[image],
46 | template_version='chat'
47 | )
48 |
49 | inputs = {
50 | 'input_ids': input_by_model['input_ids'].unsqueeze(0).to(DEVICE),
51 | 'token_type_ids': input_by_model['token_type_ids'].unsqueeze(0).to(DEVICE),
52 | 'attention_mask': input_by_model['attention_mask'].unsqueeze(0).to(DEVICE),
53 | 'images': [[input_by_model['images'][0].to(DEVICE).to(TORCH_TYPE)]] if image is not None else None,
54 | }
55 |
56 | gen_kwargs = {
57 | "max_new_tokens": 2048,
58 | "pad_token_id": 128002,
59 | "top_k": 1,
60 | }
61 |
62 | with torch.no_grad():
63 | outputs = model.generate(**inputs, **gen_kwargs)
64 | outputs = outputs[:, inputs['input_ids'].shape[1]:]
65 | response = tokenizer.decode(outputs[0], skip_special_tokens=True)
66 | print("GENERATION START")
67 | print(response)
68 | print("GENERATION END")
69 | sys.stdout.flush()
70 |
71 | if __name__ == "__main__":
72 | main()
--------------------------------------------------------------------------------
/src/ImageUtil/python/cogvlm2/requirements.txt:
--------------------------------------------------------------------------------
1 | xformers
2 | torch>=2.0.0
3 | torchvision
4 | transformers>=4.40
5 | huggingface-hub>=0.23.0
6 | pillow
7 | pydantic>=2.7.1
8 | timm>=0.9.16
9 | openai>=1.30.1
10 | loguru>=0.7.2
11 | pydantic>=2.7.1
12 | einops
13 | sse-starlette>=2.1.0
14 | bitsandbytes>=0.43.1 # for int4 quantization
15 | triton
16 | accelerate
--------------------------------------------------------------------------------
/src/ImageUtil/python/sw/interrogate.py:
--------------------------------------------------------------------------------
1 | from PIL import Image
2 | import sys
3 | from app import Predictor
4 | from io import BytesIO
5 | import time
6 | import base64
7 |
8 | def main():
9 | predictor = Predictor()
10 |
11 | while True:
12 |
13 | imagedata = sys.stdin.readline().strip()
14 | binary_data = base64.b64decode(imagedata)
15 | image_bytes = BytesIO(binary_data)
16 |
17 | with Image.open(image_bytes).convert("RGBA") as img:
18 | tagresults = predictor.predict(img, sys.argv[1], float(sys.argv[2]), 0, float(sys.argv[2]), 0)
19 | print("GENERATION START")
20 | print(tagresults)
21 | print("GENERATION END")
22 | sys.stdout.flush()
23 |
24 | if __name__ == "__main__":
25 | main()
--------------------------------------------------------------------------------
/src/ImageUtil/python/utilities/requirements.txt:
--------------------------------------------------------------------------------
1 | simple-lama-inpainting
2 | ultralytics
3 | huggingface_hub
4 | torch
5 | torchvision
6 | requests
7 | dill
8 | numpy
9 | onnxruntime
10 | rembg
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/ApiException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 |
13 | namespace SdWebUiApi.Client
14 | {
15 | ///
16 | /// API Exception
17 | ///
18 | public class ApiException : Exception
19 | {
20 | ///
21 | /// Gets or sets the error code (HTTP status code)
22 | ///
23 | /// The error code (HTTP status code).
24 | public int ErrorCode { get; set; }
25 |
26 | ///
27 | /// Gets or sets the error content (body json object)
28 | ///
29 | /// The error content (Http response body).
30 | public object ErrorContent { get; private set; }
31 |
32 | ///
33 | /// Gets or sets the HTTP headers
34 | ///
35 | /// HTTP headers
36 | public Multimap Headers { get; private set; }
37 |
38 | ///
39 | /// Initializes a new instance of the class.
40 | ///
41 | public ApiException() { }
42 |
43 | ///
44 | /// Initializes a new instance of the class.
45 | ///
46 | /// HTTP status code.
47 | /// Error message.
48 | public ApiException(int errorCode, string message) : base(message)
49 | {
50 | this.ErrorCode = errorCode;
51 | }
52 |
53 | ///
54 | /// Initializes a new instance of the class.
55 | ///
56 | /// HTTP status code.
57 | /// Error message.
58 | /// Error content.
59 | /// HTTP Headers.
60 | public ApiException(int errorCode, string message, object errorContent = null, Multimap headers = null) : base(message)
61 | {
62 | this.ErrorCode = errorCode;
63 | this.ErrorContent = errorContent;
64 | this.Headers = headers;
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/ExceptionFactory.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 |
13 | namespace SdWebUiApi.Client
14 | {
15 | ///
16 | /// A delegate to ExceptionFactory method
17 | ///
18 | /// Method name
19 | /// Response
20 | /// Exceptions
21 | public delegate Exception ExceptionFactory(string methodName, IApiResponse response);
22 | }
23 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/GlobalConfiguration.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System.Collections.Generic;
12 |
13 | namespace SdWebUiApi.Client
14 | {
15 | ///
16 | /// provides a compile-time extension point for globally configuring
17 | /// API Clients.
18 | ///
19 | ///
20 | /// A customized implementation via partial class may reside in another file and may
21 | /// be excluded from automatic generation via a .openapi-generator-ignore file.
22 | ///
23 | public partial class GlobalConfiguration : Configuration
24 | {
25 | #region Private Members
26 |
27 | private static readonly object GlobalConfigSync = new { };
28 | private static IReadableConfiguration _globalConfiguration;
29 |
30 | #endregion Private Members
31 |
32 | #region Constructors
33 |
34 | ///
35 | private GlobalConfiguration()
36 | {
37 | }
38 |
39 | ///
40 | public GlobalConfiguration(IDictionary defaultHeader, IDictionary apiKey, IDictionary apiKeyPrefix, string basePath = "http://localhost:3000/api") : base(defaultHeader, apiKey, apiKeyPrefix, basePath)
41 | {
42 | }
43 |
44 | static GlobalConfiguration()
45 | {
46 | Instance = new GlobalConfiguration();
47 | }
48 |
49 | #endregion Constructors
50 |
51 | ///
52 | /// Gets or sets the default Configuration.
53 | ///
54 | /// Configuration.
55 | public static IReadableConfiguration Instance
56 | {
57 | get { return _globalConfiguration; }
58 | set
59 | {
60 | lock (GlobalConfigSync)
61 | {
62 | _globalConfiguration = value;
63 | }
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/HttpMethod.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | namespace SdWebUiApi.Client
12 | {
13 | ///
14 | /// Http methods supported by swagger
15 | ///
16 | public enum HttpMethod
17 | {
18 | /// HTTP GET request.
19 | Get,
20 | /// HTTP POST request.
21 | Post,
22 | /// HTTP PUT request.
23 | Put,
24 | /// HTTP DELETE request.
25 | Delete,
26 | /// HTTP HEAD request.
27 | Head,
28 | /// HTTP OPTIONS request.
29 | Options,
30 | /// HTTP PATCH request.
31 | Patch
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/IApiAccessor.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 |
13 | namespace SdWebUiApi.Client
14 | {
15 | ///
16 | /// Represents configuration aspects required to interact with the API endpoints.
17 | ///
18 | public interface IApiAccessor
19 | {
20 | ///
21 | /// Gets or sets the configuration object
22 | ///
23 | /// An instance of the Configuration
24 | IReadableConfiguration Configuration { get; set; }
25 |
26 | ///
27 | /// Gets the base path of the API client.
28 | ///
29 | /// The base path
30 | string GetBasePath();
31 |
32 | ///
33 | /// Provides a factory method hook for the creation of exceptions.
34 | ///
35 | ExceptionFactory ExceptionFactory { get; set; }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/OpenAPIDateConverter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 | using Newtonsoft.Json.Converters;
11 |
12 | namespace SdWebUiApi.Client
13 | {
14 | ///
15 | /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
16 | /// see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#data-types
17 | ///
18 | public class OpenAPIDateConverter : IsoDateTimeConverter
19 | {
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | public OpenAPIDateConverter()
24 | {
25 | // full-date = date-fullyear "-" date-month "-" date-mday
26 | DateTimeFormat = "yyyy-MM-dd";
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/RequestOptions.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections.Generic;
13 | using System.IO;
14 | using System.Net;
15 |
16 | namespace SdWebUiApi.Client
17 | {
18 | ///
19 | /// A container for generalized request inputs. This type allows consumers to extend the request functionality
20 | /// by abstracting away from the default (built-in) request framework (e.g. RestSharp).
21 | ///
22 | public class RequestOptions
23 | {
24 | ///
25 | /// Parameters to be bound to path parts of the Request's URL
26 | ///
27 | public Dictionary PathParameters { get; set; }
28 |
29 | ///
30 | /// Query parameters to be applied to the request.
31 | /// Keys may have 1 or more values associated.
32 | ///
33 | public Multimap QueryParameters { get; set; }
34 |
35 | ///
36 | /// Header parameters to be applied to the request.
37 | /// Keys may have 1 or more values associated.
38 | ///
39 | public Multimap HeaderParameters { get; set; }
40 |
41 | ///
42 | /// Form parameters to be sent along with the request.
43 | ///
44 | public Dictionary FormParameters { get; set; }
45 |
46 | ///
47 | /// File parameters to be sent along with the request.
48 | ///
49 | public Multimap FileParameters { get; set; }
50 |
51 | ///
52 | /// Cookies to be sent along with the request.
53 | ///
54 | public List Cookies { get; set; }
55 |
56 | ///
57 | /// Operation associated with the request path.
58 | ///
59 | public string Operation { get; set; }
60 |
61 | ///
62 | /// Index associated with the operation.
63 | ///
64 | public int OperationIndex { get; set; }
65 |
66 | ///
67 | /// Any data associated with a request body.
68 | ///
69 | public Object Data { get; set; }
70 |
71 | ///
72 | /// Constructs a new instance of
73 | ///
74 | public RequestOptions()
75 | {
76 | PathParameters = new Dictionary();
77 | QueryParameters = new Multimap();
78 | HeaderParameters = new Multimap();
79 | FormParameters = new Dictionary();
80 | FileParameters = new Multimap();
81 | Cookies = new List();
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Client/RetryConfiguration.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using Polly;
12 | using RestSharp;
13 |
14 | namespace SdWebUiApi.Client
15 | {
16 | ///
17 | /// Configuration class to set the polly retry policies to be applied to the requests.
18 | ///
19 | public static class RetryConfiguration
20 | {
21 | ///
22 | /// Retry policy
23 | ///
24 | public static Policy RetryPolicy { get; set; }
25 |
26 | ///
27 | /// Async retry policy
28 | ///
29 | public static AsyncPolicy AsyncRetryPolicy { get; set; }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/InterrogateMethod.cs:
--------------------------------------------------------------------------------
1 | namespace SdWebUiApi
2 | {
3 | public enum InterrogateMethod
4 | {
5 | Clip = 1,
6 | DeepDanBooru = 2,
7 | JoyCaption = 3
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/InterrogateResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace StableDiffusionTagManager.Models
8 | {
9 | ///
10 | /// This was needed since the generated api returns an object when calling the interrogate function on the SD WebUI.
11 | ///
12 | public class InterrogateResult
13 | {
14 | public string caption { get; set; } = "";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/MaskedContent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SdWebUiApi
8 | {
9 | public enum MaskedContent : int
10 | {
11 | Fill = 0,
12 | Original = 1,
13 | LatentNoise = 2,
14 | LatentNothing = 3
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/AbstractOpenAPISchema.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using Newtonsoft.Json;
13 | using Newtonsoft.Json.Serialization;
14 |
15 | namespace SdWebUiApi.Model
16 | {
17 | ///
18 | /// Abstract base class for oneOf, anyOf schemas in the OpenAPI specification
19 | ///
20 | public abstract partial class AbstractOpenAPISchema
21 | {
22 | ///
23 | /// Custom JSON serializer
24 | ///
25 | static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
26 | {
27 | // OpenAPI generated types generally hide default constructors.
28 | ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
29 | MissingMemberHandling = MissingMemberHandling.Error,
30 | ContractResolver = new DefaultContractResolver
31 | {
32 | NamingStrategy = new CamelCaseNamingStrategy
33 | {
34 | OverrideSpecifiedNames = false
35 | }
36 | }
37 | };
38 |
39 | ///
40 | /// Custom JSON serializer for objects with additional properties
41 | ///
42 | static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
43 | {
44 | // OpenAPI generated types generally hide default constructors.
45 | ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
46 | MissingMemberHandling = MissingMemberHandling.Ignore,
47 | ContractResolver = new DefaultContractResolver
48 | {
49 | NamingStrategy = new CamelCaseNamingStrategy
50 | {
51 | OverrideSpecifiedNames = false
52 | }
53 | }
54 | };
55 |
56 | ///
57 | /// Gets or Sets the actual instance
58 | ///
59 | public abstract Object ActualInstance { get; set; }
60 |
61 | ///
62 | /// Gets or Sets IsNullable to indicate whether the instance is nullable
63 | ///
64 | public bool IsNullable { get; protected set; }
65 |
66 | ///
67 | /// Gets or Sets the schema type, which can be either `oneOf` or `anyOf`
68 | ///
69 | public string SchemaType { get; protected set; }
70 |
71 | ///
72 | /// Converts the instance into JSON string.
73 | ///
74 | public abstract string ToJson();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/CreateResponse.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Collections.ObjectModel;
15 | using System.Linq;
16 | using System.IO;
17 | using System.Runtime.Serialization;
18 | using System.Text;
19 | using System.Text.RegularExpressions;
20 | using Newtonsoft.Json;
21 | using Newtonsoft.Json.Converters;
22 | using Newtonsoft.Json.Linq;
23 | using System.ComponentModel.DataAnnotations;
24 | using OpenAPIDateConverter = SdWebUiApi.Client.OpenAPIDateConverter;
25 |
26 | namespace SdWebUiApi.Model
27 | {
28 | ///
29 | /// CreateResponse
30 | ///
31 | [DataContract(Name = "CreateResponse")]
32 | public partial class CreateResponse : IValidatableObject
33 | {
34 | ///
35 | /// Initializes a new instance of the class.
36 | ///
37 | [JsonConstructorAttribute]
38 | protected CreateResponse() { }
39 | ///
40 | /// Initializes a new instance of the class.
41 | ///
42 | /// Response string from create embedding or hypernetwork task. (required).
43 | public CreateResponse(string info = default(string))
44 | {
45 | // to ensure "info" is required (not null)
46 | if (info == null)
47 | {
48 | throw new ArgumentNullException("info is a required property for CreateResponse and cannot be null");
49 | }
50 | this.Info = info;
51 | }
52 |
53 | ///
54 | /// Response string from create embedding or hypernetwork task.
55 | ///
56 | /// Response string from create embedding or hypernetwork task.
57 | [DataMember(Name = "info", IsRequired = true, EmitDefaultValue = true)]
58 | public string Info { get; set; }
59 |
60 | ///
61 | /// Returns the string presentation of the object
62 | ///
63 | /// String presentation of the object
64 | public override string ToString()
65 | {
66 | StringBuilder sb = new StringBuilder();
67 | sb.Append("class CreateResponse {\n");
68 | sb.Append(" Info: ").Append(Info).Append("\n");
69 | sb.Append("}\n");
70 | return sb.ToString();
71 | }
72 |
73 | ///
74 | /// Returns the JSON string presentation of the object
75 | ///
76 | /// JSON string presentation of the object
77 | public virtual string ToJson()
78 | {
79 | return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
80 | }
81 |
82 | ///
83 | /// To validate all properties of the instance
84 | ///
85 | /// Validation context
86 | /// Validation Result
87 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
88 | {
89 | yield break;
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/HTTPValidationError.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Collections.ObjectModel;
15 | using System.Linq;
16 | using System.IO;
17 | using System.Runtime.Serialization;
18 | using System.Text;
19 | using System.Text.RegularExpressions;
20 | using Newtonsoft.Json;
21 | using Newtonsoft.Json.Converters;
22 | using Newtonsoft.Json.Linq;
23 | using System.ComponentModel.DataAnnotations;
24 | using OpenAPIDateConverter = SdWebUiApi.Client.OpenAPIDateConverter;
25 |
26 | namespace SdWebUiApi.Model
27 | {
28 | ///
29 | /// HTTPValidationError
30 | ///
31 | [DataContract(Name = "HTTPValidationError")]
32 | public partial class HTTPValidationError : IValidatableObject
33 | {
34 | ///
35 | /// Initializes a new instance of the class.
36 | ///
37 | /// detail.
38 | public HTTPValidationError(List detail = default(List))
39 | {
40 | this.Detail = detail;
41 | }
42 |
43 | ///
44 | /// Gets or Sets Detail
45 | ///
46 | [DataMember(Name = "detail", EmitDefaultValue = false)]
47 | public List Detail { get; set; }
48 |
49 | ///
50 | /// Returns the string presentation of the object
51 | ///
52 | /// String presentation of the object
53 | public override string ToString()
54 | {
55 | StringBuilder sb = new StringBuilder();
56 | sb.Append("class HTTPValidationError {\n");
57 | sb.Append(" Detail: ").Append(Detail).Append("\n");
58 | sb.Append("}\n");
59 | return sb.ToString();
60 | }
61 |
62 | ///
63 | /// Returns the JSON string presentation of the object
64 | ///
65 | /// JSON string presentation of the object
66 | public virtual string ToJson()
67 | {
68 | return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
69 | }
70 |
71 | ///
72 | /// To validate all properties of the instance
73 | ///
74 | /// Validation context
75 | /// Validation Result
76 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
77 | {
78 | yield break;
79 | }
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/LatentUpscalerModeItem.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Collections.ObjectModel;
15 | using System.Linq;
16 | using System.IO;
17 | using System.Runtime.Serialization;
18 | using System.Text;
19 | using System.Text.RegularExpressions;
20 | using Newtonsoft.Json;
21 | using Newtonsoft.Json.Converters;
22 | using Newtonsoft.Json.Linq;
23 | using System.ComponentModel.DataAnnotations;
24 | using OpenAPIDateConverter = SdWebUiApi.Client.OpenAPIDateConverter;
25 |
26 | namespace SdWebUiApi.Model
27 | {
28 | ///
29 | /// LatentUpscalerModeItem
30 | ///
31 | [DataContract(Name = "LatentUpscalerModeItem")]
32 | public partial class LatentUpscalerModeItem : IValidatableObject
33 | {
34 | ///
35 | /// Initializes a new instance of the class.
36 | ///
37 | [JsonConstructorAttribute]
38 | protected LatentUpscalerModeItem() { }
39 | ///
40 | /// Initializes a new instance of the class.
41 | ///
42 | /// name (required).
43 | public LatentUpscalerModeItem(string name = default(string))
44 | {
45 | // to ensure "name" is required (not null)
46 | if (name == null)
47 | {
48 | throw new ArgumentNullException("name is a required property for LatentUpscalerModeItem and cannot be null");
49 | }
50 | this.Name = name;
51 | }
52 |
53 | ///
54 | /// Gets or Sets Name
55 | ///
56 | [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = true)]
57 | public string Name { get; set; }
58 |
59 | ///
60 | /// Returns the string presentation of the object
61 | ///
62 | /// String presentation of the object
63 | public override string ToString()
64 | {
65 | StringBuilder sb = new StringBuilder();
66 | sb.Append("class LatentUpscalerModeItem {\n");
67 | sb.Append(" Name: ").Append(Name).Append("\n");
68 | sb.Append("}\n");
69 | return sb.ToString();
70 | }
71 |
72 | ///
73 | /// Returns the JSON string presentation of the object
74 | ///
75 | /// JSON string presentation of the object
76 | public virtual string ToJson()
77 | {
78 | return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
79 | }
80 |
81 | ///
82 | /// To validate all properties of the instance
83 | ///
84 | /// Validation context
85 | /// Validation Result
86 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
87 | {
88 | yield break;
89 | }
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/PNGInfoRequest.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Collections.ObjectModel;
15 | using System.Linq;
16 | using System.IO;
17 | using System.Runtime.Serialization;
18 | using System.Text;
19 | using System.Text.RegularExpressions;
20 | using Newtonsoft.Json;
21 | using Newtonsoft.Json.Converters;
22 | using Newtonsoft.Json.Linq;
23 | using System.ComponentModel.DataAnnotations;
24 | using OpenAPIDateConverter = SdWebUiApi.Client.OpenAPIDateConverter;
25 |
26 | namespace SdWebUiApi.Model
27 | {
28 | ///
29 | /// PNGInfoRequest
30 | ///
31 | [DataContract(Name = "PNGInfoRequest")]
32 | public partial class PNGInfoRequest : IValidatableObject
33 | {
34 | ///
35 | /// Initializes a new instance of the class.
36 | ///
37 | [JsonConstructorAttribute]
38 | protected PNGInfoRequest() { }
39 | ///
40 | /// Initializes a new instance of the class.
41 | ///
42 | /// The base64 encoded PNG image (required).
43 | public PNGInfoRequest(string image = default(string))
44 | {
45 | // to ensure "image" is required (not null)
46 | if (image == null)
47 | {
48 | throw new ArgumentNullException("image is a required property for PNGInfoRequest and cannot be null");
49 | }
50 | this.Image = image;
51 | }
52 |
53 | ///
54 | /// The base64 encoded PNG image
55 | ///
56 | /// The base64 encoded PNG image
57 | [DataMember(Name = "image", IsRequired = true, EmitDefaultValue = true)]
58 | public string Image { get; set; }
59 |
60 | ///
61 | /// Returns the string presentation of the object
62 | ///
63 | /// String presentation of the object
64 | public override string ToString()
65 | {
66 | StringBuilder sb = new StringBuilder();
67 | sb.Append("class PNGInfoRequest {\n");
68 | sb.Append(" Image: ").Append(Image).Append("\n");
69 | sb.Append("}\n");
70 | return sb.ToString();
71 | }
72 |
73 | ///
74 | /// Returns the JSON string presentation of the object
75 | ///
76 | /// JSON string presentation of the object
77 | public virtual string ToJson()
78 | {
79 | return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
80 | }
81 |
82 | ///
83 | /// To validate all properties of the instance
84 | ///
85 | /// Validation context
86 | /// Validation Result
87 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
88 | {
89 | yield break;
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/PreprocessResponse.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Collections.ObjectModel;
15 | using System.Linq;
16 | using System.IO;
17 | using System.Runtime.Serialization;
18 | using System.Text;
19 | using System.Text.RegularExpressions;
20 | using Newtonsoft.Json;
21 | using Newtonsoft.Json.Converters;
22 | using Newtonsoft.Json.Linq;
23 | using System.ComponentModel.DataAnnotations;
24 | using OpenAPIDateConverter = SdWebUiApi.Client.OpenAPIDateConverter;
25 |
26 | namespace SdWebUiApi.Model
27 | {
28 | ///
29 | /// PreprocessResponse
30 | ///
31 | [DataContract(Name = "PreprocessResponse")]
32 | public partial class PreprocessResponse : IValidatableObject
33 | {
34 | ///
35 | /// Initializes a new instance of the class.
36 | ///
37 | [JsonConstructorAttribute]
38 | protected PreprocessResponse() { }
39 | ///
40 | /// Initializes a new instance of the class.
41 | ///
42 | /// Response string from preprocessing task. (required).
43 | public PreprocessResponse(string info = default(string))
44 | {
45 | // to ensure "info" is required (not null)
46 | if (info == null)
47 | {
48 | throw new ArgumentNullException("info is a required property for PreprocessResponse and cannot be null");
49 | }
50 | this.Info = info;
51 | }
52 |
53 | ///
54 | /// Response string from preprocessing task.
55 | ///
56 | /// Response string from preprocessing task.
57 | [DataMember(Name = "info", IsRequired = true, EmitDefaultValue = true)]
58 | public string Info { get; set; }
59 |
60 | ///
61 | /// Returns the string presentation of the object
62 | ///
63 | /// String presentation of the object
64 | public override string ToString()
65 | {
66 | StringBuilder sb = new StringBuilder();
67 | sb.Append("class PreprocessResponse {\n");
68 | sb.Append(" Info: ").Append(Info).Append("\n");
69 | sb.Append("}\n");
70 | return sb.ToString();
71 | }
72 |
73 | ///
74 | /// Returns the JSON string presentation of the object
75 | ///
76 | /// JSON string presentation of the object
77 | public virtual string ToJson()
78 | {
79 | return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
80 | }
81 |
82 | ///
83 | /// To validate all properties of the instance
84 | ///
85 | /// Validation context
86 | /// Validation Result
87 | IEnumerable IValidatableObject.Validate(ValidationContext validationContext)
88 | {
89 | yield break;
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/SdWebUiApi/Model/ScriptsList.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * FastAPI
3 | *
4 | * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 | *
6 | * The version of the OpenAPI document: 0.1.0
7 | * Generated by: https://github.com/openapitools/openapi-generator.git
8 | */
9 |
10 |
11 | using System;
12 | using System.Collections;
13 | using System.Collections.Generic;
14 | using System.Collections.ObjectModel;
15 | using System.Linq;
16 | using System.IO;
17 | using System.Runtime.Serialization;
18 | using System.Text;
19 | using System.Text.RegularExpressions;
20 | using Newtonsoft.Json;
21 | using Newtonsoft.Json.Converters;
22 | using Newtonsoft.Json.Linq;
23 | using System.ComponentModel.DataAnnotations;
24 | using OpenAPIDateConverter = SdWebUiApi.Client.OpenAPIDateConverter;
25 |
26 | namespace SdWebUiApi.Model
27 | {
28 | ///
29 | /// ScriptsList
30 | ///
31 | [DataContract(Name = "ScriptsList")]
32 | public partial class ScriptsList : IValidatableObject
33 | {
34 | ///
35 | /// Initializes a new instance of the class.
36 | ///
37 | /// Titles of scripts (txt2img).
38 | /// Titles of scripts (img2img).
39 | public ScriptsList(List