Skip to content

This repository contains code to train a YOLO object detection model to identify and extract key information from trading chart images, specifically the symbol title and last price pill.

License

Notifications You must be signed in to change notification settings

StephanAkkerman/chart-info-detector

Repository files navigation

Chart Info Detector 📈🕵️‍♂️


GitHub Actions Workflow Status License Code style: black

Introduction

This project provides a tool to detect and extract key information from trading charts, such as the symbol title and last price pill, using computer vision techniques. The tool leverages the YOLO (You Only Look Once) object detection model to accurately identify and label these elements in chart images.

The model is trained on a custom dataset of trading chart images annotated with bounding boxes around the symbol_title and last_price_pill. You can find the labelled dataset here. The following image shows an example of the training data with labeled regions:

Training Data Example Labeled Training Data

Pre-trained Model 🤖

You can find the pre-trained model available on the Huggingface Model Hub: https://huggingface.co/StephanAkkerman/chart-info-detector. With the instructions on how to use the pre-trained model.

Example Output 📊

The model detects the symbol_title and last_price_pill in trading chart images as shown below:

Example Output

The detected regions can then be further processed using OCR (Optical Character Recognition) to extract the textual information.

Table of Contents 🗂

Installation ⚙️

The required packages to run this code can be found in the requirements.txt file. To run this file, execute the following code block after cloning the repository:

pip install -r requirements.txt

or

pip install git+https://github.com/StephanAkkerman/chart-info-detector.git

Usage ⌨️

To train the YOLO model on your dataset, run the following command in your terminal:

python src/main.py

To set up wandb for it, simply run the following command before training:

wandb login

And then enable wandb in the settings with:

yolo settings wandb=True

Labelling Process (optional) 🏷️

I have already labelled a dataset of trading chart images using Label Studio which are availble on this Hugginface dataset repo: https://huggingface.co/datasets/StephanAkkerman/chart-info-yolo. If you want to label your own dataset, follow the instructions below.

After installing Label Studio using the command in the Installation section, you can start a new labelling project by running the following command in your terminal:

label-studio

Use the following XML code snippet as the labeling configuration:

<View>
  <Image name="img" value="$image"/>
  <RectangleLabels name="label" toName="img">
    <Label value="symbol_title" background="#1f77b4"/>
    <Label value="last_price_pill" background="#ff7f0e"/>
  </RectangleLabels>
</View>

Then, import your images into the project and start labelling the symbol_title and last_price_pill regions in each image. After you have finished labelling, you can export the annotations in YOLO format. To do this, go to the "Export" tab in Label Studio, select "YOLO format", and download the annotations.

Afterwards you need to clean up the exported files. Make sure that the directory structure matches the expected format for training. I have made some scripts to help with this process in the dataset_creation folder.

  1. Move the images and their corresponding .txt annotation files into a single directory structure like this:
datasets/
└── tradingview/
    ├── images/
    │   ├── train/
    │   └── val/
    └── labels/
        ├── train/
        └── val/
  1. Ensure that the data.yml file in the datasets/tradingview/ directory is correctly set up to point to the training and validation image and label directories.
  2. Verify that the class names in the data.yml file match the labels you used during annotation (symbol_title and last_price_pill).
  3. Run the align_label_files.py script in the dataset_creation folder to ensure that all images have corresponding label files and vice versa.
  4. Run check_yolo_dataset.py script in the dataset_creation folder to verify the integrity of the dataset.

Citation ✍️

If you use this project in your research, please cite as follows:

@misc{chart_info_detector_2025,
  author  = {Stephan Akkerman},
  title   = {Chart Info Detector},
  year    = {2025},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/StephanAkkerman/chart-info-detector}}
}

Contributing 🛠

Contributions are welcome! If you have a feature request, bug report, or proposal for code refactoring, please feel free to open an issue on GitHub. We appreciate your help in improving this project.
https://github.com/StephanAkkerman/chart-info-detector/graphs/contributors

License 📜

This project is licensed under the MIT License. See the LICENSE file for details.

About

This repository contains code to train a YOLO object detection model to identify and extract key information from trading chart images, specifically the symbol title and last price pill.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages