GithubHelp home page GithubHelp logo

azizamari / electrical_schema_recognition Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 37.17 MB

Our api can fully understand a handwritten electrical circuit (components and connections recognition)

Python 95.20% Dockerfile 4.80%

electrical_schema_recognition's Introduction

Handwritten Electrical Schema Recognition

Introduction

The interesting thing about this project is that it originated from a real problem I faced while studying electrical circuits at university, I looked for an app that can detect a handwritten schema for simulation without needing to spend time redesigning the circuit using a drag-and-drop tool. ML Process Also, I wanted to go through all the machine learning steps so I began by hand drawing a bunch of circuits for my dataset.

Data Gathering

I drew 150 images containing 6 component types (capacitor, inductor, voltage source, resistor, diode, lamp).

I uploaded them on Kaggle link.

Data labeling was done using LabelImg in YOLO format.

dataset stats

Data Preprocessing

Wrote a simple script using OpenCV to apply adaptive thresholding on all images (used simple thresholding at first but results weren’t satisfactory) and resize them all to 320x320 pixels while filling empty space with white pixels.

images pipeline

Data Augmentation

Just 150 images won’t allow the model to generalize but guess what? data augmentation saves the day. I used albuemnations library (because it also adapts the bounding boxes) to 10x the dataset by applying horizontal/ vertical flips and random rotations.

Model Training

At first, I used TensorFlow’s object detection API, I got it working but ended up using ultralytics implementation of yolov5 for better performance and faster training (easy to set up on a colab notebook to train 100epochs on GPU)

Results:

We achieved around 90% confidence in object detection

train and val graphs

Terminal Recognition

Each component has two terminal points, this didn’t require machine learning just plain old image processing.

Remove components from circuits (using their bounding boxes) and apply bitwise and like the following !circuit image & boxes image

terminal detection pipeline

I plan to use KMeans to get the exact centroids for each terminal point, K=len(components)*2

Backend API

For this, I created two simple endpoints for inference using fastapi library

api endpoints

Deployment

Built the project into a container image for use as maybe a microservice

Untitled

Node Recognition

I haven’t worked on this part of the project yet.

ps: this project is still a work in progress.

Reference: https://arxiv.org/abs/2106.11559

electrical_schema_recognition's People

Contributors

azizamari avatar

Stargazers

Laleh avatar  avatar  avatar Ilyes Arfaoui  avatar Jihed Kdiss avatar Karim Omrane avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.