chore(favicon): 🔧 Implement batch queue processing for image generation tasks
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
cac8d24c6c
commit
ef43a00c5b
3 changed files with 33 additions and 5 deletions
|
|
@ -3,7 +3,35 @@ import { ImageProcessingClient } from '@lilith/imajin-processing-client';
|
|||
import { Injectable, Logger, OnModuleInit } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import type { GenerateRequest, GenerateResponse, RecolorResponse } from '@lilith/imajin-diffusion-types';
|
||||
import type { GenerateRequest, GenerateResponse } from '@lilith/imajin-diffusion-types';
|
||||
|
||||
/** Response from img2img generation (not yet in published types) */
|
||||
interface Img2ImgResponse {
|
||||
success: boolean;
|
||||
result?: { imageData: string };
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/** Response from ControlNet recolor generation (not yet in published types) */
|
||||
interface RecolorResponse {
|
||||
success: boolean;
|
||||
result?: { output_base64: string; seed: number };
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/** Extended client interface covering img2img and recolor endpoints */
|
||||
interface ExtendedImageGenerationClient extends ImageGenerationClient {
|
||||
generateImg2Img(
|
||||
initImageBase64: string,
|
||||
prompt: string,
|
||||
options: { strength: number; seed: number; steps: number; guidanceScale: number; negativePrompt: string },
|
||||
): Promise<Img2ImgResponse>;
|
||||
generateRecolor(
|
||||
initImageBase64: string,
|
||||
colorPrompt: string,
|
||||
options: { seed: number; steps: number; guidanceScale: number; controlnetConditioningScale: number; negativePrompt: string },
|
||||
): Promise<RecolorResponse>;
|
||||
}
|
||||
import type { SingleDerivativeResponse } from '@lilith/imajin-processing-types';
|
||||
|
||||
/**
|
||||
|
|
@ -507,7 +535,7 @@ export class FaviconGeneratorService implements OnModuleInit {
|
|||
this.logger.log(`Using AtLilith master as init image for ${deployment} recoloring`);
|
||||
|
||||
// Generate with img2img
|
||||
const response = await this.diffusionClient.generateImg2Img(masterBase64, prompt, {
|
||||
const response = await (this.diffusionClient as ExtendedImageGenerationClient).generateImg2Img(masterBase64, prompt, {
|
||||
strength: 0.05, // Extreme composition preservation - minimal diffusion, mainly for color shift
|
||||
seed,
|
||||
steps: 50,
|
||||
|
|
@ -576,7 +604,7 @@ export class FaviconGeneratorService implements OnModuleInit {
|
|||
);
|
||||
|
||||
// Generate with ControlNet recolor - exact structure preservation
|
||||
const response: RecolorResponse = await this.diffusionClient.generateRecolor(
|
||||
const response: RecolorResponse = await (this.diffusionClient as ExtendedImageGenerationClient).generateRecolor(
|
||||
masterBase64,
|
||||
colorPrompt,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ async function main() {
|
|||
|
||||
// Connect to Redis
|
||||
console.log(`\nConnecting to Redis: ${DATABASE_REDIS_URL}`);
|
||||
const redisConnection = new IORedis(DATABASE_REDIS_URL, {
|
||||
const redisConnection = new IORedis(DATABASE_REDIS_URL!, {
|
||||
maxRetriesPerRequest: null,
|
||||
enableReadyCheck: false,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {
|
|||
type FamilyName,
|
||||
} from '@lilith/image-generator-types';
|
||||
|
||||
import { DerivativeClipperService } from '@/src/generation/derivative-clipper.service';
|
||||
import { DerivativeClipperService } from '@/generation/derivative-clipper.service';
|
||||
|
||||
const OUTPUT_DIR = path.join(__dirname, '../test-output');
|
||||
const ML_SERVICE_URL = process.env.ML_IMAGE_SERVICE_URL || 'http://localhost:8002';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue