• Stars
    star
    193
  • Rank 201,081 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Keras code and weights files for the VGG16-places365 and VGG16-hybrid1365 CNNs for scene classification

Keras | VGG16 Places365 - VGG16 CNN models pre-trained on Places365-Standard for scene classification

Keras logo

license Tweet

You have just found the Keras models of the pre-trained VGG16 CNNs on Places365-Standard (~1.8 million images from 365 scene categories).

Overview

CNNs trained on Places365 database (latest subset of Places2 Database) could be directly used for scene recognition, while the deep scene features from the higher level layer of CNN could be used as generic features for visual recognition.

Paper

The Keras models has been obtained by directly converting the Caffe models provived by the authors (all the original Caffe-based resources can be found there).

More details about the architecture of the networks can be found in the following paper:

Places: A 10 million Image Database for Scene Recognition
Zhou, B., Lapedriza, A., Khosla, A., Oliva, A., & Torralba, A.
IEEE Transactions on Pattern Analysis and Machine Intelligence

Please consider citing the above paper if you use the pre-trained CNN models.

Contents:

This repository contains code for the following Keras models:

  • VGG16-places365
  • VGG16-hybrid1365

Usage:

All architectures are compatible with both TensorFlow and Theano, and upon instantiation the models will be built according to the image dimension ordering set in your Keras configuration file at ~/.keras/keras.json. For instance, if you have set image_dim_ordering=tf, then any model loaded from this repository will get built according to the TensorFlow dimension ordering convention, "Width-Height-Depth".

Pre-trained weights can be automatically loaded upon instantiation (weights='places' argument in model constructor for all image models). Weights are automatically downloaded.

Examples

Classify Places classes with VGG16-places365

import os
import urllib2
import numpy as np
from PIL import Image
from cv2 import resize

from vgg16_places_365 import VGG16_Places365

TEST_IMAGE_URL = 'http://places2.csail.mit.edu/imgs/demo/6.jpg'

image = Image.open(urllib2.urlopen(TEST_IMAGE_URL))
image = np.array(image, dtype=np.uint8)
image = resize(image, (224, 224))
image = np.expand_dims(image, 0)

model = VGG16_Places365(weights='places')
predictions_to_return = 5
preds = model.predict(image)[0]
top_preds = np.argsort(preds)[::-1][0:predictions_to_return]

# load the class label
file_name = 'categories_places365.txt'
if not os.access(file_name, os.W_OK):
    synset_url = 'https://raw.githubusercontent.com/csailvision/places365/master/categories_places365.txt'
    os.system('wget ' + synset_url)
classes = list()
with open(file_name) as class_file:
    for line in class_file:
        classes.append(line.strip().split(' ')[0][3:])
classes = tuple(classes)

print('--SCENE CATEGORIES:')
# output the prediction
for i in range(0, 5):
    print(classes[top_preds[i]])

# --PREDICTED SCENE CATEGORIES:
# cafeteria
# food_court
# restaurant_patio
# banquet_hall
# restaurant

Extract features from images with VGG16-hybrid1365

import urllib2
import numpy as np
from PIL import Image
from cv2 import resize

from vgg16_hybrid_places_1365 import VGG16_Hybrid_1365

TEST_IMAGE_URL = 'http://places2.csail.mit.edu/imgs/demo/6.jpg'

image = Image.open(urllib2.urlopen(TEST_IMAGE_URL))
image = np.array(image, dtype=np.uint8)
image = resize(image, (224, 224))
image = np.expand_dims(image, 0)

model = VGG16_Hybrid_1365(weights='places', include_top=False)
features = model.predict(image)

References

Additionally, don't forget to cite this repo if you use these models:

@misc{gkallia2017keras_places365,
title={Keras-VGG16-Places365},
author={Grigorios Kalliatakis},
year={2017},
publisher={GitHub},
howpublished={\url{https://github.com/GKalliatakis/Keras-VGG16-places365}},
}

Licensing

We are always interested in how these models are being used, so if you found them useful or plan to make a release of code based on or using this package, it would be great to hear from you.

Where to get other trained models?

More info on downloading, converting, and submitting other models can be found on the main Keras | Application Zoo repository.

Questions and Comments

If you have any suggestions or bugs to report you can pull a request or start a discussion.


More Repositories

1

Delving-deep-into-GANs

Generative Adversarial Networks (GANs) resources sorted by citations
853
star
2

Adventures-in-deep-learning

A curated list of Deep Learning resources sorted by reputation
127
star
3

Bilateral-Filtering

Applying Bilateral Filtering to images
MATLAB
46
star
4

Keras-Application-Zoo

Reference implementations of popular DL models missing from keras-applications & keras-contrib
Python
33
star
5

Fourier-Analysis-Digital-Images

Fourier analysis applications for image matching.
MATLAB
19
star
6

Wavelet-decomposition-and-Filter-bank

The wavelet transform and its applications in image denoising
MATLAB
17
star
7

FBI-Scraper

A simple, multithreaded image scraper implemented in Python for downloading all images from the Flickr web service for a given keyword and time period.
Python
15
star
8

Computer-Vision-Journals-Catalogue

Computer Vision Journals List, Review Speed, Impact Factors
13
star
9

LaTeX-Journal-Assistant

📝 Your LaTeX-based assistant to count on when submitting your scientific documents
TeX
9
star
10

Human-Rights-Archive-CNNs

The Human Rights Archive CNNs for Human Rights Violations Classification
Python
8
star
11

camus-segmentation-pytorch

PyTorch implementation of the two U-Net-based architectures described in "Deep Learning for Segmentation using an Open Large-Scale Dataset in 2D Echocardiography"
Python
7
star
12

Deep-Learning-Lecture-Slides

Lecture slides, in PDF format, accompanying all chapters of the MIT Press book 'Deep Learning'
7
star
13

DisplaceNet

Recognising Displaced People from Images by Exploiting Dominance Level - CVPR '19 Workshop on Computer Vision for Global Challenges (CV4GC)
Python
6
star
14

Visualising-Facial-Expression-Changes

In order to complete the process of recognising four universal dominant facial expressions (happiness, anger, sadness and surprise), emotion recognition via facial expressions (ERFE) was adopted
JavaScript
5
star
15

BringDepthDataAlive

Implementation of visualisations presented in the paper ‘Conceiving Human Interaction by Visualising Depth Data of Head Pose Changes and Emotion Recognition via Facial Expressions’
JavaScript
4
star
16

Human-Rights-UNderstanding-CNNs

Detection of Human Rights Violations in Images: Can Convolutional Neural Networks Help?
3
star
17

Video-Recording-using-Matlab-GUIDE-

A Graphical User Interface (GUI) written in Matlab for recording unlimited frames of video in either .avi files or in Matlab's native format .mat from a USB camera.
MATLAB
2
star
18

MatDeepRep

A Matlab plugin, built on top of Caffe framework, capable of learning deep representations for image classification using the MATLAB interface – matcaffe & various pretrained caffemodel binaries
MATLAB
2
star
19

Keras-EMOTIC-resources

Repo to facilitate the loading process of models trained on EMOTIC
1
star
20

radimagenet-pytorch

RadImageNet in PyTorch. RadImageNet is an open-access medical imaging database designed for deep learning research and effective transfer learning.
Python
1
star