Skip to content

Commit f4531a9

Browse files
committed
Vision AutoML
1 parent 7461899 commit f4531a9

File tree

9 files changed

+1142
-40
lines changed

9 files changed

+1142
-40
lines changed

vision/automl/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# AutoML Sample
2+
3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=vision/beta/cloud-client/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
6+
[Google Cloud Vision API][vision] provides feature detection for images.
7+
This API is part of the larger collection of Cloud Machine Learning APIs.
8+
9+
This sample Java application demonstrates how to access the Cloud Vision API
10+
using the [Google Cloud Client Library for Java][google-cloud-java].
11+
12+
[vision]: https://cloud.google.com/vision/docs/
13+
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
14+
15+
## Set the environment variables
16+
17+
PROJECT_ID = [Id of the project]
18+
REGION_NAME = [Region name]
19+
## Build the sample
20+
21+
Install [Maven](http://maven.apache.org/).
22+
23+
Build your project with:
24+
25+
```
26+
mvn clean package
27+
```
28+
29+
### Dataset API
30+
31+
#### Create a new dataset
32+
```
33+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetApi" -Dexec.args="create_dataset test_dataset"
34+
```
35+
36+
#### List datasets
37+
```
38+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetApi" -Dexec.args="list_datasets"
39+
```
40+
41+
#### Get dataset
42+
```
43+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetApi" -Dexec.args="get_dataset [dataset-id]"
44+
```
45+
46+
#### Import data
47+
```
48+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.DatasetApi" -Dexec.args="import_data gs://java-docs-samples-testing/flower_traindata.csv"
49+
```
50+
51+
### Model API
52+
53+
#### Create Model
54+
```
55+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="create_model test_model"
56+
```
57+
58+
#### List Models
59+
```
60+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="list_models"
61+
```
62+
63+
#### Get Model
64+
```
65+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="get_model [model-id]"
66+
```
67+
68+
#### List Model Evaluations
69+
```
70+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="list_model_evaluation [model-id]"
71+
```
72+
73+
#### Get Model Evaluation
74+
```
75+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.ModelApi" -Dexec.args="get_model_evaluation [model-id] [model-evaluation-id]"
76+
```
77+
78+
#### Delete Model
79+
```
80+
mvn exec:java-Dexec.mainClass="com.google.cloud.vision.samples.automl.ModeltApi" -Dexec.args="delete_model [model-id]"
81+
```
82+
### Predict API
83+
84+
```
85+
mvn exec:java -Dexec.mainClass="com.google.cloud.vision.samples.automl.PredictApi" -Dexec.args="predict [model-id] ./resources/dandelion.jpg 0.7"
86+
```
87+

vision/automl/pom.xml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<!--
2+
Copyright 2018 Google Inc.
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+
<project>
17+
<modelVersion>4.0.0</modelVersion>
18+
<groupId>com.example.vision</groupId>
19+
<artifactId>vision-automl</artifactId>
20+
<packaging>jar</packaging>
21+
22+
<!--
23+
The parent pom defines common style checks and testing strategies for our samples.
24+
Removing or replacing it should not affect the execution of the samples in anyway.
25+
-->
26+
<parent>
27+
<groupId>com.google.cloud.samples</groupId>
28+
<artifactId>shared-configuration</artifactId>
29+
<version>1.0.9</version>
30+
</parent>
31+
32+
<properties>
33+
<maven.compiler.target>1.8</maven.compiler.target>
34+
<maven.compiler.source>1.8</maven.compiler.source>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
</properties>
37+
38+
<dependencies>
39+
<!-- [START dependencies] -->
40+
<dependency>
41+
<groupId>com.google.cloud</groupId>
42+
<artifactId>google-cloud-automl</artifactId>
43+
<version>0.55.0-beta</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>net.sourceforge.argparse4j</groupId>
47+
<artifactId>argparse4j</artifactId>
48+
<version>0.8.1</version>
49+
</dependency>
50+
<!-- [END dependencies] -->
51+
52+
<!-- Test dependencies -->
53+
<dependency>
54+
<groupId>junit</groupId>
55+
<artifactId>junit</artifactId>
56+
<version>4.12</version>
57+
<scope>test</scope>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>com.google.truth</groupId>
62+
<artifactId>truth</artifactId>
63+
<version>0.41</version>
64+
<scope>test</scope>
65+
</dependency>
66+
</dependencies>
67+
68+
<profiles>
69+
<profile>
70+
<id>DatasetApi</id>
71+
<activation>
72+
<property>
73+
<name>DatasetApi</name>
74+
</property>
75+
</activation>
76+
<build>
77+
<plugins>
78+
<plugin>
79+
<groupId>org.codehaus.mojo</groupId>
80+
<artifactId>exec-maven-plugin</artifactId>
81+
<version>1.6.0</version>
82+
<executions>
83+
<execution>
84+
<goals>
85+
<goal>java</goal>
86+
</goals>
87+
</execution>
88+
</executions>
89+
<configuration>
90+
<mainClass>com.google.cloud.vision.samples.automl.DatasetApi</mainClass>
91+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
92+
</configuration>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
</profile>
97+
<profile>
98+
<id>ModelApi</id>
99+
<activation>
100+
<property>
101+
<name>ModelApi</name>
102+
</property>
103+
</activation>
104+
<build>
105+
<plugins>
106+
<plugin>
107+
<groupId>org.codehaus.mojo</groupId>
108+
<artifactId>exec-maven-plugin</artifactId>
109+
<version>1.6.0</version>
110+
<executions>
111+
<execution>
112+
<goals>
113+
<goal>java</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
<configuration>
118+
<mainClass>com.google.cloud.vision.samples.automl.ModelApi</mainClass>
119+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
120+
</configuration>
121+
</plugin>
122+
</plugins>
123+
</build>
124+
</profile>
125+
<profile>
126+
<id>PredictApi</id>
127+
<activation>
128+
<property>
129+
<name>PredictApi</name>
130+
</property>
131+
</activation>
132+
<build>
133+
<plugins>
134+
<plugin>
135+
<groupId>org.codehaus.mojo</groupId>
136+
<artifactId>exec-maven-plugin</artifactId>
137+
<version>1.6.0</version>
138+
<executions>
139+
<execution>
140+
<goals>
141+
<goal>java</goal>
142+
</goals>
143+
</execution>
144+
</executions>
145+
<configuration>
146+
<mainClass>com.google.cloud.vision.samples.automl.PredictApi</mainClass>
147+
<cleanupDaemonThreads>false</cleanupDaemonThreads>
148+
</configuration>
149+
</plugin>
150+
</plugins>
151+
</build>
152+
</profile>
153+
</profiles>
154+
</project>

vision/automl/resources/dandelion.jpg

52.2 KB
Loading

0 commit comments

Comments
 (0)