| --- |
| language: |
| - en |
| - km |
| metrics: |
| - accuracy |
| pipeline_tag: object-detection |
| --- |
| # YOLOv7 Finetuned Figure/Graph Detection Model |
|
|
| This repository provides a YOLOv7 model finetuned for detecting figures and graphs in document images, such as those found in scientific papers. The model and code are open for public use and research. |
|
|
| ## Model Overview |
|
|
| - **Base Model:** YOLOv7 |
| - **Task:** Figure/Graph detection in document images |
| - **Finetuned on:** Custom dataset of figures and graphs |
|
|
| ## Quick Start |
|
|
| ### 1. Clone the repository and install dependencies |
|
|
| ```bash |
| # Clone this repository |
| cd https://huggingface.co/vichetkao/graph_detection_model |
| python -m venv .venv |
| .\.venv\Scripts\activate |
| cd ../.. |
| pip install -r requirements.txt |
| ``` |
|
|
| ### 2. Download the Model Weights |
|
|
| Download the `best.pt` weights from this Hugging Face model page and place it in `run/train/weights/best.pt` or specify the path with `--weights`. |
|
|
| ### 3. Run Detection |
|
|
| You can run detection on your images using the provided script: |
|
|
| ```bash |
| python run_detect_testing.py --source "testing" --name testing_graph_bbox --device 0 |
| ``` |
|
|
| - `--source`: Path to your image folder or file (default: `testing`) |
| - `--weights`: (Optional) Path to your model weights (`best.pt`) |
| - `--device`: Set to `0` for GPU or `cpu` for CPU inference |
|
|
| ### 4. Output |
|
|
| - Results will be saved in `run/detect/testing_graph_bbox` |
| - YOLO label files will be in `run/detect/testing_graph_bbox/labels` |
|
|
| ## Example Detection Results |
|
|
| Below are some example detection results from the model: |
|
|
| <p align="center"> |
| <img src="run/detect/testing_graph_bbox/92.png" alt="Detection Example 92" width="350"/> |
| <img src="run/detect/testing_graph_bbox/145.png" alt="Detection Example 145" width="350"/> |
| <img src="run/detect/testing_graph_bbox/188.png" alt="Detection Example 188" width="350"/> |
| </p> |
| |
| ## Evaluation Results |
|
|
| The following plots show the evaluation metrics and analysis of the model's performance: |
|
|
| <p align="center"> |
| <img src="evaluation/evaluation_bar.png" alt="Overall Detection Results" width="400"/> |
| <img src="evaluation/evaluation_gt_vs_pred.png" alt="GT vs Predicted Boxes per Image" width="400"/> |
| <img src="evaluation/evaluation_per_image_hist.png" alt="Distribution of TP, FP, FN per Image" width="400"/> |
| <img src="evaluation/evaluation_per_language.png" alt="Detection Results by Language Group" width="400"/> |
| </p> |
| |
| ```python |
| import subprocess |
| subprocess.call([ |
| "python", "run_detect_testing.py", |
| "--source", "testing", |
| "--weights", "run/train/weights/best.pt", |
| "--device", "0" |
| ]) |
| ``` |
|
|
| ## Files |
|
|
| - `run_detect_testing.py`: Main script to run detection |
| - `detect.py`: YOLOv7 detection logic |
| - `requirements.txt`: Python dependencies |
| - `run_detect_testing.bat`: Windows batch file for quick testing |
|
|
| ## Citation |
|
|
| If you use this model, please cite the original YOLOv7 paper and this repository. |
|
|
| ## License & Credits |
|
|
| This project is released under an open-source license for research and educational use. |
|
|
| --- |
|
|
| ## Author & Credits |
|
|
| **Author:** Kao Vichet |
| Bachelor Student, Cambodia Academy of Digital Technology |
| AI Full Stack Developer Internship, Techo Startup Center |
| LinkedIn: [https://www.linkedin.com/in/vichet-kao/](https://www.linkedin.com/in/vichet-kao/) |
|
|
| --- |