File size: 1,755 Bytes
4595df6 | 1 2 3 4 5 6 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | const FireworksAPI = require('../utils/fireworks');
class CharacterGenerator {
constructor() {
this.fireworks = new FireworksAPI();
}
async generateCharacter(description) {
const prompt = `Create a detailed character portrait based on this description: ${description}.
The character should be visually distinct and interesting.
Art style: digital painting, high detail, fantasy`;
try {
const result = await this.fireworks.generateImage(prompt, {
model: 'stable-diffusion-xl-1024-v1-0',
steps: 30,
width: 512,
height: 512,
});
return {
characterImage: result.image,
description: description,
prompt: prompt,
};
} catch (error) {
console.error('Error generating character:', error);
throw error;
}
}
async generateCharacterWithFluxSchnell(description) {
// Simulating Flux Schnell functionality with optimized prompt engineering
const prompt = `flux schnell style, highly detailed character portrait, ${description},
fantasy character design, professional digital painting, intricate details,
vibrant colors, cinematic lighting, 8k resolution`;
try {
const result = await this.fireworks.generateImage(prompt, {
model: 'stable-diffusion-xl-1024-v1-0',
steps: 20, // Fewer steps for faster generation
width: 512,
height: 512,
});
return {
characterImage: result.image,
description: description,
prompt: prompt,
style: 'fluxSchnell',
};
} catch (error) {
console.error('Error generating character with Flux Schnell style:', error);
throw error;
}
}
}
module.exports = CharacterGenerator;
|