Skip to content

This project is an AI app for haiku generation. It receives a haiku theme as an input and then gives out the generated haiku in Japanese and Russian and creates a stunning and matching ukiyo-e illustration.

Notifications You must be signed in to change notification settings

applepi17618/haiku_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 

Repository files navigation

๐ŸŽ Japanese Haiku Generator App

This is a student project that was created for traditional Japanese haiku poems generation in response to user-defined themes โ€” with translations and authentic Ukiyo-e style illustrations. The main aim was to wrap up some knowledge obtained during โ€˜LangChain for LLM Application Developmentโ€™ AI Course and practice project architecture building.


๐ŸŽฏ The Model Choice

It was decided to pick a cohere LLM model for it has an intuitively clear and coherent API. Moreover, the model demonstrates great results in creativity and handles both Russian and Japanese text generation really well.


๐ŸŒธ Features

  • ๐Ÿ–‹๏ธ Haiku Generator (in Japanese) using Cohere language models
  • ๐Ÿ“œ Automatic Russian Translation of generated haiku
  • ๐Ÿ–ผ๏ธ Ukiyo-e Style Image Generation via Stable-Diffusion 3.5 large
  • ๐Ÿง  Theme validation with simple heuristics
  • โœจ Minimalistic Streamlit UI
  • ๐Ÿ“ Modular, extensible project structure

๐ŸŒธ Example Output

Input Theme: ะขะฐะฝะฐะฑะฐั‚ะฐ

Generated Haiku (ๆ—ฅๆœฌ่ชž):

ๆ˜Ÿใ€…ไบคใ‚ใ‚‹
ๅคใฎๅคœใซใŸใชใฐใŸใฎ
ๅคขๆใไบบ

Russian Translation:

ะ—ะฒั‘ะทะดั‹ ะฟะตั€ะตะฟะปะตั‚ะฐัŽั‚ัั
ะ’ ะปะตั‚ะฝะตะน ะฝะพั‡ะธ, ะขะฐะฝะฐะฑะฐั‚ะฐ
ะ›ัŽะดะธ ั€ะธััƒัŽั‚ ะผะตั‡ั‚ั‹.

Generated Image:

2c180073d892b52ff0c628c9ecef5f3fe3e3187bf8e5e8e9ba98af3a


๐Ÿ’ป Technologies Used

Tech Description
๐Ÿ Python 3.10+ Core language
๐ŸŒ Streamlit Frontend web app
๐Ÿง  Cohere Haiku generation & translation
๐ŸŽจ Hugging Face API stable-diffusion 3.5 large image generation
๐Ÿ“ฆ dotenv Local API token management

๐Ÿ›  Installation

git clone https://github.com/yourusername/haiku-generator.git
cd haiku-generator
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt

๐Ÿ” Environment Variables

Create an .env file in the root directory containing the paramount API keys:

COHERE_API_KEY='your_cohere_key'
HF_TOKEN='your_huggingface_token'


๐Ÿš€ Running the App

streamlit run app.py

๐Ÿ“ Project Structure

haiku-generator/
โ”œโ”€โ”€ app.py -> Streamlit app entry point
โ”œโ”€โ”€ haiku_generator.py -> Japanese haiku generation (Cohere)
โ”œโ”€โ”€ russian_translation.py -> Poetic Russian translation
โ”œโ”€โ”€ ukiyo_e_generator.py -> Image generation (stable-diffusion 3.5 large)
โ”œโ”€โ”€ theme_validation.py -> Theme quality checker
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ .env


โ— Notes

A Cohere API is geo-blocked in certain regions, like Russia. So if its implementation is unavailable in your region consider using a foreign server or a VPN software.

About

This project is an AI app for haiku generation. It receives a haiku theme as an input and then gives out the generated haiku in Japanese and Russian and creates a stunning and matching ukiyo-e illustration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published