File size: 3,269 Bytes
e9e375d
 
 
 
 
 
 
 
ac4f80f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9e375d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
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/)

---