stable-diffusion-webui-forge icon indicating copy to clipboard operation
stable-diffusion-webui-forge copied to clipboard

Generation completes prematurely but still returns an image

Open Uthstar0123 opened this issue 9 months ago • 1 comments

I'm building a Telegram bot for webui_forge_cu121_torch231 that uses the API for all requests. The issue I'm encountering is that the generation process doesn't fully complete, yet it still outputs an image.

Here's my current implementation: `

async def generate_image(update: Update, context: ContextTypes.DEFAULT_TYPE): prompt = " ".join(context.args) if context.args else "random cute animal"

payload = {
    "prompt": prompt,
    "steps": 8,
    "width": 512,
    "height": 512,
    "sampler_name": "DPM++ 2M Karras"
}

await update.message.reply_text(f"🔄 Генерирую: '{prompt}'...")

try:
    response = requests.post(SD_API_URL, json=payload)
    response.raise_for_status()
    result = response.json()

    image_data = result["images"][0]
    with open("generated_image.png", "wb") as f:
        f.write(base64.b64decode(image_data))

    with open("generated_image.png", "rb") as photo:
        await update.message.reply_photo(photo=photo, caption=f"🎨 Результат: '{prompt}'")

except Exception as e:
    await update.message.reply_text(f"❌ Ошибка: {str(e)}")

`

pic

Uthstar0123 avatar Mar 24 '25 10:03 Uthstar0123

webui_forge_cu121_torch231

Did you install from the release page? Have you run the update.bat file yet?

MisterChief95 avatar Apr 09 '25 04:04 MisterChief95