/Food-Text-Generator

Primary LanguagePythonMIT LicenseMIT

Food-Text-Generator

This app creates text captions for food images which can be used for maintaining social media of a restaurant.

A user can pass up to 9 photos as input which are then categorised into one or several food classes. After that, the information is formatted and passed to an OpenAI model which generates a corresponding text caption.

How to run the app locally 🧑‍💻

  1. Clone the repository:
git clone https://github.com/slavafive/Food-Text-Generator.git app
cd app
  1. Install yarn and run the frontend application:
yarn install
yarn start

This will start the frontend application at http://localhost:3000.

  1. Set the OpenAI API config key in api/config/config.yaml file
open_ai_key: "YOUR_API_KEY"

Note. You can view your OpenAI API keys by logging in at openai.com, then choosing API in the central menu, then clicking the avatar on top right corner and choosing the option "View API keys".

  1. Navigate to api directory and create a virtual environment there:
cd api
python3 -m venv venv
source venv/bin/activate

Make sure to use the version of Python greater than 3.9.0.

  1. Install the required dependencies:
pip3 install -r requirements.txt
  1. Launch the backend application (from the api directory):
sudo flask run
  1. Now you can go to http://localhost:3000. in your web browser and generate text captions!

Application guide 🖥

The application accepts unly URLs of photos. That is said, if you would to process a certain type of image, type its name in the browser, make a right click on it and choose the option "Copy Image Address".*

image

Then insert the copied URL into the application input field.

image

After inserting the desired URLs, click the "Generate" button. This will classify each image into one of available food classes and create an image caption describing the group of photos.

image

Note. Expect to wait up to 10 seconds for a single image to be processed.

Technical stack ⚙️

  • Frontend: HTML, CSS, JavaScript, React.js
  • Backend: Python, Flask
  • Machine Learning: langchain, transformers, nltk

Version information 🔢

  • Python: 3.10.2