GithubHelp home page GithubHelp logo

gavinconran / artnet Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 448.2 MB

An Art Image Classifier fine-tuned from pre-trained Convolutional Neural Networks

Python 16.51% Shell 0.09% Jupyter Notebook 14.09% C++ 0.08% CSS 4.07% R 0.32% Julia 1.15% Java 60.22% HTML 3.41% GAP 0.06%
tensorflow tensorboard art test-driven-development neural-networks deep-learning client-server docker-container digital-signal-processing differential-equations probability stochastic-processes calculus backpropagation linear-algebra graph-algorithms optimization programming-languages

artnet's Introduction

ArtNet

Introduction

Out of a general interest in the Arts & Humanities I found myself studying Ancient Greek and Latin, Greek and Roman Mythology, Ancient Greek History, Ancient Philosophy, Arab-Islamic History, Japanese and Classical Music in addition to following the BBC's multitude of excellent arts and history programs. To further my knowledge of Artificial Intelligence I took courses, such as Digital Signal Processing, Image & Video Processing, Advanced Software Construction in Java, Advanced C++, Machine Learning, Robotics, Cloud Computing, Analytics in Python and Data Modelling.

ArtNet successfully combines my interests in the arts & sciences, in particular Art & Artificial Intelligence, and brings together my study and work of the last couple of years into a single piece of research, marking a personal learning milestone.

Create the ArtNet Model using TensorFlow

This repository contains the paper "ArtNet:An Art Image Classifier fine-tuned from pre-trained Convolutional Neural Networks" together with supporting documentation and code.

To replicate the best performing model, as described in the paper, you must first install TensorFlow, preferably in a virtual environment [https://www.tensorflow.org/install/install_linux].

Once TensorFlow is installed and the virtual environment activated, run the shell script:

(tensorflow) $ ./retrainHub_InceptionV4.sh

at the command line, which in turn calls the python program, retrain.py.

The above script trains, validates and tests an ArtNet model and the test images discussed in the paper can be replicated by executing the following Jupyter Notebook, ArtNet_Classification.ipynb, found in the ArtNet_Clients directory, along with the test data folder, dataTestPaper.

N.B.: The results will be different from the paper due to the use of the 'Hub' version of retrain.py. I used the pre-Hub version of retrain.py when writing the paper. That said, the generated ArtNet model is valid and should have an accuracy very close to that described in the paper.

Training and validation progress can be visualised by using tensorboard by executing the following command

(tensorflow) $ tensorboard --logdir=./models

Deploy a Model Server using TensorFlow

To setup a Model Server I refer the reader to the online tutorial [https://www.tensorflow.org/serving/setup]. It is possible to intall the prerequisites using two options:

  1. by pip (install pre-compiled binaries)
  2. by bazel (compile from source)

The following instructions will use pip.

To start the server execute the following command at the command line:

(tensorflow) $ tensorflow_model_server --port=9000 --model_name=artnet --model_base_path=/path/to/model/

N.B.: /path/to/model/ is the absolute path to the model directory (which in my case is the models directory, as above)

I have provided a script, ArtNet_Client.py, for users to test the ArtNet server. It can be found in the directory ArtNet_Clients. To operate:

(tensorflow) $ python ArtNet_Client.py --server=localhost:9000 \
--image=./dataPaperTest/1454_VirginAndChild_Rogier_van_der_Weyden.jpeg 

Deploy the ArtNet Server using TensorFlow in a Docker Container

To setup an ArtNet Docker Image please refer to ArtNet_Docker/README.md.

Once you have created the docker image, $USER/artnet_serving, you can run the associated container with the following command:

$ docker run -p 9000:9000 -it $USER/artnet_serving
root@854459658fb4:/# tensorflow_model_server --port=9000 --model_name=artnet --model_base_path=/ArtNet/models &> artnet_log &

In a new terminal, query the ArtNet server

cd ArtNet_Clients
$ python ArtNet_Client.py --server=localhost:9000 \
--image=./dataPaperTest/1454_VirginAndChild_Rogier_van_der_Weyden.jpeg 

The image, $USER/artnet_serving, can be deployed to a serving cluster with Kubernetes in the Google Cloud Platform as described in [https://www.tensorflow.org/serving/serving_inception].

Extend TensorFlow by creating a new Op

As a pedagogical exercise I added a new Op, called CopyOfInputOp, by following the instructions in [https://www.tensorflow.org/extend/adding_an_op]. The new op is a very simple operation that just returns the input. The files can be found in the directory TensorFlow_Extend. The source code must be compiled on your own machine and can be done by executing the following script in the TensorFlow_Extend directory:

(tensorflow) $  ./compileCopyOfInputOp.sh

To create an ArtNet model using this new Op, run the shell script:

(tensorflow) $ ./retrainHub_InceptionV4_Extend.sh

at the command line, which in turn calls the python program, retrain_Extend.py.

Training and validation progress can be visualised by using tensorboard by executing the following command

(tensorflow) $ tensorboard --logdir=./models/CopyOfInputOp

Note:

When running ArtNet_Classification.ipynb with the ArtNet model created with the new op, the following lines of code must be included in the notebook:

model_file = "../models/CopyOfInputOp/output_graph.pb"
label_file = "../models/CopyOfInputOp/output_labels.txt"
tf.load_op_library('../TensorFlow_Extend/copy_of_input.so')

artnet's People

Contributors

gavinconran avatar

Stargazers

Karthik N avatar

Watchers

 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.