Skip to content

A program for generating photo previews for journalistic articles

Notifications You must be signed in to change notification settings

KyryloTurchyn/NewsImageGeneration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This programme allows to get preview images for journalistic articles from "WashingtonPost", "CNN" or "The Guardian" websites with the use of the Facebook BART text generation model, the zephyr-7b-beta promt generation model and the 8-steps SDXL-Lightning stable diffusion model.

Instalation

git clone https://github.com/KyryloTurchyn/NewsImageGeneration
pip install -r requirements.txt

Since image generation is done using CUDA, you will need to activate it. You can use the official Pytorch website, but for Windows it will probably be:

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

After that, you will need to go to the directory and run app.py

cd pythonProject
python app.py

Structure of the project

pythonProject/
│
├── Models/
│   ├── __init__.py             # Initializes the Models package
│   ├── PromptModel.py          # Module for the prompt generation model
│   ├── StableDiffusionModel.py # Module for the stable diffusion model
│   └── SummarizationModel.py   # Module for the text summarization model
│
├── static/
│   └── output.png              # Static image file for the web interface
│
├── templates/
│   └── index.html              # HTML template for the main page of the web application
│
└── Utils/
    ├── __init__.py             # Initializes the Utils package
    └── ParserClass.py          # Module with parser class
│
└── app.py                      # Main file for the Flask application
└── logic.py                    # Module containing the business logic of the application

How does it work

  1. Parsing - you pass a link to the article into the code. Then all the text from the site is parsed.
  2. Summarization - for the prompt model to generate a good prompt, we need to summarise the text.
  3. Prompting - on the basis of summery and base prompt a separate prompt is prepared in the image generation model
  4. Image Generation - the image is generated on the basis of the existing promt, which is specially generated for the preview photo.

Examples of work

Trump in ‘full sprint’ to close Biden’s money lead as legal bills mount

trump 1

Irish moonshine and the village that declared itself an outlaw republic

ireland 1

Original cover art for ‘Harry Potter and the Philosopher’s Stone’ expected to set auction record harry 1

Who was Alexei Navalny, Russian opposition leader and Putin critic? lexa 1

About

A program for generating photo previews for journalistic articles

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published