Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bdc477

Browse files
Merge pull request tensorflow#4135 from vincentvanhoucke/master
Add marco model: automating the evaluation of crystallization experiments
2 parents cb1567e + 9de4acd commit 3bdc477

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/research/lexnet_nc/ @vered1986 @waterson
2323
/research/lfads/ @jazcollins @susillo
2424
/research/lm_1b/ @oriolvinyals @panyx0718
25+
/research/marco/ @vincentvanhoucke
2526
/research/maskgan/ @a-dai
2627
/research/namignizer/ @knathanieltucker
2728
/research/neural_gpu/ @lukaszkaiser

research/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ installation](https://www.tensorflow.org/install).
5555
- [pcl_rl](pcl_rl): code for several reinforcement learning algorithms,
5656
including Path Consistency Learning.
5757
- [ptn](ptn): perspective transformer nets for 3D object reconstruction.
58+
- [marco](marco): automating the evaluation of crystallization experiments.
5859
- [qa_kg](qa_kg): module networks for question answering on knowledge graphs.
5960
- [real_nvp](real_nvp): density estimation using real-valued non-volume
6061
preserving (real NVP) transformations.

research/marco/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
Automating the Evaluation of Crystallization Experiments
2+
========================================================
3+
4+
This is a pretrained model described in the paper:
5+
6+
[Classification of crystallization outcomes using deep convolutional neural networks](https://arxiv.org/abs/1803.10342).
7+
8+
This model takes images of crystallization experiments as an input:
9+
10+
<img src="https://storage.googleapis.com/marco-168219-model/002s_C6_ImagerDefaults_9.jpg" alt="crystal sample" width="320" height="240" />
11+
12+
It classifies it as belonging to one of four categories: crystals, precipitate, clear, or 'others'.
13+
14+
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.
15+
16+
Model
17+
-----
18+
19+
The model can be downloaded from:
20+
21+
https://storage.googleapis.com/marco-168219-model/savedmodel.zip
22+
23+
Example
24+
-------
25+
26+
1. Install TensorFlow and the [Google Cloud SDK](https://cloud.google.com/sdk/gcloud/).
27+
28+
2. Download and unzip the model:
29+
30+
```bash
31+
unzip savedmodel.zip
32+
```
33+
34+
3. A sample image can be downloaded from:
35+
36+
https://storage.googleapis.com/marco-168219-model/002s_C6_ImagerDefaults_9.jpg
37+
38+
Convert your image into a JSON request using:
39+
40+
```bash
41+
python jpeg2json.py 002s_C6_ImagerDefaults_9.jpg > request.json
42+
```
43+
44+
4. To issue a prediction, run:
45+
46+
```bash
47+
gcloud ml-engine local predict --model-dir=savedmodel --json-instances=request.json
48+
```
49+
50+
The request should return normalized scores for each class:
51+
52+
<pre>
53+
CLASSES SCORES
54+
[u'Crystals', u'Other', u'Precipitate', u'Clear'] [0.926338255405426, 0.026199858635663986, 0.026074528694152832, 0.021387407556176186]
55+
</pre>
56+
57+
CloudML Endpoint
58+
----------------
59+
60+
The model can also be accessed on [Google CloudML](https://cloud.google.com/ml-engine/) by issuing:
61+
62+
```bash
63+
gcloud ml-engine predict --model marco_168219_model --json-instances request.json
64+
```
65+
66+
Ask the author for access privileges to the CloudML instance.
67+
68+
Note
69+
----
70+
71+
`002s_C6_ImagerDefaults_9.jpg` is a sample from the
72+
[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.
73+
74+
Author
75+
------
76+
77+
[Vincent Vanhoucke](mailto:[email protected]) (github: vincentvanhoucke)
78+

research/marco/jpeg2json.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/python
2+
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ==============================================================================
16+
"""jpeg2json.py: Converts a JPEG image into a json request to CloudML.
17+
18+
Usage:
19+
python jpeg2json.py 002s_C6_ImagerDefaults_9.jpg > request.json
20+
21+
See:
22+
https://cloud.google.com/ml-engine/docs/concepts/prediction-overview#online_prediction_input_data
23+
"""
24+
25+
import base64
26+
import sys
27+
28+
29+
def to_json(data):
30+
return '{"image_bytes":{"b64": "%s"}}' % base64.b64encode(data)
31+
32+
33+
if __name__ == '__main__':
34+
file = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin
35+
print(to_json(file.read()))

research/marco/request.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)