{"id":13499008,"url":"https://github.com/conan7882/GoogLeNet-Inception","last_synced_at":"2025-03-29T03:32:16.912Z","repository":{"id":201475202,"uuid":"113358331","full_name":"conan7882/GoogLeNet-Inception","owner":"conan7882","description":"TensorFlow implementation of GoogLeNet and Inception for image classification.","archived":false,"fork":false,"pushed_at":"2020-03-11T20:56:53.000Z","size":12063,"stargazers_count":282,"open_issues_count":5,"forks_count":116,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-31T17:39:07.621Z","etag":null,"topics":["cifar","googlenet","image-classification","inception","pre-trained","tensorflow"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conan7882.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-06T19:26:24.000Z","updated_at":"2024-09-23T02:04:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"10348158-38e0-41bc-a3b5-dee7570f7de1","html_url":"https://github.com/conan7882/GoogLeNet-Inception","commit_stats":null,"previous_names":["conan7882/googlenet-inception"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conan7882%2FGoogLeNet-Inception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conan7882%2FGoogLeNet-Inception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conan7882%2FGoogLeNet-Inception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conan7882%2FGoogLeNet-Inception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conan7882","download_url":"https://codeload.github.com/conan7882/GoogLeNet-Inception/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246135766,"owners_count":20729056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cifar","googlenet","image-classification","inception","pre-trained","tensorflow"],"created_at":"2024-07-31T22:00:25.851Z","updated_at":"2025-03-29T03:32:15.855Z","avatar_url":"https://github.com/conan7882.png","language":"Python","funding_links":[],"categories":["Papers\u0026Codes"],"sub_categories":["GoogleNet"],"readme":"# GoogLeNet for Image Classification\n\n- TensorFlow implementation of [Going Deeper with Convolutions](https://research.google.com/pubs/pub43022.html) (CVPR'15). \n\u003c!-- - **The inception structure** --\u003e\n- This repository contains the examples of natural image classification using pre-trained model as well as training a Inception network from scratch on [CIFAR-10](https://www.cs.toronto.edu/~kriz/cifar.html) dataset (93.64% accuracy on testing set). The pre-trained model on CIFAR-10 can be download from [here](https://www.dropbox.com/sh/kab0bzpy0zymljx/AAD2YCVm0J1Qmlor8EoPzgQda?dl=0).\n- Architecture of GoogLeNet from the paper:\n![googlenet](fig/arch.png)\n\n## Requirements\n- Python 3.3+\n- [TensorFlow 1.9+](https://www.tensorflow.org/)\n- [Numpy](http://www.numpy.org/)\n- [Scipy](https://www.scipy.org/)\n\n## Implementation Details\n\n- The GoogLeNet model is defined in [`src/nets/googlenet.py`](src/nets/googlenet.py).\n- Inception module is defined in [`src/models/inception_module.py`](src/models/inception_module.py).\n- An example of image classification using pre-trained model is in [`examples/inception_pretrained.py`](examples/inception_pretrained.py).\n- An example of train a network from scratch on CIFAR-10 is in [`examples/inception_cifar.py`](examples/inception_cifar.py).\n\nFor testing the pre-trained model\n- Images are rescaled so that the smallest side equals 224 before fed into the model. This is not the same as the original paper which is an ensemble of 7 similar models using 144 224x224 crops per image for testing. So the performance will not be as good as the original paper. \n\u003c!--- **LRN** --\u003e\n\nFor training from scratch on CIFAR-10\n- All the LRN layers are removed from the convolutional layers.\n- [Batch normalization](https://arxiv.org/abs/1502.03167) and ReLU activation are used in all the convolutional layers including the layers in Inception structure except the output layer.\n- Two auxiliary classifiers are used as mentioned in the paper, though 512 instead of 1024 hidden units are used in the two fully connected layers to reduce the computation. However, I found the results are almost the same on CIFAR-10 with and without auxiliary classifiers.\n- Since the 32 x 32 images are down-sampled to 1 x 1 before fed into `inception_5a`, this makes the multi-scale structure of inception layers less useful and harm the performance (around **80%** accuracy). To make full use of the multi-scale structures, the stride of the first convolutional layer is reduced to 1 and the first two max pooling layers are removed. The the feature map (32 x 32 x channels) will have almost the same size as described in table 1 (28 x 28 x channel) in the paper before fed into `inception_3a`. I have also tried only reduce the stride or only remove one max pooling layer. But I found the current setting provides the best performance on the testing set.\n- During training, dropout with keep probability 0.4 is applied to two fully connected layers and weight decay with 5e-4 is used as well.\n- The network is trained through Adam optimizer. Batch size is 128. The initial learning rate is 1e-3, decays to 1e-4 after 30 epochs, and finally decays to 1e-5 after 50 epochs. \n- Each color channel of the input images are subtracted by the mean value computed from the training set.\n\n\n## Usage\n### ImageNet Classification\n#### Preparation\n- Download the pre-trained parameters [here](https://www.dropbox.com/sh/axnbpd1oe92aoyd/AADpmuFIJTtxS7zkL_LZrROLa?dl=0). This is original from [here](http://www.deeplearningmodel.net/).\n- Setup path in [`examples/inception_pretrained.py`](examples/inception_pretrained.py): `PRETRINED_PATH` is the path for pre-trained model. `DATA_PATH` is the path to put testing images.\n\n#### Run\nGo to `examples/` and put test image in folder `DATA_PATH`, then run the script:\n\n```\npython inception_pretrained.py --im_name PART_OF_IMAGE_NAME\n```\n- `--im_name` is the option for image names you want to test. If the testing images are all `png` files, this can be `png`. The default setting is `.jpg`.\n- The output will be the top-5 class labels and probabilities.\n\n### Train the network on CIFAR-10\n#### Preparation\n- Download CIFAR-10 dataset from [here](https://www.cs.toronto.edu/~kriz/cifar.html)\n- Setup path in [`examples/inception_cifar.py`](examples/inception_cifar.py): `DATA_PATH` is the path to put CIFAR-10. `SAVE_PATH` is the path to save or load summary file and trained model.\n#### Train the model\nGo to `examples/` and run the script:\n\n```\npython inception_cifar.py --train \\\n  --lr LEARNING_RATE \\\n  --bsize BATCH_SIZE \\\n  --keep_prob KEEP_PROB_OF_DROPOUT \\\n  --maxepoch MAX_TRAINING_EPOCH\n```\n- Summary and model will be saved in `SAVE_PATH`. One pre-trained model on CIFAR-10  can be downloaded from [here](https://www.dropbox.com/sh/kab0bzpy0zymljx/AAD2YCVm0J1Qmlor8EoPzgQda?dl=0).\n\n#### Evaluate the model\nGo to `examples/` and put the pre-trained model in `SAVE_PATH`. Then run the script:\n\n```\npython inception_cifar.py --eval \\\n  --load PRE_TRAINED_MODEL_ID\n```\n- The pre-trained ID is epoch ID shown in the save modeled file name. The default value is `99`, which indicates the one I uploaded. \n- The output will be the accuracy of training and testing set.\n\n\n## Results\n### Image classification using pre-trained model\n- Top five predictions are shown. The probabilities are shown keeping two decimal places. Note that the pre-trained model are trained on [ImageNet](http://www.image-net.org/).\n- Result of VGG19 for the same images can be found [here](https://github.com/conan7882/VGG-tensorflow#results). \n**The pre-processing of images for both experiments are the same.** \n\n*Data Source* | *Image* | *Result* |\n|:--|:--:|:--|\n[COCO](http://cocodataset.org/#home) |\u003cimg src='data/000000000285.jpg' height='200px'\u003e| 1: probability: 1.00, label: brown bear, bruin, Ursus arctos\u003cbr\u003e2: probability: 0.00, label: ice bear, polar bear\u003cbr\u003e3: probability: 0.00, label: hyena, hyaena\u003cbr\u003e4: probability: 0.00, label: chow, chow chow\u003cbr\u003e5: probability: 0.00, label: American black bear, black bear\n[COCO](http://cocodataset.org/#home) |\u003cimg src='data/000000000724.jpg' height='200px'\u003e| 1: probability: 0.79, label: street sign\u003cbr\u003e2: probability: 0.06, label: traffic light, traffic signal, stoplight\u003cbr\u003e3: probability: 0.03, label: parking meter\u003cbr\u003e4: probability: 0.02, label: mailbox, letter box\u003cbr\u003e5: probability: 0.01, label: balloon\n[COCO](http://cocodataset.org/#home) |\u003cimg src='data/000000001584.jpg' height='200px'\u003e|1: probability: 0.94, label: trolleybus, trolley coach\u003cbr\u003e2: probability: 0.05, label: passenger car, coach, carriage\u003cbr\u003e3: probability: 0.00, label: fire engine, fire truck\u003cbr\u003e4: probability: 0.00, label: streetcar, tram, tramcar, trolley\u003cbr\u003e5: probability: 0.00, label: minibus\n[COCO](http://cocodataset.org/#home) |\u003cimg src='data/000000003845.jpg' height='200px'\u003e|1: probability: 0.35, label: burrito\u003cbr\u003e2: probability: 0.17, label: potpie\u003cbr\u003e3: probability: 0.14, label: mashed potato\u003cbr\u003e4: probability: 0.10, label: plate\u003cbr\u003e5: probability: 0.03, label: pizza, pizza pie\n[ImageNet](http://www.image-net.org/) |\u003cimg src='data/ILSVRC2017_test_00000004.jpg' height='200px'\u003e|1: probability: 1.00, label: goldfish, Carassius auratus\u003cbr\u003e2: probability: 0.00, label: rock beauty, Holocanthus tricolor\u003cbr\u003e3: probability: 0.00, label: puffer, pufferfish, blowfish, globefish\u003cbr\u003e4: probability: 0.00, label: tench, Tinca tinca\u003cbr\u003e5: probability: 0.00, label: anemone fish\nSelf Collection | \u003cimg src='data/IMG_4379.jpg' height='200px'\u003e|1: probability: 0.32, label: Egyptian cat\u003cbr\u003e2: probability: 0.30, label: tabby, tabby cat\u003cbr\u003e3: probability: 0.05, label: tiger cat\u003cbr\u003e4: probability: 0.02, label: mouse, computer mouse\u003cbr\u003e5: probability: 0.02, label: paper towel\nSelf Collection | \u003cimg src='data/IMG_7940.JPG' height='200px'\u003e|1: probability: 1.00, label: streetcar, tram, tramcar, trolley, trolley car\u003cbr\u003e2: probability: 0.00, label: passenger car, coach, carriage\u003cbr\u003e3: probability: 0.00, label: trolleybus, trolley coach, trackless trolley\u003cbr\u003e4: probability: 0.00, label: electric locomotive\u003cbr\u003e5: probability: 0.00, label: freight car\n\n### Train the network from scratch on CIFAR-10\n- [Here](https://github.com/conan7882/VGG-cifar-tf/blob/master/README.md#train-the-network-from-scratch-on-cifar-10) is a similar experiment using VGG19.\n\nlearning curve for training set \n\n![train_lc](fig/train_lc.png)\n\nlearning curve for testing set \n- The accuracy on testing set is 93.64% around 100 epochs. We can observe the slightly over-fitting behavior at the end of training.\n\n![valid_lc](fig/valid_lc.png)\n\n## Author\nQian Ge\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconan7882%2FGoogLeNet-Inception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconan7882%2FGoogLeNet-Inception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconan7882%2FGoogLeNet-Inception/lists"}