nicknochnack /
ImageClassification
Jupyter notebook showing how to build an image classifier with Python and Tensorflow
Loading repository data…
mudigosa / repository
Image Classifier Going forward, AI algorithms will be incorporated into more and more everyday applications. For example, you might want to include an image classifier in a smartphone app. To do this, you'd use a deep learning model trained on hundreds of thousands of images as part of the overall application architecture. A large part of software development in the future will be using these types of models as common parts of applications. In this project, you'll train an image classifier to recognize different species of flowers. You can imagine using something like this in a phone app that tells you the name of the flower your camera is looking at. In practice, you'd train this classifier, then export it for use in your application. We'll be using this dataset of 102 flower categories. When you've completed this project, you'll have an application that can be trained on any set of labelled images. Here your network will be learning about flowers and end up as a command line application. But, what you do with your new skills depends on your imagination and effort in building a dataset. This is the final Project of the Udacity AI with Python Nanodegree Prerequisites The Code is written in Python 3.6.5 . If you don't have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install pip run in the command Line python -m ensurepip -- default-pip to upgrade it python -m pip install -- upgrade pip setuptools wheel to upgrade Python pip install python -- upgrade Additional Packages that are required are: Numpy, Pandas, MatplotLib, Pytorch, PIL and json. You can donwload them using pip pip install numpy pandas matplotlib pil or conda conda install numpy pandas matplotlib pil In order to intall Pytorch head over to the Pytorch site select your specs and follow the instructions given. Viewing the Jyputer Notebook In order to better view and work on the jupyter Notebook I encourage you to use nbviewer . You can simply copy and paste the link to this website and you will be able to edit it without any problem. Alternatively you can clone the repository using git clone https://github.com/fotisk07/Image-Classifier/ then in the command Line type, after you have downloaded jupyter notebook type jupyter notebook locate the notebook and run it. Command Line Application Train a new network on a data set with train.py Basic Usage : python train.py data_directory Prints out current epoch, training loss, validation loss, and validation accuracy as the netowrk trains Options: Set direcotry to save checkpoints: python train.py data_dor --save_dir save_directory Choose arcitecture (alexnet, densenet121 or vgg16 available): pytnon train.py data_dir --arch "vgg16" Set hyperparameters: python train.py data_dir --learning_rate 0.001 --hidden_layer1 120 --epochs 20 Use GPU for training: python train.py data_dir --gpu gpu Predict flower name from an image with predict.py along with the probability of that name. That is you'll pass in a single image /path/to/image and return the flower name and class probability Basic usage: python predict.py /path/to/image checkpoint Options: Return top K most likely classes: python predict.py input checkpoint ---top_k 3 Use a mapping of categories to real names: python predict.py input checkpoint --category_names cat_To_name.json Use GPU for inference: python predict.py input checkpoint --gpu Json file In order for the network to print out the name of the flower a .json file is required. If you aren't familiar with json you can find information here. By using a .json file the data can be sorted into folders with numbers and those numbers will correspond to specific names specified in the .json file. Data and the json file The data used specifically for this assignemnt are a flower database are not provided in the repository as it's larger than what github allows. Nevertheless, feel free to create your own databases and train the model on them to use with your own projects. The structure of your data should be the following: The data need to comprised of 3 folders, test, train and validate. Generally the proportions should be 70% training 10% validate and 20% test. Inside the train, test and validate folders there should be folders bearing a specific number which corresponds to a specific category, clarified in the json file. For example if we have the image a.jpj and it is a rose it could be in a path like this /test/5/a.jpg and json file would be like this {...5:"rose",...}. Make sure to include a lot of photos of your catagories (more than 10) with different angles and different lighting conditions in order for the network to generalize better. GPU As the network makes use of a sophisticated deep convolutional neural network the training process is impossible to be done by a common laptop. In order to train your models to your local machine you have three options Cuda -- If you have an NVIDIA GPU then you can install CUDA from here. With Cuda you will be able to train your model however the process will still be time consuming Cloud Services -- There are many paid cloud services that let you train your models like AWS or Google Cloud Coogle Colab -- Google Colab gives you free access to a tesla K80 GPU for 12 hours at a time. Once 12 hours have ellapsed you can just reload and continue! The only limitation is that you have to upload the data to Google Drive and if the dataset is massive you may run out of space. However, once a model is trained then a normal CPU can be used for the predict.py file and you will have an answer within some seconds. Hyperparameters As you can see you have a wide selection of hyperparameters available and you can get even more by making small modifications to the code. Thus it may seem overly complicated to choose the right ones especially if the training needs at least 15 minutes to be completed. So here are some hints: By increasing the number of epochs the accuracy of the network on the training set gets better and better however be careful because if you pick a large number of epochs the network won't generalize well, that is to say it will have high accuracy on the training image and low accuracy on the test images. Eg: training for 12 epochs training accuracy: 85% Test accuracy: 82%. Training for 30 epochs training accuracy 95% test accuracy 50%. A big learning rate guarantees that the network will converge fast to a small error but it will constantly overshot A small learning rate guarantees that the network will reach greater accuracies but the learning process will take longer Densenet121 works best for images but the training process takes significantly longer than alexnet or vgg16 *My settings were lr=0.001, dropoup=0.5, epochs= 15 and my test accuracy was 86% with densenet121 as my feature extraction model. Pre-Trained Network The checkpoint.pth file contains the information of a network trained to recognise 102 different species of flowers. I has been trained with specific hyperparameters thus if you don't set them right the network will fail. In order to have a prediction for an image located in the path /path/to/image using my pretrained model you can simply type python predict.py /path/to/image checkpoint.pth Contributing Please read CONTRIBUTING.md for the process for submitting pull requests. Authors Shanmukha Mudigonda - Initial work Udacity - Final Project of the AI with Python Nanodegree
Image Classifier
I have implemeted Image classifier reconizing images of flowers using PyTorch image classification model and further converted into Command line application. AI algorithms will be incorporated into more and more everyday applications. For example, you might want to include an image classifier in a smartphone app. To do this, you'd use a deep learning model trained on hundreds of thousands of images as part of the overall application architecture. A large part of software development in the future will be using these types of models as common parts of applications.
In this project, you'll train an image classifier to recognize different species of flowers. You can imagine using something like this in a phone app that tells you the name of the flower your camera is looking at. In practice, you'd train this classifier, then export it for use in your application. We'll be using this dataset of 102 flower categories.
When you've completed this project, you'll have an application that can be trained on any set of labelled images. Here your network will be learning about flowers and end up as a command line application. But, what you do with your new skills depends on your imagination and effort in building a dataset.
This is the final Project of the Udacity AI with Python Nanodegree Prerequisites
The Code is written in Python 3.6.5 . If you don't have Python installed you can find it here. If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip.
To install pip run in the command Line
python -m ensurepip -- default-pip
to upgrade it
python -m pip install -- upgrade pip setuptools wheel
to upgrade Python
pip install python -- upgrade
Additional Packages that are required are: Numpy, Pandas, MatplotLib, Pytorch, PIL and json which can be downloaded using pip command.
pip install numpy pandas matplotlib pil
or conda
conda install numpy pandas matplotlib pil
In order to intall Pytorch head over to the Pytorch site select your specs and follow the instructions given. Viewing the Jyputer Notebook
In order to better view and work on the jupyter Notebook I encourage you to use nbviewer . You can simply copy and paste the link to this website and you will be able to edit it without any problem. Alternatively you can clone the repository using
then in the command Line type, after you have downloaded jupyter notebook type
jupyter notebook
locate the notebook and run it. Command Line Application
Train a new network on a data set with train.py
Basic Usage : python train.py data_directory
Prints out current epoch, training loss, validation loss, and validation accuracy as the netowrk trains
Options:
Set direcotry to save checkpoints: python train.py data_dor --save_dir save_directory
Choose arcitecture (alexnet, densenet121 or vgg16 available): pytnon train.py data_dir --arch "vgg16"
Set hyperparameters: python train.py data_dir --learning_rate 0.001 --hidden_layer1 120 --epochs 20
Use GPU for training: python train.py data_dir --gpu gpu
Predict flower name from an image with predict.py along with the probability of that name. That is you'll pass in a single image /path/to/image and return the flower name and class probability
Basic usage: python predict.py /path/to/image checkpoint
Options:
Return top K most likely classes: python predict.py input checkpoint ---top_k 3
Use a mapping of categories to real names: python predict.py input checkpoint --category_names cat_To_name.json
Use GPU for inference: python predict.py input checkpoint --gpu
Json file
In order for the network to print out the name of the flower a .json file is required. By using a .json file the data can be sorted into folders with numbers and those numbers will correspond to specific names specified in the .json file. Data and the json file
The data used specifically for this assignemnt are a flower database are not provided in the repository as it's larger than what github allows. Nevertheless, feel free to create your own databases and train the model on them to use with your own projects. The structure of your data should be the following: The data need to comprised of 3 folders, test, train and validate. Generally the proportions should be 70% training 10% validate and 20% test. Inside the train, test and validate folders there should be folders bearing a specific number which corresponds to a specific category, clarified in the json file. For example if we have the image a.jpj and it is a rose it could be in a path like this /test/5/a.jpg and json file would be like this {...5:"rose",...}. Make sure to include a lot of photos of your catagories (more than 10) with different angles and different lighting conditions in order for the network to generalize better. GPU
As the network makes use of a sophisticated deep convolutional neural network the training process is impossible to be done by a common laptop. In order to train your models to your local machine you have three options
Cuda -- If you have an NVIDIA GPU then you can install CUDA from here. With Cuda you will be able to train your model however the process will still be time consuming
Cloud Services -- There are many paid cloud services that let you train your models like AWS or Google Cloud
Coogle Colab -- Google Colab gives you free access to a tesla K80 GPU for 12 hours at a time. Once 12 hours have ellapsed you can just reload and continue! The only limitation is that you have to upload the data to Google Drive and if the dataset is massive you may run out of space.
However, once a model is trained then a normal CPU can be used for the predict.py file and you will have an answer within some seconds. Hyperparameters
Sample Training Command:
bash train.sh
Sample Prediction Command:
bash predict.sh
As you can see you have a wide selection of hyperparameters available and you can get even more by making small modifications to the code. Thus it may seem overly complicated to choose the right ones especially if the training needs at least 15 minutes to be completed. So here are some hints:
By increasing the number of epochs the accuracy of the network on the training set gets better and better however be careful because if you pick a large number of epochs the network won't generalize well, that is to say it will have high accuracy on the training image and low accuracy on the test images. Eg: training for 12 epochs training accuracy: 85% Test accuracy: 82%. Training for 30 epochs training accuracy 95% test accuracy 50%.
A big learning rate guarantees that the network will converge fast to a small error but it will constantly overshot
A small learning rate guarantees that the network will reach greater accuracies but the learning process will take longer
Densenet121 works best for images but the training process takes significantly longer than alexnet or vgg16
*My settings were lr=0.001, dropoup=0.5, epochs= 15 and my test accuracy was 86% with densenet121 as my feature extraction model. Pre-Trained Network
The checkpoint.pth file contains the information of a network trained to recognise 102 different species of flowers. I has been trained with specific hyperparameters thus if you don't set them right the network will fail. In order to have a prediction for an image located in the path /path/to/image using my pretrained model you can simply type python predict.py /path/to/image checkpoint.pth Contributing
Please read CONTRIBUTING.md for the process for submitting pull requests. Authors
Shanmukha Mudigonda - Initial work Udacity - Final Project of the AI with Python Nanodegree
Selected from shared topics, language and repository description—not editorial ratings.
nicknochnack /
Jupyter notebook showing how to build an image classifier with Python and Tensorflow
CAPRDZV /
论文 Hinton等的论文 Matrix capsules with EM routing - Hinton, G. E., Sabour, S. and Frosst, N. (2018) Dynamic Routing Between Capsules - Sabour, S., Frosst, N. and Hinton, G.E. (2017) Transforming Auto-encoders - Hinton, G. E., Krizhevsky, A. and Wang, S. D. (2011) A parallel computation that assigns canonical object-based frames of reference. - Hinton, G.E. (1981) Shape representation in parallel systems - Hinton, G.E. (1981) Optimizing Neural Networks that Generate Images - Tijmen Tieleman’s disseration 其他论文 Capsule Network Performance on Complex Data - Xi, E., Bing, S. and Jin, Y. (2017) Accurate reconstruction of image stimuli from human fMRI based on the decoding model with capsule network architecture - Qiao, K., Zhang, C., Wang, L., Yan, B., Chen, J., Zeng, L. and Tong, L., (2018) An Optimization View on Dynamic Routing Between Capsules - Wang, D., Liu, E. (2018) CapsuleGAN: Generative Adversarial Capsule Network Ayush Jaiswal, Wael AbdAlmageed, Premkumar Natarajan. (2018) Spectral Capsule Networks - Bahadori, M. T. (2018) 博客 Max Pechyonkin的胶囊网络入门系列: 胶囊网络背后的直觉 胶囊如何工作 囊间动态路由算法 胶囊网络架构 基于TensorFlow实现胶囊网络 Debarko De的胶囊网络教程,包括注释详尽的胶囊网络实现代码 基于CUDA为胶囊网络实现TensorFlow定制操作 Jos van de Wolfshaar的文章,定制胶囊网络运算的CUDA支持 ISI新研究:胶囊生成对抗网络 用胶囊网络替换CNN作为GAN的判别网络,在MNIST数据集上取得了比卷积GAN更好的表现 Uncovering the Intuition behind Capsule Networks and Inverse Graphic Tanay Kothari的长篇教程 A Visual Representation of Capsule Connections in Dynamic Routing Between Capsules Mike Ross的胶囊网络示意图 Capsule Networks Are Shaking up AI — Here’s How to Use Them Nick Bourdakos的介绍 Capsule Networks Explained Kendrick Tan的解释 Understanding Dynamic Routing between Capsules (Capsule Networks) Jonathan Hui的教程,包括注释详尽的基于Keras的胶囊网络实现代码 Matrix capsules with EM routing Adrian Colyer关于EM路由的文章 Capsule Networks: A Glossary Sebastian Kwiatkowski的胶囊网络术语表 Overview of awesome articles 点评三篇胶囊网络教程 视频 Geoffrey Hinton’s talk: What is wrong with convolutional neural nets? - Geoffrey Hinton在MIT. Brain & Cognitive Sciences的演讲《卷积神经网络的问题在哪里?》 Capsule Networks (CapsNets) – Tutorial - “这视频棒极了。我本希望我能把胶囊解释得这么清楚。”Geoffrey Hinton Capsule networks: overview - 胶囊网络概览,包括向量和矩阵胶囊。 Overview of awesome videos 对以上3个视频的点评。 Capsule Networks: An Improvement to Convolutional Networks Siraj Raval介绍胶囊网络的视频 动态路由实现 官方实现 Sarasra/models 《Dynamic Routing Between Capsules》论文所用的代码 TensorFlow alisure-ml/CapsNet bourdakos1/capsule-networks etendue/CapsNet_TF InnerPeace-Wu/CapsNet-tensorflow jaesik817/adv_attack_capsnet jostosh/capsnet JunYeopLee/capsule-networks laodar/tf_CapsNet leoniloris/CapsNet naturomics/CapsNet-Tensorflow rrqq/CapsNet-tensorflow-jupyter thibo73800/capsnet-traffic-sign-classifier tjiang31/CapsNet winwinJJiang/capsNet-Tensorflow PyTorch acburigo/CapsNet adambielski/CapsNet-pytorch AlexHex7/CapsNet_pytorch aliasvishnu/Capsule-Networks-Notebook-MNIST andreaazzini/capsnet.pytorch cedrickchee/capsule-net-pytorch dragen1860/CapsNet-Pytorch gram-ai/capsule-networks higgsfield/Capsule-Network-Tutorial laubonghaudoi/CapsNet_guide_PyTorch leftthomas/CapsNet nishnik/CapsNet-PyTorch tonysy/CapsuleNet-PyTorch Ujjwal-9/CapsNet Keras fengwang/minimal-capsule gusgad/capsule-GAN mitiku1/Emopy-CapsNet ruslangrimov/capsnet-with-capsulewise-convolution streamride/CapsNet-keras-imdb sunxirui310/CapsNet-Keras theblackcat102/dynamic-routing-capsule-cifar XifengGuo/CapsNet-Keras XifengGuo/CapsNet-Fashion-MNIST Chainer soskek/dynamic_routing_between_capsules Torch mrkulk/Unsupervised-Capsule-Network MXNet AaronLeong/CapsNet_Mxnet GarrickLin/Capsnet.Gluon Soonhwan-Kwon/capsnet.mxnet CNTK Southworkscom/CapsNet-CNTK Lasagne DeniskaMazur/CapsNet-Lasagne Matlab yechengxi/LightCapsNet R dfalbel/capsnet JavaScript alseambusher/capsnet.js Vulcan moothyknight/CapsNet-for-Graphics-Rendering-Optimization EM路由实现 TensorFlow gyang274/capsulesEM www0wwwjs1/Matrix-Capsules-EM-Tensorflow PyTorch shzygmyx/Matrix-Capsules-pytorch 其他资源 Capsule Networks discussion Facebook讨论组 CapsNet-Tensorflow CapsNet-Tensorflow的gitter.im讨论组 Will capsule networks replace neural networks? Quora问答“胶囊网络会取代神经网络吗?” Could GANs work with Hinton’s capsule theory? Quora问答“GAN可以应用Hinton的胶囊理论吗?” Dynamic Routing Between Capsules Kyuhwan Jung对论文《Dynamic routing between Capsules》的评论(slideshare)
Classification of Kidney Disease using CNN model in Deep Learning to classify kidney disease among Cyst, Stone, Tumor and Normal Kidney in Jupyter Notebook.
NhanPhamThanh-IT /
🍎 Fruit & vegetable image classifier using TensorFlow CNN. 18 categories, Streamlit web app, Jupyter training notebooks, modular Python code. Learn computer vision & deep learning. Automated preprocessing, metrics visualization, easy deployment. Educational ML project with clean architecture.
marcgarnica13 /
Understanding gender differences in professional European football through Machine Learning interpretability and match actions data. This repository contains the full data pipeline implemented for the study *Understanding gender differences in professional European football through Machine Learning interpretability and match actions data*. We evaluated European male, and female football players' main differential features in-match actions data under the assumption of finding significant differences and established patterns between genders. A methodology for unbiased feature extraction and objective analysis is presented based on data integration and machine learning explainability algorithms. Female (1511) and male (2700) data points were collected from event data categorized by game period and player position. Each data point included the main tactical variables supported by research and industry to evaluate and classify football styles and performance. We set up a supervised classification pipeline to predict the gender of each player by looking at their actions in the game. The comparison methodology did not include any qualitative enrichment or subjective analysis to prevent biased data enhancement or gender-related processing. The pipeline had three representative binary classification models; A logic-based Decision Trees, a probabilistic Logistic Regression and a multilevel perceptron Neural Network. Each model tried to draw the differences between male and female data points, and we extracted the results using machine learning explainability methods to understand the underlying mechanics of the models implemented. A good model predicting accuracy was consistent across the different models deployed. ## Installation Install the required python packages ``` pip install -r requirements.txt ``` To handle heterogeneity and performance efficiently, we use PySpark from [Apache Spark](https://spark.apache.org/). PySpark enables an end-user API for Spark jobs. You might want to check how to set up a local or remote Spark cluster in [their documentation](https://spark.apache.org/docs/latest/api/python/index.html). ## Repository structure This repository is organized as follows: - Preprocessed data from the two different data streams is collecting in [the data folder](data/). For the Opta files, it contains the event-based metrics computed from each match of the 2017 Women's Championship and a single file calculating the event-based metrics from the 2016 Men's Championship published [here](https://figshare.com/collections/Soccer_match_event_dataset/4415000/5). Even though we cannot publish the original data source, the two python scripts implemented to homogenize and integrate both data streams into event-based metrics are included in [the data gathering folder](data_gathering/) folder contains the graphical images and media used for the report. - The [data cleaning folder](data_cleaning/) contains descriptor scripts for both data streams and [the final integration](data_cleaning/merger.py) - [Classification](classification/) contains all the Jupyter notebooks for each model present in the experiment as well as some persistent models for testing.
A project using a Support Vector Machine (SVM) to classify images of cats and dogs, implemented in a Jupyter Notebook. It includes data preprocessing, model training, and evaluation steps.