Giter Site home page Giter Site logo

vgg16-pretrained-c's Introduction

VGG16-Pretrained-C

Pretrained VGG16 neural net in C language

  1. image_to_text_converter.py - convert any image in format needed by ZFC_VGG16_CPU
  2. keras_weights_converter.py - convert any VGG16 Keras weights to format needed by ZFC_VGG16_CPU
  3. values_checker.py - program to check if results are the same in Keras and in C program

Installation

gcc -O3 -fopenmp -lm ZFC_VGG16_CPU.c -o ZFC_VGG16_CPU.exe

Usage

ZFC_VGG16_CPU.exe <weights_path> <file_with_list_of_images> <output_file> <output_convolution_features_(optional)>

Example: ZFC_VGG16_CPU.exe "weights.txt" "image_list.txt" "results.txt" 1

Downloads

Weights (~800MB Compressed 7z): https://mega.nz/#!LIhjXRhQ!scgNodAkfwWIUZdTcRfmKNHjtUfUb2KiIvfvXdIe-vc

Advantages

  1. No external dependencies
  2. Cross platform
  3. Can be easily optimized for given weights with a little loss in accuracy. For example: using fixed point instead of float, using all available AVX instructions, optimized multiprocessor support, etc.
  4. Faster if you need only features from last convolution layer
  5. You can use it for infer operation with weights obtained with transfer learning

Disadvantages

  1. Slow weights reading (it should be generated in some binary file)
  2. Use own TEXT format for images and weights
  3. Not optimized

Image format

  • Text file
  • BGR order
  • Exactly 3x224x224 integers in txt file, separated by spaces.
  • See image_to_text_converter.py for details.

Weights format

  • Text file
  • Weights + Bias by levels on independent lines
  • Must contain exactly 138357544 floating point numbers
  • Can be generated from any VGG16 Keras weights with Python script: keras_weights_converter.py

Timings

  • Reading weights (all layers): 80 seconds
  • Reading weights (convolution only): 8 seconds
  • Processing one image (all layers, single core): 22 seconds
  • Processing one image (all layers, 7 cores): 6 seconds
  • Processing one image (convolution only, single core): 20 seconds
  • Processing one image (convolution only, 7 cores): 5 seconds

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.