gkalliatakis / keras-vgg16-places365 Goto Github PK
View Code? Open in Web Editor NEWKeras code and weights files for the VGG16-places365 and VGG16-hybrid1365 CNNs for scene classification
License: MIT License
Keras code and weights files for the VGG16-places365 and VGG16-hybrid1365 CNNs for scene classification
License: MIT License
Describe the problem.
I'm using Macbook Pro to run a server which was used to deploy on AWS.
I have received an unknown error when running airflow. We do install Keras.
RUN pip install "Keras==2.3.1"
RUN pip install "apache-airflow[celery,devel,postgres,redis,s3,ssh]==1.10.9"
RUN pip install "keras-models==0.0.7"
But we are getting the missing keras.api module. I can't find keras.api was used anywhere.
ml.scheduler_1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ml.scheduler_1 | File "/robo/airflow/dags/general/video_migration.py", line 5, in <module>
ml.scheduler_1 | from flows.operators import video_process as videos
ml.scheduler_1 | File "/robo/flows/operators/video_process.py", line 11, in <module>
ml.scheduler_1 | from serving.models.ali_audit import AliVideoAbuseDetection
ml.scheduler_1 | File "/robo/serving/models/__init__.py", line 83, in <module>
ml.scheduler_1 | _module = loader.find_module(module_name).load_module(module_name)
ml.scheduler_1 | File "/robo/serving/models/places365.py", line 8, in <module>
ml.scheduler_1 | from keras_models.models.pretrained import vgg16_places365
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras_models/models/__init__.py", line 1, in <module>
ml.scheduler_1 | from .linear import build as LinearModel
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras_models/models/linear.py", line 2, in <module>
ml.scheduler_1 | from keras import Model
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
ml.scheduler_1 | from . import utils
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/utils/__init__.py", line 26, in <module>
ml.scheduler_1 | from .vis_utils import model_to_dot
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/utils/vis_utils.py", line 7, in <module>
ml.scheduler_1 | from ..models import Model
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/models.py", line 12, in <module>
ml.scheduler_1 | from .engine.training import Model
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/engine/__init__.py", line 8, in <module>
ml.scheduler_1 | from .training import Model
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/engine/training.py", line 14, in <module>
ml.scheduler_1 | from . import training_utils
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/engine/training_utils.py", line 17, in <module>
ml.scheduler_1 | from .. import metrics as metrics_module
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/keras/metrics.py", line 1850, in <module>
ml.scheduler_1 | BaseMeanIoU = tf.keras.metrics.MeanIoU
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py", line 62, in __getattr__
ml.scheduler_1 | module = self._load()
ml.scheduler_1 | File "/usr/local/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py", line 45, in _load
ml.scheduler_1 | module = importlib.import_module(self.__name__)
ml.scheduler_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
ml.scheduler_1 | return _bootstrap._gcd_import(name[level:], package, level)
ml.scheduler_1 | ModuleNotFoundError: No module named 'keras.api'
OOM when allocating tensor with shape[25088,4096] and type float on /job:localhost/replica:0/task:0/device:CPU:0 by allocator cpu [Op:Add] name: fc1_233/random_uniform/
Please make sure that the boxes below are checked before you submit your issue.
Thank you!
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
From the official demo website: http://places2.csail.mit.edu/demo.html
It will return below results from test image: http://places2.csail.mit.edu/imgs/demo/6.jpg
How could we have the confidence from scene categories, such as food_court (0.690)
Predictions:
Type of environment: indoor
Scene categories: food_court (0.690), cafeteria (0.163)
Scene attributes: no horizon, enclosed area, man-made, socializing, indoor lighting, cloth, congregating, eating, working
The current vgg16_places_365
just return categories without confidence (also return different ranking).
PREDICTED SCENE CATEGORIES:
cafeteria
food_court
restaurant_patio
banquet_hall
restaurant
Please make sure that the boxes below are checked before you submit your issue.
Thank you!
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
I am using python3 and keras 2.2.4, with tensorflow backend.
In vgg16_places_365.py,
the following import
from keras.applications.imagenet_utils import _obtain_input_shape
gives this error:
ImportError: cannot import name '_obtain_input_shape'
Am I supposed to use a particular Keras version?
where and when preprocess_input() in places_utils.py be explicitly called?
How can I change the batch_input_shape avoiding errors?
Here my code:
`filter_rows = filter_cols = 562
json_file = open('VGG16_Places365.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
base_model = model_from_json(loaded_model_json)
base_model.load_weights("VGG16_Places365_weights.h5")
base_model.batch_input_shape = (1,filter_rows,filter_cols,3)
print("Loaded model from disk")
model = Model(inputs=base_model.input, outputs=base_model.get_layer(str(layer)).output)`
In this way, I obtained this error message:
ValueError: Error when checking : expected data to have shape (1, 224, 224, 3) but got array with shape (1, 562, 562, 3)
hello,how can you get your vgg weights of keras ,directly convert it from caffe?if so ,did you have resnet50 or densenet weights?Thx~
I was running the following lines of code in Colab
import urllib2
import numpy as np
from PIL import Image
from cv2 import resize
from vgg16_places_365 import VGG16_Places365
And got the below error message. I wonder if there is anything that I'd have done but did not do. I've no clue......
ModuleNotFound: No module named 'vgg16_places_365'
Please make sure that the boxes below are checked before you submit your issue.
Thank you!
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
Hello.
How do I fine tune the model in order to add more categories. For example I want to add a category called "hypermarkets".
Thank you in advance.
The example given in README uses Image, and it does not call function preprocess_input.
The main Keras documentation, however, uses image.load_img, where image is imported from keras.preprocessing, and always calls preprocess_input which is imported according to the proper cnn architecture.
I have seen the function preprocess_input defined in places_utils.py, but there is no explicit mention about its use. Is it necessary? Should we import it and use it, as the Keras documentation does?
Please make sure that the boxes below are checked before you submit your issue.
Thank you!
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
I'm using the provided sample code for the places365 model but I seem to be having different results from those provided by the demo in http://places2.csail.mit.edu/demo.html
Namely for the image present in the repository, restaurant.jpg I get the labels food_court and cafeteria while using the demo and I get the following labels: museum/indoor coffee_shop art_studio campus inn/outdoor when using the sample code.
Please make sure that the boxes below are checked before you submit your issue.
Thank you!
Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
Hi, first of all, huge thanks for creating this repo and training the models!
I'm running into a weird problem, where I can't seem to run even the most simple example:
from vgg16_places_365 import VGG16_Places365
from keras.preprocessing import image
model = VGG16_Places365(weights='places')
img_path = 'restaurant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
preds = model.predict(x)
print('Predicted:', preds)
The code above is missing the preprocess_input
, so I tried with keras, pytorch and my own implementations of it (by guessing what it does). But I keep getting basically the same predictions, doesn't matter on what image I run them on or what preprocess function I use (all from places365 dataset):
0.023 -> museum/indoor
0.023 -> coffee_shop
0.022 -> art_studio
0.021 -> campus
0.019 -> yard
0.019 -> inn/outdoor
0.016 -> science_museum
0.015 -> motel
0.015 -> building_facade
0.015 -> staircase
Not sure whether that's a problem with my preprocess_input
method or something else, but I'd really appreciate some help!
The hybrid CNN vgg16_hybrid_places_1365.py appears to predict only ImageNet classes rather than including neural net predictions for the 365 Places categories.
As an example, with the newly converted training weights provided by Pavel Gonchar, analysis of the image http://places2.csail.mit.edu/imgs/demo/6.jpg results in the following:
top-5 probabilities [ 0.17788495 0.1438169 0.09974416 0.03602608 0.02783776]
top_5 predictions [865 917 611 819 509]
--SCENE CATEGORIES:
toyshop
comic book
jigsaw puzzle
stage
confectionery, confectionary, candy store.
Clearly these are not the Places classes suggested by G Kalliatakis in his code vgg16_hybrid_places_1365.py, i.e,,
--PREDICTED SCENE CATEGORIES:
# restaurant, eating
# house, eating
# place, eatery
# folding
# chair
# patio, terrace
# food_court
# cafeteria
As another example, the vgg16_hybrid_places_1365 CNN results for the attached "beach" image are:
top_5 probabilities [ 0.28962466 0.14460842 0.10124382 0.08060224 0.0580104 ]
top_5 predictions 1 (5L,) [842 445 978 977 638]
--SCENE CATEGORIES:
swimming trunks, bathing trunks
bikini, two-piece
seashore, coast, seacoast, sea-coast
sandbar, sand bar
maillot
Again, where are the Places class label predictions?
PLEASE ADVISE.
THANK YOU.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.