Type error in StableDiffusionImg2ImgPipeline
Sup, i need helpWhen I run the code below, my image from the telegram bot message is saved and then loaded and converted to RGB, checked for compliance with the PIL.image.image class and then passed to StableDiffusionImg2ImgPipeline, which returns an error that the image variable does not match the PIL.image.image classasync def image_handler(update: Update, context: ContextTypes.DEFAULT_TYPE):
    user_id = str(update.message.from_user.id)
    if user_id not in user_settings:
        user_settings[user_id] = default_settings.copy()

    settings = user_settings[user_id]

    if update.message.photo:
        photo = update.message.photo[-1]
        file = await photo.get_file()
        file_path = os.path.join(image_folder, f"{user_id}_{photo.file_unique_id}.jpg")

        await file.download_to_drive(file_path)

        text = update.message.caption if update.message.caption else "masterpiece"

        image = Image.open(file_path).convert("RGB")

        # Проверка типа и размеров изображения
        if not isinstance(image, Image.Image):
            await update.message.reply_text("Error: The loaded image is not an instance of PIL.Image.Image.")
            return

        if image.size[0] == 0 or image.size[1] == 0:
            await update.message.reply_text("Error: The uploaded image has incorrect dimensions.")
            return

        scheduler = schedulers_dict[settings["scheduler"]]

        try:
            pipeline_sd = StableDiffusionImg2ImgPipeline.from_single_file(
                os.path.join(checkpoints_dir, settings["model"]),
                scheduler=scheduler,
                tokenizer=clip_tokenizer
            )
            pipeline_sd.to('cuda')

            generated_image = pipeline_sd(
                prompt=text,
                init_image=image,
                strength=settings["denoising_strength"],
                guidance_scale=settings["cfgscale"],
                num_inference_steps=settings["steps"],
            ).images[0]

            output_image = io.BytesIO()
            #generated_image.save(output_image, format='PNG')
            output_image.seek(0)

            await update.message.reply_photo(photo=output_image)

            del pipeline_sd
            torch.cuda.empty_cache()

        except Exception as e:
            await update.message.reply_text(f"Error: {str(e)} ")
            del pipeline_sd
            torch.cuda.empty_cache()
    else:
        await update.message.reply_text("Please send the image along with the text.")Error belowInput is in incorrect format. Currently, we only support 
<class 'PIL.Image.Image'>, <class 'numpy.ndarray'>, <class 'torch.Tensor'>But when I run the code separately from the bot, to change the same saved image, everything works fineimport requests
import torch
from PIL import Image
from io import BytesIO
from diffusers import DPMSolverMultistepScheduler
from diffusers import StableDiffusionImg2ImgPipeline, StableDiffusionXLImg2ImgPipeline

dpmpp2mK = DPMSolverMultistepScheduler.from_pretrained("runwayml/stable-diffusion-v1-5", subfolder="scheduler",
                                                       use_karras_sigmas=True)
device = "cuda"
model_id_or_path = "runwayml/stable-diffusion-v1-5"
pipe = StableDiffusionImg2ImgPipeline.from_single_file("F:/SDTG/models/checkpoints/cyberrealistic_v50.safetensors", torch_dtype=torch.float16)
pipe = pipe.to(device)

init_image = Image.open('image.jpg').convert("RGB")
prompt = "realistic"

images = pipe(prompt=prompt, image=init_image, strength=0.75, guidance_scale=7.5, num_inference_steps=40, scheduler=dpmpp2mK).images
images[0].save("image_out.png")I’ve been racking my brains for several days now, please tell me what my problem is?