{"id":21578287,"url":"https://github.com/stephanakkerman/chart-recognizer","last_synced_at":"2025-03-18T07:31:38.567Z","repository":{"id":232827621,"uuid":"785297118","full_name":"StephanAkkerman/chart-recognizer","owner":"StephanAkkerman","description":"Image recognition model made to recognize financial charts from social media sources.","archived":false,"fork":false,"pushed_at":"2024-04-30T18:02:55.000Z","size":603,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-02T00:56:55.415Z","etag":null,"topics":["chart","charts","finance","financial-analysis","financial-chart","financial-charts","financial-data","image-recognition","tweets","tweets-classification","twitter","x"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StephanAkkerman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-11T15:47:10.000Z","updated_at":"2024-05-03T17:59:14.536Z","dependencies_parsed_at":"2024-05-03T17:59:12.330Z","dependency_job_id":"ced22ca0-91c9-46e9-9029-5f6bdfec2537","html_url":"https://github.com/StephanAkkerman/chart-recognizer","commit_stats":null,"previous_names":["stephanakkerman/chart-recognizer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fchart-recognizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fchart-recognizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fchart-recognizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fchart-recognizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephanAkkerman","download_url":"https://codeload.github.com/StephanAkkerman/chart-recognizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244177648,"owners_count":20410993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","charts","finance","financial-analysis","financial-chart","financial-charts","financial-data","image-recognition","tweets","tweets-classification","twitter","x"],"created_at":"2024-11-24T13:10:04.083Z","updated_at":"2025-03-18T07:31:38.545Z","avatar_url":"https://github.com/StephanAkkerman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Specialized Image Model For Financial Charts\n\n![chart-recognizer banner](img/banner.png)\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/python-3.9+-blue.svg\" alt=\"Supported versions\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen\" alt=\"License\"\u003e\n  \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg src=\"https://img.shields.io/badge/code%20style-black-000000.svg\" alt=\"Code style: black\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nchart-recognizer is an image model specifically trained to recognize financial charts from social media sources. It's designed to recognize if an image posted on social media such as Twitter, is a financial chart or something else.\n\n## Introduction\n\nSocial media users post a lot of useful financial information, including their predictions of financial assets. However, it is often hard to distinguish if the images that they post also contain useful information. This model was developed to fill this gap, to recognize if an image is a financial chart. \n\nI use this model in combination with my two other projects [FinTwit-bot](https://github.com/StephanAkkerman/fintwit-bot) and [FinTwitBERT](https://huggingface.co/StephanAkkerman/FinTwitBERT-sentiment) to track market sentiment accross Twitter.\n\n## Table of Contents\n- [Datasets](#datasets)\n- [Model Details](#model-details)\n- [Model Results](#model-results)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Citation](#citation)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Datasets\nchart-recognizer has been trained on three of my datasets. So far I have not found another image dataset about financial charts. The datasets that have been used to train these models are as follows:\n- [StephanAkkerman/crypto-charts](https://huggingface.co/datasets/StephanAkkerman/crypto-charts): 4,880 images.\n- [StephanAkkerman/stock-charts](https://huggingface.co/datasets/StephanAkkerman/stock-charts): 5,203 images.\n- [StephanAkkerman/fintwit-images](https://huggingface.co/datasets/StephanAkkerman/fintwit-images): 4,579 images.\n\nI have implemented two approaches to train the model using these datasets. One, where the model loads the images in memory however this does not work for more than 10k images on 48GB of RAM. The second method unpacks all the downloaded images which does not put as much strain on the user's RAM however, this approach demands some extra storage.\n\n## Model Details\nThe model is finetuned from [Timm's efficientnet](https://huggingface.co/docs/timm/en/models/efficientnet) and has an accuracy of 97.8% on the test set.\n\n## Model Results\nThese are the latest results on the 10% test set.\n- Accuracy: 97.8\n- F1-score: 96.9\n\n## Installation\n```bash\n# Clone this repository\ngit clone https://github.com/StephanAkkerman/chart-recognizer\n# Install required packages\npip install -r requirements.txt\n```\n\n## Usage\nThe model can be found on [Huggingface](https://huggingface.co/StephanAkkerman/chart-recognizer). It can be used together with the transformers library.\n\n```python\nimport timm\nimport torch\nfrom PIL import Image\nfrom timm.data import resolve_data_config, create_transform\n\n# Load and set model to eval mode\nmodel = timm.create_model(\"hf_hub:StephanAkkerman/chart-recognizer\", pretrained=True)\nmodel.eval()\n\n# Create transform and get labels\ntransform = create_transform(**resolve_data_config(model.pretrained_cfg, model=model))\nlabels = model.pretrained_cfg[\"label_names\"]\n\n# Load and preprocess image\nimage = Image.open(\"img/examples/tweet_example.png\").convert(\"RGB\")\nx = transform(image).unsqueeze(0)\n\n# Get model output and apply softmax\nprobabilities = torch.nn.functional.softmax(model(x)[0], dim=0)\n\n# Map probabilities to labels\noutput = {label: prob.item() for label, prob in zip(labels, probabilities)}\n\n# Print the predicted probabilities\nprint(output)\n```\n\n## Citation\nIf you use chart-recognizer in your research, please cite as follows:\n\n```bibtex\n@misc{chart-recognizer,\n  author = {Stephan Akkerman},\n  title = {chart-recognizer: A Specialized Image Model for Financial Charts},\n  year = {2024},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/StephanAkkerman/chart-recognizer}}\n}\n```\n\n## Contributing\nContributions 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.\n\n## License\nThis project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanakkerman%2Fchart-recognizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanakkerman%2Fchart-recognizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanakkerman%2Fchart-recognizer/lists"}