Machine vision without using neural nets

Hi,
I am sharing my work on computer vision using logic. I have used jetson nano / orin nano to implement the idea. Thanks for helping me with my forum posts. Please take a look at my github repo called pyrebel and pyrebel-ml. There is a demo program in the repo. Let me know what you think about the project.

Thanks,

1 Like

Demo of image abstraction. https://www.youtube.com/watch?v=F13Qj7SjQGY

Demo of pattern recognition. https://youtu.be/MvGt38nTpzE

This video demonstrates pattern recognition. The program does not use neural nets instead uses an image abstraction technique in which the model is trained using very few datasets. In this case, the model (knowledge base) is trained (learned) using a single image of each alphabets and the program recognizes novel inputs.

Thanks,

I’m just curious if the GPU is used at all, and maybe what the CPU load looks like?

When i run the jtop utility i see that the CPU load is around 25 percent and the GPU load is around 40 percent. This is the output of tegrastats at a moment

11-10-2024 09:54:57 RAM 2574/7620MB (lfb 6x4MB) SWAP 0/3810MB (cached 0MB) CPU [25%@1510,14%@1510,22%@1510,19%@1510,19%@883,12%@883] GR3D_FREQ 31% [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] VDD_IN 6509mW/6349mW VDD_CPU_GPU_CV 1315mW/1175mW VDD_SOC 1837mW/1817mW

The GPU is responsible for processing the images and forming abstract representation while CPU is responsible for taking that abstract representation and running the learning and inference routines. The demo program takes on 320x240 pixels camera stream. I am sure you could run the program and test for yourself.

Thanks,

You run
python3 pyvision.py --learn <filename.png> or <path/to/learn/> --layer <layers> for learning a symbol/pattern.
For example,
python3 pyvision.py --layer 30 --learn images/hand-alphabet/ for learning all alphabets in the hand-alphabet directory.

You run
python3 pyvision.py --recognize <filename.png> --layer <layers> for recognizing a single image.
or
python3 pyvision.py --recognize 1 --camera 1 --layer <layers> for recognizing the camera stream.

The value of “layers” may be tweaked. It is the depth at the which the abstract representation is formed. I give it 30. It works for example alphabet images.

Hi all,
This is a demo of edge detection achieved using data abstraction.

Run the following commands,
git clone https://github.com/ps-nithin/pyrebel
cd pyrebel
python3 pyvision_edge_detection.py --preprocess <filename>

For eq. python3 pyvision_edge_detection.py --preprocess images/wildlife.jpg
Running the above program will show the edges in the image.


1 Like

Hi,
This is a jupyter / google colab notebook of edge detection algorithm with no jetson specific dependencies.
https://github.com/ps-nithin/pyrebel/blob/main/pyvision_edge_detection.ipynb

Thanks,

1 Like

Hi,
I have created a python library that implements the idea of abstraction of data.

You can now install the library with
pip install pyrebel

To run the demo programs you may have to clone the github repository https://github.com/ps-nithin/pyrebel. There you can find the demo programs.

You can run,

  1. The image abstraction demo with
    python3 pyrebel_main.py --input images/abc.png

  2. The edge detection demo with
    python3 pyrebel_main_edge.py --input images/wildlife.jpg

The output is saved to ‘output.png’.

Thanks,

Hi,
There is now a pattern recognition demo. First, you have to update the package by running,
pip install pyrebel --upgrade or pip install pyrebel==1.0.2

Run the demo program by running,

  1. Learning
    Usage: python3 pyrebel_main_learn.py --learn /path/to/image/directory/

    For eq. running python3 pyrebel_main_learn.py --learn images/letters_standard/ learns all the images in the directory and links the filename with the signatures.

  2. Recognition
    Usage: python3 pyrebel_main_learn.py --recognize <filename>

    For eq. running python3 pyrebel_main_learn.py --recognize images/letters_ripple/c_ripple.png displays the symbols recognized.

To reset the knowledge base just delete file ‘know_base.pkl’ in the current working directory.
The program expects a single pattern in the input image.

Thanks,

Hi,
This is a demo of learning and recognition of patterns.
https://youtu.be/4B4QZWxQ4kA

Thanks,

Hi,
This is a demo of forming a 2D sketch from the input image.
Below is a sample input.
python3 pyrebel_main_vision.py --input photo.jpg --edge_threshold 5 --bound_threshold 100 --abs_threshold 20

Input image 1 :

Less abstract output 1:

Input image 2 :

python3 pyrebel_main_vision.py --input photo2.jpg --abs_threshold 100 --edge_threshold 1 --bound_threshold 2000

More abstract output 2 :

You could tweak the output by changing --edge_threshold (Default 5), --abs_threshold (Default 10), and --bound_threshold (Default 100).
Thanks,

Hi,
This is a demo of abstract painting. It paints the output of edge detection.

Usage : python3 pyrebel_main_paint.py --input <filename>

This is a sample input.

This is the output.

You could tweak the output by changing --edge_threshold and also by changing the value of n(defaults to 20) in pyrebel_main_paint.py. The above output was obtained using --edge_threshold 30 and n=50

Thanks,

Hi,

How does the program learn and recognize patterns? See here

Thanks,