import { ComfyUIClient } from '../src/comfyui-client.js';
import { getUpscalingWorkflow } from '../src/workflows/upscaling.js';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function main() {
const host = process.env.COMFYUI_HOST || 'comfyui';
const port = process.env.COMFYUI_PORT || '8188';
const client = new ComfyUIClient(`${host}:${port}`);
try {
// Connect to ComfyUI
console.log('Connecting to ComfyUI...');
await client.connect();
console.log('Connected successfully!');
// Test upscaling with 4x-UltraSharp
console.log('\n=== Testing 4x-UltraSharp Upscaling ===');
console.log('Input image: flux_output_00001_.png');
const workflow = getUpscalingWorkflow('flux_output_00001_.png', '4x-UltraSharp.safetensors', 1.0);
console.log('Generating upscaled image...');
const images = await client.generateImage(workflow, path.join(__dirname, 'output'));
console.log('✅ Upscaled image saved:', images[0]?.path);
// Test with AnimeSharp model
console.log('\n=== Testing 4x-AnimeSharp Upscaling ===');
console.log('Input image: bg_removed_00001_.png');
const workflow2 = getUpscalingWorkflow('bg_removed_00001_.png', '4x-AnimeSharp.safetensors', 1.0);
console.log('Generating upscaled image...');
const images2 = await client.generateImage(workflow2, path.join(__dirname, 'output'));
console.log('✅ Upscaled image saved:', images2[0]?.path);
console.log('\n✅ All upscaling tests completed successfully!');
} catch (error) {
console.error('Error:', error);
} finally {
// Disconnect from ComfyUI
client.disconnect();
console.log('\nDisconnected from ComfyUI');
}
}
// Run the example
main().catch(console.error);