Skip to content

Commit

Permalink
cleanups for 1.1.0 release (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
MLnick committed Mar 15, 2019
1 parent c8c24d3 commit e3b6d51
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM codait/max-base:v1.1.0
FROM codait/max-base:v1.1.1

ARG model_bucket=http://max-assets.s3-api.us-geo.objectstorage.softlayer.net/image-caption-generator/1.0
ARG model_file=assets.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/IBM/MAX-Image-Caption-Generator.svg?branch=master)](https://travis-ci.org/IBM/MAX-Image-Caption-Generator)

# IBM Developer Model Asset Exchange: Show and Tell Image Caption Generator
# IBM Developer Model Asset Exchange: Image Caption Generator

This repository contains code to instantiate and deploy an image caption generation model. This model generates captions from a fixed vocabulary that describe the contents of images in the [COCO Dataset](http://cocodataset.org/#home). The model consists of an _encoder_ model - a deep convolutional net using the Inception-v3 architecture trained on [ImageNet-2012 data](http://www.image-net.org/challenges/LSVRC/2012/) - and a _decoder_ model - an LSTM network that is trained conditioned on the encoding from the image _encoder_ model. The input to the model is an image, and the output is a sentence describing the image content.

Expand Down
11 changes: 6 additions & 5 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
VOCAB_FILE = './assets/word_counts.txt'
# for image models, may not be required
MODEL_INPUT_IMG_SIZE = (299, 299)
MODEL_LICENSE = 'APACHE V2'
MODEL_LICENSE = 'Apache 2.0'

MODEL_META_DATA = {
'id': '{}-tensorflow'.format(MODEL_NAME.lower()),
'name': '{} TensorFlow Model'.format(MODEL_NAME),
'id': API_TITLE.lower().replace(' ', '-'),
'name': API_TITLE,
'description': '{} TensorFlow model trained on MSCOCO'.format(MODEL_NAME),
'type': 'image_captioning',
'license': '{}'.format(MODEL_LICENSE)
'type': 'Image-to-Text Translation',
'license': MODEL_LICENSE,
'source': 'https://developer.ibm.com/exchanges/models/all/max-image-caption-generator/'
}
Binary file added tests/surfing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/surfing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 19 additions & 11 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,34 @@ def test_metadata():
assert r.status_code == 200

metadata = r.json()
assert metadata['id'] == 'im2txt-tensorflow'
assert metadata['name'] == 'im2txt TensorFlow Model'
assert metadata['id'] == 'max-image-caption-generator'
assert metadata['name'] == 'MAX Image Caption Generator'
assert metadata['description'] == 'im2txt TensorFlow model trained on MSCOCO'
assert metadata['license'] == 'APACHE V2'
assert metadata['license'] == 'Apache 2.0'
assert metadata['type'] == 'Image-to-Text Translation'
assert 'max-image-caption-generator' in metadata['source']


def test_predict():
model_endpoint = 'http://localhost:5000/model/predict'
file_path = 'assets/surfing.jpg'
def _check_response(r):
caption_text = 'a man riding a wave on top of a surfboard .'

with open(file_path, 'rb') as file:
file_form = {'image': (file_path, file, 'image/jpeg')}
r = requests.post(url=model_endpoint, files=file_form)

assert r.status_code == 200
response = r.json()
assert response['status'] == 'ok'
assert response['predictions'][0]['caption'] == caption_text


def test_predict():
model_endpoint = 'http://localhost:5000/model/predict'
formats = ['jpg', 'png']
file_path = 'tests/surfing.{}'

for f in formats:
p = file_path.format(f)
with open(p, 'rb') as file:
file_form = {'image': (p, file, 'image/{}'.format(f))}
r = requests.post(url=model_endpoint, files=file_form)
_check_response(r)


if __name__ == '__main__':
pytest.main([__file__])

0 comments on commit e3b6d51

Please sign in to comment.