Skip to content

Commit 97f05eb

Browse files
committed
Fix workflows + add support for hidream
1 parent 003eefb commit 97f05eb

File tree

7 files changed

+18
-111
lines changed

7 files changed

+18
-111
lines changed

AiServer.ServiceInterface/GenerationServices.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ public static async Task<GenerationResponse> ProcessSyncGenerationAsync(this Cre
298298

299299
var completedResponse = new GenerationResponse { };
300300

301-
// Wait for the job to complete max 1 minute
302-
var timeout = DateTime.UtcNow.AddMinutes(1);
301+
// Wait for the job to complete max 20 minutes
302+
var timeout = DateTime.UtcNow.AddSeconds(job.Job?.TimeoutSecs ?? 20 * 60);
303303
while (queuedJob?.Job?.State is not (BackgroundJobState.Completed or BackgroundJobState.Cancelled
304-
or BackgroundJobState.Failed) && DateTime.UtcNow < timeout)
304+
or BackgroundJobState.Failed) && DateTime.UtcNow < timeout)
305305
{
306306
await Task.Delay(1000);
307307
queuedJob = jobs.GetJob(diffResponse.Id);

AiServer.ServiceInterface/VideoServices.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static async Task<ArtifactGenerationResponse> ProcessSyncTransformAsync(t
374374

375375
var completedResponse = new ArtifactGenerationResponse();
376376

377-
// Wait for the job to complete max 1 minute
377+
// Wait for the job to complete max 20 minutes
378378
var timeout = DateTime.UtcNow.AddSeconds(job.Job?.TimeoutSecs ?? 20 * 60);
379379
while (queuedJob?.Job?.State is not (
380380
BackgroundJobState.Completed or BackgroundJobState.Cancelled or BackgroundJobState.Failed)

AiServer.ServiceModel/Types/Generations.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public class MediaModel : IHasId<string>
144144
public int? Steps { get; set; }
145145
public string? NegativePrompt { get; set; }
146146
public ModelType? ModelType { get; set; }
147+
public string? Filename { get; set; }
148+
public string? Workflow { get; set; }
147149
/// <summary>
148150
/// Flag for models that are pulled down when run for the first time
149151
/// Keys are the ProviderId strings

AiServer/Configure.AppHost.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@ public void Configure(IWebHostBuilder builder) => builder
5757
services.AddSingleton<CustomOpenAiProvider>();
5858
services.AddSingleton<AiProviderFactory>();
5959

60-
services.AddSingleton(new ComfyMediaProviderOptions
61-
{
62-
TextToImageModelOverrides = new Dictionary<string, string>
63-
{
64-
["flux1-schnell.safetensors"] = "flux1/text_to_image.json",
65-
["sd3.5_large_fp8_scaled.safetensors"] = "sd35/text_to_image.json"
66-
}
67-
});
60+
services.AddSingleton(new ComfyMediaProviderOptions());
61+
6862
services.AddSingleton<ComfyProvider>();
6963
services.AddSingleton<ReplicateAiProvider>();
7064
services.AddSingleton<OpenAiMediaProvider>();

AiServer/Configure.BackgroundJobs.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AiServer.ServiceInterface;
2+
using AiServer.ServiceInterface.Generation;
23
using AiServer.ServiceInterface.Recurring;
34
using ServiceStack.Data;
45
using ServiceStack.Jobs;
@@ -32,6 +33,12 @@ public void Configure(IWebHostBuilder builder) => builder
3233
using var db = services.GetRequiredService<IDbConnectionFactory>().OpenDbConnection();
3334
AppData.Instance.Reload(db);
3435

36+
var mediaOptions = services.GetRequiredService<ComfyMediaProviderOptions>();
37+
foreach (var model in AppData.Instance.MediaModels.Where(x => x.Filename != null && x.Workflow != null))
38+
{
39+
mediaOptions.TextToImageModelOverrides[model.Filename!] = model.Workflow!;
40+
}
41+
3542
var jobs = services.GetRequiredService<IBackgroundJobs>();
3643
// #if DEBUG
3744
// jobs.RecurringCommand<LogCommand>("Every Minute", Schedule.EveryMinute, new() {

AiServer/workflows/hidream/text_to_image.json

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,6 @@
9797
},
9898
"widgets_values": []
9999
},
100-
{
101-
"id": 72,
102-
"type": "MarkdownNote",
103-
"pos": [
104-
1250,
105-
-130
106-
],
107-
"size": [
108-
320,
109-
360
110-
],
111-
"flags": {},
112-
"order": 1,
113-
"mode": 0,
114-
"inputs": [],
115-
"outputs": [],
116-
"title": "Sampling Settings",
117-
"properties": {},
118-
"widgets_values": [
119-
"## Official sampling settings\n\nProvided for reference, my workflows may have slightly different settings.\n\n### HiDream Full\n\n* hidream_i1_full_fp16.safetensors\n* shift: 3.0\n* steps: 50\n* sampler: uni_pc\n* scheduler: simple\n* cfg: 5.0\n\n### HiDream Dev\n\n* hidream_i1_dev_bf16.safetensors\n* shift: 6.0\n* steps: 28\n* sampler: lcm\n* scheduler: normal\n* cfg: 1.0 (no negative prompt)\n\n### HiDream Fast\n\n* hidream_i1_fast_bf16.safetensors\n* shift: 3.0\n* steps: 16\n* sampler: lcm\n* scheduler: normal\n* cfg: 1.0 (no negative prompt)\n"
120-
],
121-
"color": "#432",
122-
"bgcolor": "#653"
123-
},
124100
{
125101
"id": 40,
126102
"type": "CLIPTextEncode",
@@ -211,75 +187,6 @@
211187
"ComfyUI"
212188
]
213189
},
214-
{
215-
"id": 79,
216-
"type": "MarkdownNote",
217-
"pos": [
218-
-100,
219-
-110
220-
],
221-
"size": [
222-
240,
223-
120
224-
],
225-
"flags": {},
226-
"order": 2,
227-
"mode": 0,
228-
"inputs": [],
229-
"outputs": [],
230-
"properties": {},
231-
"widgets_values": [
232-
"You can try changing the weight_dtype to fp8 if you are running out of memory.\n\nDownload one of diffusion Models file [here](https://huggingface.co/Comfy-Org/HiDream-I1_ComfyUI/tree/main/split_files/diffusion_models)\n\nPut it in the **ComfyUI/models/diffusion_models** directory"
233-
],
234-
"color": "#432",
235-
"bgcolor": "#653"
236-
},
237-
{
238-
"id": 78,
239-
"type": "MarkdownNote",
240-
"pos": [
241-
-100,
242-
50
243-
],
244-
"size": [
245-
220,
246-
120
247-
],
248-
"flags": {},
249-
"order": 3,
250-
"mode": 0,
251-
"inputs": [],
252-
"outputs": [],
253-
"properties": {},
254-
"widgets_values": [
255-
"Download all of the text_encoders models [here](https://huggingface.co/Comfy-Org/HiDream-I1_ComfyUI/tree/main/split_files/text_encoders)\n\nPut them in the **ComfyUI/models/clip** directory"
256-
],
257-
"color": "#432",
258-
"bgcolor": "#653"
259-
},
260-
{
261-
"id": 80,
262-
"type": "MarkdownNote",
263-
"pos": [
264-
-100,
265-
230
266-
],
267-
"size": [
268-
210,
269-
88
270-
],
271-
"flags": {},
272-
"order": 4,
273-
"mode": 0,
274-
"inputs": [],
275-
"outputs": [],
276-
"properties": {},
277-
"widgets_values": [
278-
"Download the VAE model [here](https://huggingface.co/Comfy-Org/HiDream-I1_ComfyUI/blob/main/split_files/vae/ae.safetensors) \n\nPut it in the **ComfyUI/models/vae** directory"
279-
],
280-
"color": "#432",
281-
"bgcolor": "#653"
282-
},
283190
{
284191
"id": 70,
285192
"type": "ModelSamplingSD3",

AiServer/wwwroot/lib/data/media-models.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"sampler": "dpmpp_2m_sde_gpu",
4444
"width": 1024,
4545
"height": 1024,
46-
"type": "sd3",
4746
"url": "https://civitai.com/models/194768?modelVersionId=1031794",
4847
"downloadUrl": "https://civitai.com/api/download/models/1031794?type=Model&format=SafeTensor&size=pruned&fp=fp16"
4948
},
@@ -68,7 +67,7 @@
6867
"sampler": "euler",
6968
"width": 1024,
7069
"height": 1024,
71-
"type": "flux1",
70+
"workflow": "flux1/text_to_image.json",
7271
"downloadApiKeyVar": "HF_TOKEN",
7372
"url": "https://huggingface.co/black-forest-labs/FLUX.1-schnell",
7473
"downloadUrl": "https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors?download=true",
@@ -94,7 +93,7 @@
9493
"sampler": "lcm",
9594
"width": 1024,
9695
"height": 1024,
97-
"type": "hidream",
96+
"workflow": "hidream/text_to_image.json",
9897
"url": "https://comfyanonymous.github.io/ComfyUI_examples/hidream/",
9998
"downloadUrl": "https://huggingface.co/Comfy-Org/HiDream-I1_ComfyUI/resolve/main/split_files/diffusion_models/hidream_i1_dev_fp8.safetensors?download=true"
10099
},
@@ -116,7 +115,6 @@
116115
"sampler": "dpmpp_2m",
117116
"width": 1024,
118117
"height": 1024,
119-
"type": "sd3",
120118
"url": "https://huggingface.co/stabilityai/stable-diffusion-3.5-large",
121119
"downloadUrl": "https://huggingface.co/stabilityai/stable-diffusion-3.5-large/resolve/main/sd3.5_large.safetensors?download=true"
122120
},
@@ -138,7 +136,7 @@
138136
"sampler": "dpmpp_2m",
139137
"width": 1024,
140138
"height": 1024,
141-
"type": "sd3",
139+
"workflow": "sd35/text_to_image.json",
142140
"url": "https://huggingface.co/stabilityai/stable-diffusion-3.5-large-turbo",
143141
"downloadUrl": "https://huggingface.co/stabilityai/stable-diffusion-3.5-large-turbo/resolve/main/sd3.5_large_turbo.safetensors?download=true"
144142
},
@@ -161,7 +159,6 @@
161159
"sampler": "euler",
162160
"width": 1024,
163161
"height": 1024,
164-
"type": "sd3",
165162
"url": "https://huggingface.co/Comfy-Org/stable-diffusion-3.5-fp8",
166163
"downloadUrl": "https://huggingface.co/Comfy-Org/stable-diffusion-3.5-fp8/resolve/main/sd3.5_large_fp8_scaled.safetensors?download=true"
167164
},

0 commit comments

Comments
 (0)