ai-forever / Kandinsky-2

Kandinsky 2 — multilingual text2image latent diffusion model
Apache License 2.0
2.74k stars 306 forks source link

Add helpful installation information to README #19

Open maximxlss opened 1 year ago

maximxlss commented 1 year ago

Right now it's only a pip command to install kadinsky but not a word about clip or opencv. Probably should be something like this:

pip install opencv-python
pip install git+https://github.com/openai/CLIP.git
pip install git+https://github.com/ai-forever/Kandinsky-2.git
gruevy commented 1 year ago

When I run the command "pip install git+https://github.com/ai-forever/Kandinsky-2.git" no new folder is created and I don't see that anything was installed. How do I actually install and run this? Does it work in windows?

maximxlss commented 1 year ago

When I run the command "pip install git+https://github.com/ai-forever/Kandinsky-2.git" no new folder is created and I don't see that anything was installed. How do I actually install and run this? Does it work in windows?

Right now this is only an api for use in python. The command installs the library. After installation, you can run the example scripts present in the repository. If you have no experience with python, you can try out the hosted demos:

gruevy commented 1 year ago

Oh my bad, I thought it was a standalone client. Thanks!

snakers4 commented 1 year ago

Also maybe adding this to the instruction will be helpful for users running in notebooks:

pip install ipywidgets
Blucknote commented 1 year ago

@gruevy you can use my script after installation in venv https://gist.github.com/Blucknote/31f792621f4e4cdf0a7d2505ddd6b0a2

Kurskikh commented 1 year ago

Привет! не могу поставить для питон 3.11..Как можно решить эту проблему? Можете выложить sentencepiece-0.1.97-cp311-cp311-win_amd64.whl ?

Blucknote commented 1 year ago

@Kurskikh а в чём проблема? пакет не собирается? окружение чистая винда или wsl?

Kurskikh commented 1 year ago

Привет) Я разобрался с этой проблемой, поставив 10 питон..у меня код работает, но почему то при попытке сгененировать изображения ничего не происходит и я получаю варнинг PS C:\python\ & "C:/Program Files/Python310/python.exe" c:/python/bot/bot.py C:\Program Files\Python310\lib\site-packages\huggingface_hub\file_download.py:637: FutureWarning: cached_download is the legacy way to download files from the HF hub, please consider upgrading to hf_hub_download warnings.warn(

Я пытаюсь через телеграм бота реализовать получение изображений

@dp.message_handler(Command("img"), lambda message: database_turbo.is_authorized(cursor, message.from_user.id))
async def img_command(message: types.Message):
    await message.answer("Введите текстовый запрос для генерации изображения:")
    await ImageGenerationState.prompt.set()

@dp.message_handler(lambda message: message.text, state=ImageGenerationState.prompt)
async def generate_image(message: types.Message, state: FSMContext):
    text_prompt = message.text
    model = get_kandinsky2('cuda', task_type='text2img', model_version='2.1', use_flash_attention=False)
    images = model.generate_text2img(
        text_prompt,
        num_steps=100,
        batch_size=1,
        guidance_scale=4,
        h=768, w=768,
        sampler='p_sampler',
        prior_cf_scale=4,
        prior_steps="5"
    )

    # Convert the image to a format suitable for sending via Telegram
    img_data = io.BytesIO()
    images[0].save(img_data, format='JPEG')
    img_data.seek(0)

    # Send the generated image to the user
    await bot.send_photo(chat_id=message.chat.id, photo=img_data, caption="Generated image:")
    await state.finish()

Когда я ввожу команду /img далее промт, то получаю варнинг и бот зависает(

maximxlss commented 1 year ago

при попытке сгененировать изображения ничего не происходит и я получаю варнинг

Варнинг это нормально. Во-первых, модель лучше инициализировать в самом начале один раз, а во-вторых, скорее всего стоит просто подольше подождать. Во время инициализации модели долгое время нет никакого вывода.