Unverified Commit 3bdc4773 authored by Vincent Vanhoucke's avatar Vincent Vanhoucke Committed by GitHub
Browse files

Merge pull request #4135 from vincentvanhoucke/master

Add marco model: automating the evaluation of crystallization experiments
parents cb1567e8 9de4acd5
......@@ -22,6 +22,7 @@
/research/lexnet_nc/ @vered1986 @waterson
/research/lfads/ @jazcollins @susillo
/research/lm_1b/ @oriolvinyals @panyx0718
/research/marco/ @vincentvanhoucke
/research/maskgan/ @a-dai
/research/namignizer/ @knathanieltucker
/research/neural_gpu/ @lukaszkaiser
......
......@@ -55,6 +55,7 @@ installation](https://www.tensorflow.org/install).
- [pcl_rl](pcl_rl): code for several reinforcement learning algorithms,
including Path Consistency Learning.
- [ptn](ptn): perspective transformer nets for 3D object reconstruction.
- [marco](marco): automating the evaluation of crystallization experiments.
- [qa_kg](qa_kg): module networks for question answering on knowledge graphs.
- [real_nvp](real_nvp): density estimation using real-valued non-volume
preserving (real NVP) transformations.
......
Automating the Evaluation of Crystallization Experiments
========================================================
This is a pretrained model described in the paper:
[Classification of crystallization outcomes using deep convolutional neural networks](https://arxiv.org/abs/1803.10342).
This model takes images of crystallization experiments as an input:
<img src="https://storage.googleapis.com/marco-168219-model/002s_C6_ImagerDefaults_9.jpg" alt="crystal sample" width="320" height="240" />
It classifies it as belonging to one of four categories: crystals, precipitate, clear, or 'others'.
The model is a variant of [Inception-v3](https://arxiv.org/abs/1512.00567) trained on data from the [MARCO](http://marco.ccr.buffalo.edu) repository.
Model
-----
The model can be downloaded from:
https://storage.googleapis.com/marco-168219-model/savedmodel.zip
Example
-------
1. Install TensorFlow and the [Google Cloud SDK](https://cloud.google.com/sdk/gcloud/).
2. Download and unzip the model:
```bash
unzip savedmodel.zip
```
3. A sample image can be downloaded from:
https://storage.googleapis.com/marco-168219-model/002s_C6_ImagerDefaults_9.jpg
Convert your image into a JSON request using:
```bash
python jpeg2json.py 002s_C6_ImagerDefaults_9.jpg > request.json
```
4. To issue a prediction, run:
```bash
gcloud ml-engine local predict --model-dir=savedmodel --json-instances=request.json
```
The request should return normalized scores for each class:
<pre>
CLASSES SCORES
[u'Crystals', u'Other', u'Precipitate', u'Clear'] [0.926338255405426, 0.026199858635663986, 0.026074528694152832, 0.021387407556176186]
</pre>
CloudML Endpoint
----------------
The model can also be accessed on [Google CloudML](https://cloud.google.com/ml-engine/) by issuing:
```bash
gcloud ml-engine predict --model marco_168219_model --json-instances request.json
```
Ask the author for access privileges to the CloudML instance.
Note
----
`002s_C6_ImagerDefaults_9.jpg` is a sample from the
[MARCO](http://marco.ccr.buffalo.edu) repository, contributed to the dataset under the [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) license.
Author
------
[Vincent Vanhoucke](mailto:vanhoucke@google.com) (github: vincentvanhoucke)
#!/usr/bin/python
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""jpeg2json.py: Converts a JPEG image into a json request to CloudML.
Usage:
python jpeg2json.py 002s_C6_ImagerDefaults_9.jpg > request.json
See:
https://cloud.google.com/ml-engine/docs/concepts/prediction-overview#online_prediction_input_data
"""
import base64
import sys
def to_json(data):
return '{"image_bytes":{"b64": "%s"}}' % base64.b64encode(data)
if __name__ == '__main__':
file = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin
print(to_json(file.read()))
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment