An AI pipeline that transforms photos into poetry using computer vision and text generation.
- Take a Picture - Capture a photo using your webcam
- Generate Caption - BLIP model describes what's in the image
- Create Prompt - Truncated caption becomes the prompt
- Generate Poem - Custom-trained GPT model creates a poem from the prompt
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtpython3 model.pyThis will download poetry data and train the GPT model. But the latest checkpoint and model are saved so you don't need to retrain.
python3 main.py- Spacebar - Take a picture
- ESC - Exit and generate poem
📸 Camera → Image Saved → BLIP Caption → Prompt Extract → Poem Generation → 📄 poem.txt
- Take a picture of a sunset
- BLIP generates: "a photography of beautiful sunset over mountains"
- Prompt extracted: "beautiful sunset over"
- GPT generates a poem starting with those words
- Poem saved to
poem.txtand printed to terminal
take_pic.py- Camera capture scriptblip.py- Generates caption for the picture using BLIP and truncate it into a promptgen_poem.py- Poem generation from promptmodel.py- GPT training scriptprompt.txt- Temporary file storing the image caption promptpoem.txt- Final generated poem outputopencv_frame_0.png- Captured image
checkpoints- stores the best model and latest checkpoint during trainingscene_images- test images for BLIPframe_msg- code to generate poem on AR Glasses (Not implemented fully. For later)
- Modify prompt length in the blip.py script
- Adjust poem length with
max_new_tokensparameter
a woman with a marche to each others grasp, and it will be commanding with those pumps stove is the space he crawled with pulses of dust corrents diaper. Or more wondering thee.
Home. I Touch the time through a hollow scale of oozild left, you met an unknown. All that you there is to have gone up to watch only this drawing; the living street, you do not, you would ragge from the taste but now you naught
a man sitting at my son. He was shoved the scrowling of a patfort power. What do I say here, if they think he crawled with pulse I sleep from my piece of worms and I feel at keeping the missing, be a better through into the wall of our bares.
Exception in the day I can shone their soutches, refused her women only this she moves near with a pilphone were durapped.
Here mocks, pull them, but now God. Alway
I fine-tuned Karpathy's GPT model with the poetry dataset. Link to reference: Github