Skip to content

Commit 49f1d74

Browse files
committed
Add dataset and refactor project structure
1 parent 089f736 commit 49f1d74

20 files changed

+267
-912
lines changed

.gitignore

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
circuitnet/
139+
140+
# Spyder project settings
141+
.spyderproject
142+
.spyproject
143+
144+
# Rope project settings
145+
.ropeproject
146+
147+
# mkdocs documentation
148+
/site
149+
150+
# mypy
151+
.mypy_cache/
152+
.dmypy.json
153+
dmypy.json
154+
155+
# Pyre type checker
156+
.pyre/
157+
158+
# pytype static type analyzer
159+
.pytype/
160+
161+
# Cython debug symbols
162+
cython_debug/
163+
164+
# PyCharm
165+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167+
# and can be added to the global gitignore or merged into this file. For a more nuclear
168+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
169+
#.idea/
170+
171+
# Ruff stuff:
172+
.ruff_cache/
173+
174+
# PyPI configuration file
175+
.pypirc
176+
177+
# Tensorflow models
178+
models/

README.md

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,94 @@
1414

1515
</div>
1616

17+
## Table of Contents
18+
- [Introduction](#introduction)
19+
- [Features](#features)
20+
- [Installation](#installation)
21+
- [Usage](#usage)
22+
- [Contributing](#contributing)
23+
- [License](#license)
24+
- [Contact](#contact)
25+
- [Project Structure](#project-structure)
26+
27+
## Introduction
28+
CircuitNet aims to automate the conversion of hand-drawn circuit sketches into professional circuit diagrams using deep learning. The system combines traditional image processing for component detection with a CNN for classification, achieving 90% detection and 96.5% classification accuracy across 5 common circuit components.
29+
30+
## Installation
31+
To install CircuitNet, follow these steps:
32+
33+
1. Clone the repository:
34+
```bash
35+
git clone https://github.com/aaanthonyyy/CircuitNet.git
36+
cd CircuitNet
37+
```
38+
3. Activate the virtual environment:
39+
```bash
40+
python -m venv circuitnet
41+
source circuitnet/bin/activate
42+
```
43+
5. Install the dependencies:
44+
```bash
45+
pip install -r requirements.txt
46+
```
47+
48+
49+
## License
50+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
51+
1752
## Project Overview
53+
> [!INFO]
54+
> The project is divided into 3 main components: component detection, component classification, and circuit generation. The following sections provide an overview of each component.
1855
<div align="center">
1956
<img src="https://user-images.githubusercontent.com/43044255/170146864-9e7f77e7-fd16-4c4e-9d26-26639a7e9c37.png" alt="Logo" width="600"/>
2057
</div>
58+
<br/>
2159

22-
> A deep learning algorithm is proposed to automatically convert schematic sketches into circuit diagrams. The algorithm is promising, achieving a detection accuracy of 90% and a classification accuracy of 96.5%.
60+
### Dataset
61+
The dataset used in this project consists of 3,191 images (including augmented data). The original dataset was sourced from [mahmut-aksakalli/circuit_recognizer](https://github.com/mahmut-aksakalli/circuit_recognizer/blob/master/traindata.zip) and was further augmented to improve model performance.
2362

24-
<br/>
25-
<br/>
63+
The dataset is located in the `dataset/` directory of this repository and includes:
64+
- Original circuit component images
65+
- Augmented variations of the original images
66+
- Additional handcrafted component images
2667

68+
#### Extract the dataset:
2769

28-
### Component Segmentation
70+
```bash
71+
cd dataset/
72+
tar -xzvf circuit_dataset.tar.gz
73+
```
74+
75+
### Notebooks
76+
- **neural_network.ipynb**: This notebook is where the neural network is trained to predict the circuit components.
77+
- **object_detection.ipynb**: This notebook covers the image processing algorithm used to detect circuit components.
78+
- **circuit_generation.ipynb**: This notebook takes the detected and classified components to generate an SVG/PNG of the circuit.
79+
80+
81+
### Component Classification
2982
<div align="center">
30-
<img src="https://user-images.githubusercontent.com/43044255/170148823-b921898d-1d6a-457b-8dfa-ffa2ad8d0ea7.png" alt="Logo" width="600"/>
83+
<img src="https://user-images.githubusercontent.com/43044255/170149446-d57c13f0-3ab0-4542-86c9-8a7093d11627.png" alt="Logo" width="600"/>
3184
<br/>
3285
<br/>
3386
</div>
34-
There are a variety of feature detection algorithms possible, but we opted for traditional image processing techniques due to the inavailability of labeled data.
35-
87+
The component classification model was trained using a Convolutional Neural Network (CNN) with 5 classes: resistor, capacitor, inductor, voltage source, and current source. The model achieved an accuracy of 96.5% on the test set.
3688
<br/>
3789
<br/>
3890

39-
### Classification Architecture
91+
### Component Segmentation
4092
<div align="center">
41-
<img src="https://user-images.githubusercontent.com/43044255/170149446-d57c13f0-3ab0-4542-86c9-8a7093d11627.png" alt="Logo" width="600"/>
93+
<img src="https://user-images.githubusercontent.com/43044255/170148823-b921898d-1d6a-457b-8dfa-ffa2ad8d0ea7.png" alt="Logo" width="600"/>
4294
<br/>
4395
<br/>
4496
</div>
97+
There are a variety of feature detection algorithms possible, but we opted for traditional image processing techniques due to the inavailability of labeled data.
98+
<br/>
99+
<br/>
45100

101+
### Circuit Generation
46102

47-
### Software Dependancies
48-
This project was built using the following open-source libraries:
103+
The circuit generation pipeline transforms detected components into a complete circuit diagram through a three-stage process. First, the detected and classified components are processed to establish their spatial relationships and mapped to standardized circuit elements. Next, these processed components are used to automatically generate a JSON netlist that defines all component connections while preserving the original circuit topology. Finally, this netlist is rendered into an SVG circuit diagram using a rule-based placement system, which can then be exported to PNG format for easy visualization
49104

50-
* [Numpy](https://www.numpy.org/) is an array manipulation library, used for linear algebra, Fourier transform, and random number capabilities.
51-
* [CV2](https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_image_display/py_image_display.html) is a library for computer vision tasks.
52-
* [Skimage](https://scikit-image.org/) is a library which supports image processing applications on python.
53-
* [Matplotlib](https://matplotlib.org/) is a library which generates figures and provides graphical user interface toolkit.
54-
* [Tensorflow](https://www.tensorflow.org/) is an end-to-end open source machine learning platform
55-
* [SVG Schematic](https://github.com/KenKundert/svg_schematic) is a library to build a schematic using Python to instantiate and place the symbols and wires
56-
* [Cairo SVG](https://cairosvg.org/) is a library for processing SVG in python
57-
105+
106+
#### Acknowledgements
107+
I would like to express my sincere gratitude to Dr. Akash Pooransingh, my project supervisor, for his invaluable guidance, expertise and encouragement throughout this research project. His insights into machine learning applications in electrical engineering and consistent support were instrumental in bringing this project to fruition.

dataset/circuit_dataset.tar.gz

23.9 MB
Binary file not shown.
412 KB
Loading
1.98 MB
Loading
1.85 MB
Loading
2.54 MB
Loading
2.7 MB
Loading
1.73 MB
Loading
1.37 MB
Loading

0 commit comments

Comments
 (0)