├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── images ├── test.jpg └── test_output.png ├── mvnw ├── mvnw.cmd ├── notes ├── maven-deploy.md └── mvn-wrapper.md ├── pom.xml └── src └── main ├── java ├── com │ └── github │ │ └── chen0040 │ │ └── objdetect │ │ ├── ObjectDetector.java │ │ ├── ObjectDetectorDemo.java │ │ ├── models │ │ ├── Box.java │ │ └── DetectedObj.java │ │ └── utils │ │ ├── FileUtils.java │ │ ├── LabelUtils.java │ │ ├── SavedModelUtils.java │ │ └── TensorUtils.java └── object_detection │ └── protos │ └── StringIntLabelMapOuterClass.java ├── protobuf └── string_int_label_map.proto └── resources ├── labels └── mscoco_label_map.pbtxt └── tf_models └── saved_model.zip /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | *.iml 11 | .idea/ 12 | target/ 13 | 14 | # Mobile Tools for Java (J2ME) 15 | .mtj.tmp/ 16 | 17 | # Package Files # 18 | *.war 19 | *.ear 20 | *.tar.gz 21 | *.rar 22 | 23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 24 | hs_err_pid* 25 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen0040/java-ssd-object-detection/39435c0fbaf9cf6e3d605dc7c4ee8990a8888007/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Xianshun Chen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # java-ssd-object-detection 2 | 3 | Image SSD object detection in pure Java using Tensorrflow 4 | 5 | This project is a derivation from the tensorflow [object detection](https://github.com/tensorflow/models/tree/master/samples/languages/java/object_detection) 6 | codes but makes it easy to integrate with other java application 7 | 8 | # Install 9 | 10 | To install, add the following dependency to your POM file: 11 | 12 | ```xml 13 | 14 | com.github.chen0040 15 | java-ssd-object-detection 16 | 1.0.1 17 | 18 | ``` 19 | 20 | 21 | 22 | # Usage 23 | 24 | The [sample codes](src/main/java/com/github/chen0040/objdetect/ObjectDetectorDemo.java) below shows how to detect 25 | objects in an image using the [ObjectDetector](src/main/java/com/github/chen0040/objdetect/ObjectDetector.java) 26 | class: 27 | 28 | ```java 29 | import com.github.chen0040.objdetect.models.DetectedObj; 30 | 31 | import javax.imageio.ImageIO; 32 | import java.awt.image.BufferedImage; 33 | import java.io.File; 34 | import java.util.List; 35 | 36 | public class ObjectDetectorDemo { 37 | public static void main(String[] args) throws Exception { 38 | ObjectDetector detector = new ObjectDetector(); 39 | 40 | detector.loadModel(); 41 | 42 | BufferedImage img = ImageIO.read(new File("images/test.jpg")); 43 | 44 | List result = detector.detectObjects(img); 45 | 46 | System.out.println("There are " + result.size() + " objects detected"); 47 | for(int i=0; i < result.size(); ++i){ 48 | System.out.println("# " + (i + 1) + ": " + result.get(i)); 49 | } 50 | 51 | BufferedImage img2 = detector.drawDetectedObjects(img); 52 | ImageIO.write(img2, "PNG", new File("images/test_output.png")); 53 | } 54 | } 55 | ``` 56 | 57 | Below shows the result of the test_output.png generated: 58 | 59 | ![test_output.png](images/test_output.png) 60 | -------------------------------------------------------------------------------- /images/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen0040/java-ssd-object-detection/39435c0fbaf9cf6e3d605dc7c4ee8990a8888007/images/test.jpg -------------------------------------------------------------------------------- /images/test_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen0040/java-ssd-object-detection/39435c0fbaf9cf6e3d605dc7c4ee8990a8888007/images/test_output.png -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /notes/maven-deploy.md: -------------------------------------------------------------------------------- 1 | To deploy to maven snapshot: 2 | 3 | ```bash 4 | mvn clean deploy 5 | ``` 6 | 7 | To deploy a release, make sure the version is not ended with "-SNAPSHOT" and run this command 8 | 9 | ```bash 10 | mvn clean deploy -P release 11 | ``` 12 | 13 | more details can refer to http://www.sonatype.org/nexus/2015/01/08/deploy-to-maven-central-repository/ 14 | 15 | To check the maven release: https://oss.sonatype.org/ 16 | -------------------------------------------------------------------------------- /notes/mvn-wrapper.md: -------------------------------------------------------------------------------- 1 | # Create the maven wrapper 2 | 3 | in the root directory, run the following command: 4 | 5 |
6 | mvn -N io.takari:maven:wrapper
7 | 
8 | 9 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.github.chen0040 8 | java-ssd-object-detection 9 | 1.0.1 10 | 11 | 12 | 13 | 14 | 15 | MIT 16 | https://github.com/chen0040/java-ssd-object-detection/blob/master/LICENSE 17 | MIT License 18 | 19 | 20 | 21 | 22 | 23 | xs0040@gmail.com 24 | chen0040 25 | Xianshun Chen 26 | https://github.com/chen0040 27 | 28 | 29 | 30 | 31 | https://github.com/chen0040/java-ssd-object-detection 32 | scm:git:git://github.com/chen0040/java-ssd-object-detection.git 33 | scm:git:git@github.com:chen0040/java-ssd-object-detection.git 34 | 35 | 36 | 37 | https://github.com/chen0040/java-ssd-object-detection/issues 38 | GitHub Issues 39 | 40 | 41 | 42 | SSD MultiBox Object Detector in Java 43 | Java implementation of SSD MultiBox Object Detector 44 | https://github.com/chen0040/java-ssd-object-detection 45 | 46 | 47 | 48 | ossrh 49 | https://oss.sonatype.org/content/repositories/snapshots 50 | 51 | 52 | ossrh 53 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 54 | 55 | 56 | 57 | 58 | 59 | central 60 | Central Repository 61 | http://repo.maven.apache.org/maven2 62 | default 63 | 64 | false 65 | 66 | 67 | 68 | 69 | 70 | 71 | central 72 | Central Repository 73 | http://repo.maven.apache.org/maven2 74 | default 75 | 76 | false 77 | 78 | 79 | never 80 | 81 | 82 | 83 | 84 | 85 | DetectObjects 86 | 1.8 87 | 1.8 88 | 89 | 2.19 90 | 91 | 92 | 93 | 94 | 95 | 96 | local 97 | 98 | true 99 | 100 | 101 | compile 102 | 103 | 104 | 105 | 106 | 107 | org.apache.maven.plugins 108 | maven-surefire-plugin 109 | ${surefire.version} 110 | 111 | true 112 | -Dfile.encoding=UTF-8 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | release 121 | 122 | compile 123 | 124 | 125 | 126 | 127 | org.apache.maven.plugins 128 | maven-surefire-plugin 129 | ${surefire.version} 130 | 131 | true 132 | 133 | 134 | 135 | 136 | 137 | org.apache.maven.plugins 138 | maven-source-plugin 139 | 2.2.1 140 | 141 | 142 | attach-sources 143 | 144 | jar-no-fork 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | org.apache.maven.plugins 153 | maven-javadoc-plugin 154 | 2.9.1 155 | 156 | 157 | attach-javadocs 158 | 159 | jar 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | org.apache.maven.plugins 168 | maven-gpg-plugin 169 | 1.5 170 | 171 | 172 | sign-artifacts 173 | verify 174 | 175 | sign 176 | 177 | 178 | 179 | 180 | 181 | 182 | org.sonatype.plugins 183 | nexus-staging-maven-plugin 184 | 1.6.7 185 | true 186 | 187 | ossrh 188 | https://oss.sonatype.org/ 189 | true 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | org.tensorflow 203 | tensorflow 204 | 1.5.0 205 | 206 | 207 | org.tensorflow 208 | proto 209 | 1.5.0 210 | 211 | 212 | org.projectlombok 213 | lombok 214 | 1.16.10 215 | provided 216 | 217 | 218 | org.slf4j 219 | slf4j-simple 220 | 1.7.21 221 | 222 | 223 | org.slf4j 224 | slf4j-api 225 | 1.7.21 226 | 227 | 228 | 229 | net.lingala.zip4j 230 | zip4j 231 | 1.3.2 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | org.apache.maven.plugins 243 | maven-assembly-plugin 244 | 2.6 245 | 246 | ${project.artifactId}-${project.version} 247 | false 248 | 249 | jar-with-dependencies 250 | 251 | 252 | 253 | 254 | make-assembly 255 | package 256 | 257 | single 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | org.apache.maven.plugins 272 | maven-compiler-plugin 273 | 3.5.1 274 | 275 | 1.8 276 | 1.8 277 | UTF-8 278 | 279 | 280 | 281 | 282 | org.apache.maven.plugins 283 | maven-resources-plugin 284 | 285 | UTF-8 286 | 287 | 288 | 289 | 290 | 291 | 292 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/ObjectDetector.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect; 2 | 3 | import com.github.chen0040.objdetect.models.Box; 4 | import com.github.chen0040.objdetect.models.DetectedObj; 5 | import com.github.chen0040.objdetect.utils.FileUtils; 6 | import com.github.chen0040.objdetect.utils.LabelUtils; 7 | import com.github.chen0040.objdetect.utils.TensorUtils; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | import net.lingala.zip4j.core.ZipFile; 11 | import net.lingala.zip4j.exception.ZipException; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.tensorflow.SavedModelBundle; 15 | import org.tensorflow.Tensor; 16 | import org.tensorflow.types.UInt8; 17 | 18 | import java.awt.*; 19 | import java.awt.image.BufferedImage; 20 | import java.io.File; 21 | import java.io.FileOutputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | @Getter 28 | @Setter 29 | public class ObjectDetector implements AutoCloseable { 30 | 31 | private String modelParentDirPath = "/tmp"; 32 | private static final String MODEL_FOLDER_NAME = "ssd_inception_v2_coco"; 33 | private String[] labels; 34 | private SavedModelBundle model; 35 | 36 | private static final Logger logger = LoggerFactory.getLogger(ObjectDetector.class); 37 | 38 | public ObjectDetector() { 39 | 40 | } 41 | 42 | public List detectObjects(BufferedImage img) throws IOException { 43 | 44 | logger.info("begin detecting objects from image ..."); 45 | List result = new ArrayList<>(); 46 | 47 | List> outputs = null; 48 | try (Tensor input = TensorUtils.makeImageTensor(img)) { 49 | outputs = 50 | model 51 | .session() 52 | .runner() 53 | .feed("image_tensor", input) 54 | .fetch("detection_scores") 55 | .fetch("detection_classes") 56 | .fetch("detection_boxes") 57 | .run(); 58 | } 59 | try (Tensor scoresT = outputs.get(0).expect(Float.class); 60 | Tensor classesT = outputs.get(1).expect(Float.class); 61 | Tensor boxesT = outputs.get(2).expect(Float.class)) { 62 | // All these tensors have: 63 | // - 1 as the first dimension 64 | // - maxObjects as the second dimension 65 | // While boxesT will have 4 as the third dimension (2 sets of (x, y) coordinates). 66 | // This can be verified by looking at scoresT.shape() etc. 67 | int maxObjects = (int) scoresT.shape()[1]; 68 | float[] scores = scoresT.copyTo(new float[1][maxObjects])[0]; 69 | float[] classes = classesT.copyTo(new float[1][maxObjects])[0]; 70 | float[][] boxes = boxesT.copyTo(new float[1][maxObjects][4])[0]; 71 | for (int i = 0; i < scores.length; ++i) { 72 | if (scores[i] < 0.5) { 73 | continue; 74 | } 75 | String label = labels[(int) classes[i]]; 76 | float score = scores[i]; 77 | float[] box = boxes[i]; 78 | 79 | DetectedObj detectedObj = new DetectedObj(label,score, box); 80 | result.add(detectedObj); 81 | } 82 | } 83 | 84 | logger.info("object detection completed on image"); 85 | 86 | return result; 87 | } 88 | 89 | public void loadModel() throws Exception { 90 | exportModel(); 91 | labels = LabelUtils.loadLabels(); 92 | String modelDirPath = getModelDirPath(); 93 | logger.info("loading model from {} ...", modelDirPath); 94 | this.model = SavedModelBundle.load(modelDirPath, "serve"); 95 | logger.info("model loaded"); 96 | } 97 | 98 | public String getModelDirPath() { 99 | File modelParentDir = new File(modelParentDirPath); 100 | return modelParentDir.getAbsolutePath() + "/" + MODEL_FOLDER_NAME; 101 | } 102 | 103 | 104 | 105 | private void exportModel() { 106 | File modelParentDir = new File(modelParentDirPath); 107 | if(!modelParentDir.exists()){ 108 | modelParentDir.mkdir(); 109 | } 110 | 111 | String modelDirPath = modelParentDir.getAbsolutePath() + "/" + MODEL_FOLDER_NAME; 112 | 113 | String modelPath = modelDirPath + "/saved_model.pb"; 114 | 115 | File modelFile = new File(modelPath); 116 | 117 | if(modelFile.exists()){ 118 | return; 119 | } 120 | 121 | File modelDir = new File(modelDirPath); 122 | if(!modelDir.exists()) { 123 | modelDir.mkdir(); 124 | } 125 | 126 | 127 | String zipFileName = modelParentDir.getAbsolutePath() + "/saved_model.zip"; 128 | try { 129 | 130 | InputStream inStream = FileUtils.getResource("tf_models/saved_model.zip"); 131 | 132 | FileOutputStream outStream = new FileOutputStream(new File(zipFileName)); 133 | 134 | byte[] buffer = new byte[1024]; 135 | 136 | int length; 137 | while ((length = inStream.read(buffer)) > 0){ 138 | outStream.write(buffer, 0, length); 139 | } 140 | 141 | inStream.close(); 142 | outStream.close(); 143 | 144 | ZipFile zipFile = new ZipFile(zipFileName); 145 | zipFile.extractAll(modelDirPath); 146 | } 147 | catch (IOException e) { 148 | logger.error("Failed to copy the saved_model.zip from resources to " + modelParentDirPath, e); 149 | } 150 | catch (ZipException e) { 151 | logger.error("Failed to unzip " + zipFileName, e); 152 | } 153 | } 154 | 155 | 156 | 157 | 158 | @Override 159 | public void close() throws Exception { 160 | if(model != null) { 161 | model.close(); 162 | model = null; 163 | } 164 | } 165 | 166 | public BufferedImage drawDetectedObjects(BufferedImage img) { 167 | List objList; 168 | try { 169 | objList = detectObjects(img); 170 | } catch (IOException e) { 171 | logger.error("Failed to detect objects in image", e); 172 | objList = new ArrayList<>(); 173 | } 174 | 175 | BufferedImage result = new BufferedImage(img.getWidth(), img.getHeight(), img.getType()); 176 | Graphics g = result.getGraphics(); 177 | g.drawImage(img, 0, 0, null); 178 | 179 | g.setColor(Color.red); 180 | 181 | for(DetectedObj obj : objList){ 182 | Box box = obj.getBox(); 183 | int x = (int)(box.getLeft() * img.getWidth()); 184 | int y = (int)(box.getTop() * img.getHeight()); 185 | g.drawString(obj.getLabel(), x, y); 186 | int width = (int)(box.getWidth() * img.getWidth()); 187 | int height = (int)(box.getHeight() * img.getHeight()); 188 | g.drawRect(x, y, width, height); 189 | } 190 | 191 | return result; 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/ObjectDetectorDemo.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect; 2 | 3 | import com.github.chen0040.objdetect.models.DetectedObj; 4 | 5 | import javax.imageio.ImageIO; 6 | import java.awt.image.BufferedImage; 7 | import java.io.File; 8 | import java.util.List; 9 | 10 | public class ObjectDetectorDemo { 11 | public static void main(String[] args) throws Exception { 12 | ObjectDetector detector = new ObjectDetector(); 13 | 14 | detector.loadModel(); 15 | 16 | BufferedImage img = ImageIO.read(new File("images/test.jpg")); 17 | 18 | List result = detector.detectObjects(img); 19 | 20 | System.out.println("There are " + result.size() + " objects detected"); 21 | for(int i=0; i < result.size(); ++i){ 22 | System.out.println("# " + (i + 1) + ": " + result.get(i)); 23 | } 24 | 25 | BufferedImage img2 = detector.drawDetectedObjects(img); 26 | ImageIO.write(img2, "PNG", new File("images/test_output.png")); 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/models/Box.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect.models; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class Box { 9 | 10 | private float left; 11 | private float top; 12 | private float width; 13 | private float height; 14 | 15 | public Box() { 16 | 17 | } 18 | 19 | public Box(float[] box) { 20 | left = box[1]; 21 | top = box[0]; 22 | width = box[3] - box[1]; 23 | height = box[2] - box[0]; 24 | } 25 | 26 | public String toString() { 27 | StringBuilder sb = new StringBuilder(); 28 | sb.append("("); 29 | sb.append("left: ").append(left).append(", "); 30 | sb.append("top: ").append(top).append(", "); 31 | sb.append("width: ").append(width).append(", "); 32 | sb.append("height: ").append(height); 33 | sb.append(")"); 34 | return sb.toString(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/models/DetectedObj.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect.models; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class DetectedObj { 9 | private String label; 10 | private float score; 11 | 12 | private Box box = new Box(); 13 | 14 | public DetectedObj(){ 15 | 16 | } 17 | 18 | public DetectedObj(String label, float score, float[] box) { 19 | this.label = label; 20 | this.score = score; 21 | this.box = new Box(box); 22 | } 23 | @Override 24 | public String toString() { 25 | return "{ label: " + label + ", score: " + score + ", box: " + box + " }"; 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/utils/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect.utils; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.io.ByteArrayOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.net.URL; 11 | 12 | 13 | /** 14 | * Created by xschen on 8/4/2017. 15 | */ 16 | public class FileUtils { 17 | 18 | private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); 19 | 20 | public static InputStream getResource(String filename) throws IOException { 21 | ClassLoader classLoader = FileUtils.class.getClassLoader(); 22 | URL dataFile = classLoader.getResource(filename); 23 | return dataFile.openStream(); 24 | } 25 | 26 | 27 | public static InputStream getResourceStream(String filename) { 28 | ClassLoader classLoader = FileUtils.class.getClassLoader(); 29 | return classLoader.getResourceAsStream(filename); 30 | } 31 | 32 | 33 | public static byte[] getBytes(String filename) { 34 | InputStream inputStream = getResourceStream(filename); 35 | 36 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 37 | byte[] buffer = new byte[1024]; 38 | int length = 0; 39 | try { 40 | while((length = inputStream.read(buffer)) > 0){ 41 | baos.write(buffer, 0, length); 42 | } 43 | } 44 | catch (IOException e) { 45 | logger.error("Failed to get bytes from " + filename, e); 46 | } 47 | return baos.toByteArray(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/utils/LabelUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect.utils; 2 | 3 | import com.google.protobuf.TextFormat; 4 | import object_detection.protos.StringIntLabelMapOuterClass; 5 | 6 | import java.nio.charset.StandardCharsets; 7 | import java.nio.file.Files; 8 | import java.nio.file.Paths; 9 | 10 | public class LabelUtils { 11 | public static String[] loadLabels() throws Exception { 12 | String text = new String(FileUtils.getBytes("labels/mscoco_label_map.pbtxt"), StandardCharsets.UTF_8); 13 | StringIntLabelMapOuterClass.StringIntLabelMap.Builder builder = StringIntLabelMapOuterClass.StringIntLabelMap.newBuilder(); 14 | TextFormat.merge(text, builder); 15 | StringIntLabelMapOuterClass.StringIntLabelMap proto = builder.build(); 16 | int maxId = 0; 17 | for (StringIntLabelMapOuterClass.StringIntLabelMapItem item : proto.getItemList()) { 18 | if (item.getId() > maxId) { 19 | maxId = item.getId(); 20 | } 21 | } 22 | String[] ret = new String[maxId + 1]; 23 | for (StringIntLabelMapOuterClass.StringIntLabelMapItem item : proto.getItemList()) { 24 | ret[item.getId()] = item.getDisplayName(); 25 | } 26 | return ret; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/utils/SavedModelUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect.utils; 2 | 3 | import org.tensorflow.SavedModelBundle; 4 | import org.tensorflow.framework.MetaGraphDef; 5 | import org.tensorflow.framework.SignatureDef; 6 | import org.tensorflow.framework.TensorInfo; 7 | 8 | import java.util.Map; 9 | 10 | public class SavedModelUtils { 11 | public static String getSignature(SavedModelBundle model) throws Exception { 12 | MetaGraphDef m = MetaGraphDef.parseFrom(model.metaGraphDef()); 13 | SignatureDef sig = m.getSignatureDefOrThrow("serving_default"); 14 | int numInputs = sig.getInputsCount(); 15 | int i = 1; 16 | StringBuilder sb = new StringBuilder(); 17 | sb.append("MODEL SIGNATURE\n"); 18 | sb.append("Inputs:\n"); 19 | for (Map.Entry entry : sig.getInputsMap().entrySet()) { 20 | TensorInfo t = entry.getValue(); 21 | sb.append(String.format( 22 | "%d of %d: %-20s (Node name in graph: %-20s, type: %s)\n", 23 | i++, numInputs, entry.getKey(), t.getName(), t.getDtype())); 24 | } 25 | int numOutputs = sig.getOutputsCount(); 26 | i = 1; 27 | System.out.println("Outputs:"); 28 | for (Map.Entry entry : sig.getOutputsMap().entrySet()) { 29 | TensorInfo t = entry.getValue(); 30 | sb.append(String.format( 31 | "%d of %d: %-20s (Node name in graph: %-20s, type: %s)\n", 32 | i++, numOutputs, entry.getKey(), t.getName(), t.getDtype())); 33 | } 34 | sb.append("-----------------------------------------------"); 35 | return sb.toString(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/github/chen0040/objdetect/utils/TensorUtils.java: -------------------------------------------------------------------------------- 1 | package com.github.chen0040.objdetect.utils; 2 | 3 | import org.tensorflow.Tensor; 4 | import org.tensorflow.types.UInt8; 5 | 6 | import javax.imageio.ImageIO; 7 | import java.awt.image.BufferedImage; 8 | import java.awt.image.DataBufferByte; 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.nio.ByteBuffer; 12 | 13 | public class TensorUtils { 14 | 15 | private static void bgr2rgb(byte[] data) { 16 | for (int i = 0; i < data.length; i += 3) { 17 | byte tmp = data[i]; 18 | data[i] = data[i + 2]; 19 | data[i + 2] = tmp; 20 | } 21 | } 22 | 23 | 24 | public static Tensor makeImageTensor(BufferedImage img) throws IOException { 25 | 26 | if (img.getType() != BufferedImage.TYPE_3BYTE_BGR) { 27 | throw new IOException( 28 | String.format( 29 | "Expected 3-byte BGR encoding in BufferedImage, found %d. This code could be made more robust", 30 | img.getType())); 31 | } 32 | byte[] data = ((DataBufferByte) img.getData().getDataBuffer()).getData(); 33 | // ImageIO.read seems to produce BGR-encoded images, but the model expects RGB. 34 | bgr2rgb(data); 35 | final long BATCH_SIZE = 1; 36 | final long CHANNELS = 3; 37 | long[] shape = new long[] {BATCH_SIZE, img.getHeight(), img.getWidth(), CHANNELS}; 38 | return Tensor.create(UInt8.class, shape, ByteBuffer.wrap(data)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/object_detection/protos/StringIntLabelMapOuterClass.java: -------------------------------------------------------------------------------- 1 | package object_detection.protos; 2 | 3 | // Generated by the protocol buffer compiler. DO NOT EDIT! 4 | // source: string_int_label_map.proto 5 | 6 | public final class StringIntLabelMapOuterClass { 7 | private StringIntLabelMapOuterClass() {} 8 | public static void registerAllExtensions( 9 | com.google.protobuf.ExtensionRegistryLite registry) { 10 | } 11 | 12 | public static void registerAllExtensions( 13 | com.google.protobuf.ExtensionRegistry registry) { 14 | registerAllExtensions( 15 | (com.google.protobuf.ExtensionRegistryLite) registry); 16 | } 17 | public interface StringIntLabelMapItemOrBuilder extends 18 | // @@protoc_insertion_point(interface_extends:object_detection.protos.StringIntLabelMapItem) 19 | com.google.protobuf.MessageOrBuilder { 20 | 21 | /** 22 | *
  23 |          * String name. The most common practice is to set this to a MID or synsets
  24 |          * id.
  25 |          * 
26 | * 27 | * optional string name = 1; 28 | */ 29 | boolean hasName(); 30 | /** 31 | *
  32 |          * String name. The most common practice is to set this to a MID or synsets
  33 |          * id.
  34 |          * 
35 | * 36 | * optional string name = 1; 37 | */ 38 | java.lang.String getName(); 39 | /** 40 | *
  41 |          * String name. The most common practice is to set this to a MID or synsets
  42 |          * id.
  43 |          * 
44 | * 45 | * optional string name = 1; 46 | */ 47 | com.google.protobuf.ByteString 48 | getNameBytes(); 49 | 50 | /** 51 | *
  52 |          * Integer id that maps to the string name above. Label ids should start from
  53 |          * 1.
  54 |          * 
55 | * 56 | * optional int32 id = 2; 57 | */ 58 | boolean hasId(); 59 | /** 60 | *
  61 |          * Integer id that maps to the string name above. Label ids should start from
  62 |          * 1.
  63 |          * 
64 | * 65 | * optional int32 id = 2; 66 | */ 67 | int getId(); 68 | 69 | /** 70 | *
  71 |          * Human readable string label.
  72 |          * 
73 | * 74 | * optional string display_name = 3; 75 | */ 76 | boolean hasDisplayName(); 77 | /** 78 | *
  79 |          * Human readable string label.
  80 |          * 
81 | * 82 | * optional string display_name = 3; 83 | */ 84 | java.lang.String getDisplayName(); 85 | /** 86 | *
  87 |          * Human readable string label.
  88 |          * 
89 | * 90 | * optional string display_name = 3; 91 | */ 92 | com.google.protobuf.ByteString 93 | getDisplayNameBytes(); 94 | } 95 | /** 96 | * Protobuf type {@code object_detection.protos.StringIntLabelMapItem} 97 | */ 98 | public static final class StringIntLabelMapItem extends 99 | com.google.protobuf.GeneratedMessageV3 implements 100 | // @@protoc_insertion_point(message_implements:object_detection.protos.StringIntLabelMapItem) 101 | StringIntLabelMapItemOrBuilder { 102 | private static final long serialVersionUID = 0L; 103 | // Use StringIntLabelMapItem.newBuilder() to construct. 104 | private StringIntLabelMapItem(com.google.protobuf.GeneratedMessageV3.Builder builder) { 105 | super(builder); 106 | } 107 | private StringIntLabelMapItem() { 108 | name_ = ""; 109 | id_ = 0; 110 | displayName_ = ""; 111 | } 112 | 113 | @java.lang.Override 114 | public final com.google.protobuf.UnknownFieldSet 115 | getUnknownFields() { 116 | return this.unknownFields; 117 | } 118 | private StringIntLabelMapItem( 119 | com.google.protobuf.CodedInputStream input, 120 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 121 | throws com.google.protobuf.InvalidProtocolBufferException { 122 | this(); 123 | if (extensionRegistry == null) { 124 | throw new java.lang.NullPointerException(); 125 | } 126 | int mutable_bitField0_ = 0; 127 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 128 | com.google.protobuf.UnknownFieldSet.newBuilder(); 129 | try { 130 | boolean done = false; 131 | while (!done) { 132 | int tag = input.readTag(); 133 | switch (tag) { 134 | case 0: 135 | done = true; 136 | break; 137 | default: { 138 | if (!parseUnknownField( 139 | input, unknownFields, extensionRegistry, tag)) { 140 | done = true; 141 | } 142 | break; 143 | } 144 | case 10: { 145 | com.google.protobuf.ByteString bs = input.readBytes(); 146 | bitField0_ |= 0x00000001; 147 | name_ = bs; 148 | break; 149 | } 150 | case 16: { 151 | bitField0_ |= 0x00000002; 152 | id_ = input.readInt32(); 153 | break; 154 | } 155 | case 26: { 156 | com.google.protobuf.ByteString bs = input.readBytes(); 157 | bitField0_ |= 0x00000004; 158 | displayName_ = bs; 159 | break; 160 | } 161 | } 162 | } 163 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 164 | throw e.setUnfinishedMessage(this); 165 | } catch (java.io.IOException e) { 166 | throw new com.google.protobuf.InvalidProtocolBufferException( 167 | e).setUnfinishedMessage(this); 168 | } finally { 169 | this.unknownFields = unknownFields.build(); 170 | makeExtensionsImmutable(); 171 | } 172 | } 173 | public static final com.google.protobuf.Descriptors.Descriptor 174 | getDescriptor() { 175 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMapItem_descriptor; 176 | } 177 | 178 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 179 | internalGetFieldAccessorTable() { 180 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMapItem_fieldAccessorTable 181 | .ensureFieldAccessorsInitialized( 182 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.class, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder.class); 183 | } 184 | 185 | private int bitField0_; 186 | public static final int NAME_FIELD_NUMBER = 1; 187 | private volatile java.lang.Object name_; 188 | /** 189 | *
 190 |          * String name. The most common practice is to set this to a MID or synsets
 191 |          * id.
 192 |          * 
193 | * 194 | * optional string name = 1; 195 | */ 196 | public boolean hasName() { 197 | return ((bitField0_ & 0x00000001) == 0x00000001); 198 | } 199 | /** 200 | *
 201 |          * String name. The most common practice is to set this to a MID or synsets
 202 |          * id.
 203 |          * 
204 | * 205 | * optional string name = 1; 206 | */ 207 | public java.lang.String getName() { 208 | java.lang.Object ref = name_; 209 | if (ref instanceof java.lang.String) { 210 | return (java.lang.String) ref; 211 | } else { 212 | com.google.protobuf.ByteString bs = 213 | (com.google.protobuf.ByteString) ref; 214 | java.lang.String s = bs.toStringUtf8(); 215 | if (bs.isValidUtf8()) { 216 | name_ = s; 217 | } 218 | return s; 219 | } 220 | } 221 | /** 222 | *
 223 |          * String name. The most common practice is to set this to a MID or synsets
 224 |          * id.
 225 |          * 
226 | * 227 | * optional string name = 1; 228 | */ 229 | public com.google.protobuf.ByteString 230 | getNameBytes() { 231 | java.lang.Object ref = name_; 232 | if (ref instanceof java.lang.String) { 233 | com.google.protobuf.ByteString b = 234 | com.google.protobuf.ByteString.copyFromUtf8( 235 | (java.lang.String) ref); 236 | name_ = b; 237 | return b; 238 | } else { 239 | return (com.google.protobuf.ByteString) ref; 240 | } 241 | } 242 | 243 | public static final int ID_FIELD_NUMBER = 2; 244 | private int id_; 245 | /** 246 | *
 247 |          * Integer id that maps to the string name above. Label ids should start from
 248 |          * 1.
 249 |          * 
250 | * 251 | * optional int32 id = 2; 252 | */ 253 | public boolean hasId() { 254 | return ((bitField0_ & 0x00000002) == 0x00000002); 255 | } 256 | /** 257 | *
 258 |          * Integer id that maps to the string name above. Label ids should start from
 259 |          * 1.
 260 |          * 
261 | * 262 | * optional int32 id = 2; 263 | */ 264 | public int getId() { 265 | return id_; 266 | } 267 | 268 | public static final int DISPLAY_NAME_FIELD_NUMBER = 3; 269 | private volatile java.lang.Object displayName_; 270 | /** 271 | *
 272 |          * Human readable string label.
 273 |          * 
274 | * 275 | * optional string display_name = 3; 276 | */ 277 | public boolean hasDisplayName() { 278 | return ((bitField0_ & 0x00000004) == 0x00000004); 279 | } 280 | /** 281 | *
 282 |          * Human readable string label.
 283 |          * 
284 | * 285 | * optional string display_name = 3; 286 | */ 287 | public java.lang.String getDisplayName() { 288 | java.lang.Object ref = displayName_; 289 | if (ref instanceof java.lang.String) { 290 | return (java.lang.String) ref; 291 | } else { 292 | com.google.protobuf.ByteString bs = 293 | (com.google.protobuf.ByteString) ref; 294 | java.lang.String s = bs.toStringUtf8(); 295 | if (bs.isValidUtf8()) { 296 | displayName_ = s; 297 | } 298 | return s; 299 | } 300 | } 301 | /** 302 | *
 303 |          * Human readable string label.
 304 |          * 
305 | * 306 | * optional string display_name = 3; 307 | */ 308 | public com.google.protobuf.ByteString 309 | getDisplayNameBytes() { 310 | java.lang.Object ref = displayName_; 311 | if (ref instanceof java.lang.String) { 312 | com.google.protobuf.ByteString b = 313 | com.google.protobuf.ByteString.copyFromUtf8( 314 | (java.lang.String) ref); 315 | displayName_ = b; 316 | return b; 317 | } else { 318 | return (com.google.protobuf.ByteString) ref; 319 | } 320 | } 321 | 322 | private byte memoizedIsInitialized = -1; 323 | public final boolean isInitialized() { 324 | byte isInitialized = memoizedIsInitialized; 325 | if (isInitialized == 1) return true; 326 | if (isInitialized == 0) return false; 327 | 328 | memoizedIsInitialized = 1; 329 | return true; 330 | } 331 | 332 | public void writeTo(com.google.protobuf.CodedOutputStream output) 333 | throws java.io.IOException { 334 | if (((bitField0_ & 0x00000001) == 0x00000001)) { 335 | com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); 336 | } 337 | if (((bitField0_ & 0x00000002) == 0x00000002)) { 338 | output.writeInt32(2, id_); 339 | } 340 | if (((bitField0_ & 0x00000004) == 0x00000004)) { 341 | com.google.protobuf.GeneratedMessageV3.writeString(output, 3, displayName_); 342 | } 343 | unknownFields.writeTo(output); 344 | } 345 | 346 | public int getSerializedSize() { 347 | int size = memoizedSize; 348 | if (size != -1) return size; 349 | 350 | size = 0; 351 | if (((bitField0_ & 0x00000001) == 0x00000001)) { 352 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); 353 | } 354 | if (((bitField0_ & 0x00000002) == 0x00000002)) { 355 | size += com.google.protobuf.CodedOutputStream 356 | .computeInt32Size(2, id_); 357 | } 358 | if (((bitField0_ & 0x00000004) == 0x00000004)) { 359 | size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, displayName_); 360 | } 361 | size += unknownFields.getSerializedSize(); 362 | memoizedSize = size; 363 | return size; 364 | } 365 | 366 | @java.lang.Override 367 | public boolean equals(final java.lang.Object obj) { 368 | if (obj == this) { 369 | return true; 370 | } 371 | if (!(obj instanceof object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem)) { 372 | return super.equals(obj); 373 | } 374 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem other = (object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem) obj; 375 | 376 | boolean result = true; 377 | result = result && (hasName() == other.hasName()); 378 | if (hasName()) { 379 | result = result && getName() 380 | .equals(other.getName()); 381 | } 382 | result = result && (hasId() == other.hasId()); 383 | if (hasId()) { 384 | result = result && (getId() 385 | == other.getId()); 386 | } 387 | result = result && (hasDisplayName() == other.hasDisplayName()); 388 | if (hasDisplayName()) { 389 | result = result && getDisplayName() 390 | .equals(other.getDisplayName()); 391 | } 392 | result = result && unknownFields.equals(other.unknownFields); 393 | return result; 394 | } 395 | 396 | @java.lang.Override 397 | public int hashCode() { 398 | if (memoizedHashCode != 0) { 399 | return memoizedHashCode; 400 | } 401 | int hash = 41; 402 | hash = (19 * hash) + getDescriptor().hashCode(); 403 | if (hasName()) { 404 | hash = (37 * hash) + NAME_FIELD_NUMBER; 405 | hash = (53 * hash) + getName().hashCode(); 406 | } 407 | if (hasId()) { 408 | hash = (37 * hash) + ID_FIELD_NUMBER; 409 | hash = (53 * hash) + getId(); 410 | } 411 | if (hasDisplayName()) { 412 | hash = (37 * hash) + DISPLAY_NAME_FIELD_NUMBER; 413 | hash = (53 * hash) + getDisplayName().hashCode(); 414 | } 415 | hash = (29 * hash) + unknownFields.hashCode(); 416 | memoizedHashCode = hash; 417 | return hash; 418 | } 419 | 420 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 421 | java.nio.ByteBuffer data) 422 | throws com.google.protobuf.InvalidProtocolBufferException { 423 | return PARSER.parseFrom(data); 424 | } 425 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 426 | java.nio.ByteBuffer data, 427 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 428 | throws com.google.protobuf.InvalidProtocolBufferException { 429 | return PARSER.parseFrom(data, extensionRegistry); 430 | } 431 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 432 | com.google.protobuf.ByteString data) 433 | throws com.google.protobuf.InvalidProtocolBufferException { 434 | return PARSER.parseFrom(data); 435 | } 436 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 437 | com.google.protobuf.ByteString data, 438 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 439 | throws com.google.protobuf.InvalidProtocolBufferException { 440 | return PARSER.parseFrom(data, extensionRegistry); 441 | } 442 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom(byte[] data) 443 | throws com.google.protobuf.InvalidProtocolBufferException { 444 | return PARSER.parseFrom(data); 445 | } 446 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 447 | byte[] data, 448 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 449 | throws com.google.protobuf.InvalidProtocolBufferException { 450 | return PARSER.parseFrom(data, extensionRegistry); 451 | } 452 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom(java.io.InputStream input) 453 | throws java.io.IOException { 454 | return com.google.protobuf.GeneratedMessageV3 455 | .parseWithIOException(PARSER, input); 456 | } 457 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 458 | java.io.InputStream input, 459 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 460 | throws java.io.IOException { 461 | return com.google.protobuf.GeneratedMessageV3 462 | .parseWithIOException(PARSER, input, extensionRegistry); 463 | } 464 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseDelimitedFrom(java.io.InputStream input) 465 | throws java.io.IOException { 466 | return com.google.protobuf.GeneratedMessageV3 467 | .parseDelimitedWithIOException(PARSER, input); 468 | } 469 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseDelimitedFrom( 470 | java.io.InputStream input, 471 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 472 | throws java.io.IOException { 473 | return com.google.protobuf.GeneratedMessageV3 474 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 475 | } 476 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 477 | com.google.protobuf.CodedInputStream input) 478 | throws java.io.IOException { 479 | return com.google.protobuf.GeneratedMessageV3 480 | .parseWithIOException(PARSER, input); 481 | } 482 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parseFrom( 483 | com.google.protobuf.CodedInputStream input, 484 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 485 | throws java.io.IOException { 486 | return com.google.protobuf.GeneratedMessageV3 487 | .parseWithIOException(PARSER, input, extensionRegistry); 488 | } 489 | 490 | public Builder newBuilderForType() { return newBuilder(); } 491 | public static Builder newBuilder() { 492 | return DEFAULT_INSTANCE.toBuilder(); 493 | } 494 | public static Builder newBuilder(object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem prototype) { 495 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 496 | } 497 | public Builder toBuilder() { 498 | return this == DEFAULT_INSTANCE 499 | ? new Builder() : new Builder().mergeFrom(this); 500 | } 501 | 502 | @java.lang.Override 503 | protected Builder newBuilderForType( 504 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 505 | Builder builder = new Builder(parent); 506 | return builder; 507 | } 508 | /** 509 | * Protobuf type {@code object_detection.protos.StringIntLabelMapItem} 510 | */ 511 | public static final class Builder extends 512 | com.google.protobuf.GeneratedMessageV3.Builder implements 513 | // @@protoc_insertion_point(builder_implements:object_detection.protos.StringIntLabelMapItem) 514 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder { 515 | public static final com.google.protobuf.Descriptors.Descriptor 516 | getDescriptor() { 517 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMapItem_descriptor; 518 | } 519 | 520 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 521 | internalGetFieldAccessorTable() { 522 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMapItem_fieldAccessorTable 523 | .ensureFieldAccessorsInitialized( 524 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.class, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder.class); 525 | } 526 | 527 | // Construct using object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.newBuilder() 528 | private Builder() { 529 | maybeForceBuilderInitialization(); 530 | } 531 | 532 | private Builder( 533 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 534 | super(parent); 535 | maybeForceBuilderInitialization(); 536 | } 537 | private void maybeForceBuilderInitialization() { 538 | if (com.google.protobuf.GeneratedMessageV3 539 | .alwaysUseFieldBuilders) { 540 | } 541 | } 542 | public Builder clear() { 543 | super.clear(); 544 | name_ = ""; 545 | bitField0_ = (bitField0_ & ~0x00000001); 546 | id_ = 0; 547 | bitField0_ = (bitField0_ & ~0x00000002); 548 | displayName_ = ""; 549 | bitField0_ = (bitField0_ & ~0x00000004); 550 | return this; 551 | } 552 | 553 | public com.google.protobuf.Descriptors.Descriptor 554 | getDescriptorForType() { 555 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMapItem_descriptor; 556 | } 557 | 558 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem getDefaultInstanceForType() { 559 | return object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.getDefaultInstance(); 560 | } 561 | 562 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem build() { 563 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem result = buildPartial(); 564 | if (!result.isInitialized()) { 565 | throw newUninitializedMessageException(result); 566 | } 567 | return result; 568 | } 569 | 570 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem buildPartial() { 571 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem result = new object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem(this); 572 | int from_bitField0_ = bitField0_; 573 | int to_bitField0_ = 0; 574 | if (((from_bitField0_ & 0x00000001) == 0x00000001)) { 575 | to_bitField0_ |= 0x00000001; 576 | } 577 | result.name_ = name_; 578 | if (((from_bitField0_ & 0x00000002) == 0x00000002)) { 579 | to_bitField0_ |= 0x00000002; 580 | } 581 | result.id_ = id_; 582 | if (((from_bitField0_ & 0x00000004) == 0x00000004)) { 583 | to_bitField0_ |= 0x00000004; 584 | } 585 | result.displayName_ = displayName_; 586 | result.bitField0_ = to_bitField0_; 587 | onBuilt(); 588 | return result; 589 | } 590 | 591 | public Builder clone() { 592 | return (Builder) super.clone(); 593 | } 594 | public Builder setField( 595 | com.google.protobuf.Descriptors.FieldDescriptor field, 596 | java.lang.Object value) { 597 | return (Builder) super.setField(field, value); 598 | } 599 | public Builder clearField( 600 | com.google.protobuf.Descriptors.FieldDescriptor field) { 601 | return (Builder) super.clearField(field); 602 | } 603 | public Builder clearOneof( 604 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 605 | return (Builder) super.clearOneof(oneof); 606 | } 607 | public Builder setRepeatedField( 608 | com.google.protobuf.Descriptors.FieldDescriptor field, 609 | int index, java.lang.Object value) { 610 | return (Builder) super.setRepeatedField(field, index, value); 611 | } 612 | public Builder addRepeatedField( 613 | com.google.protobuf.Descriptors.FieldDescriptor field, 614 | java.lang.Object value) { 615 | return (Builder) super.addRepeatedField(field, value); 616 | } 617 | public Builder mergeFrom(com.google.protobuf.Message other) { 618 | if (other instanceof object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem) { 619 | return mergeFrom((object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem)other); 620 | } else { 621 | super.mergeFrom(other); 622 | return this; 623 | } 624 | } 625 | 626 | public Builder mergeFrom(object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem other) { 627 | if (other == object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.getDefaultInstance()) return this; 628 | if (other.hasName()) { 629 | bitField0_ |= 0x00000001; 630 | name_ = other.name_; 631 | onChanged(); 632 | } 633 | if (other.hasId()) { 634 | setId(other.getId()); 635 | } 636 | if (other.hasDisplayName()) { 637 | bitField0_ |= 0x00000004; 638 | displayName_ = other.displayName_; 639 | onChanged(); 640 | } 641 | this.mergeUnknownFields(other.unknownFields); 642 | onChanged(); 643 | return this; 644 | } 645 | 646 | public final boolean isInitialized() { 647 | return true; 648 | } 649 | 650 | public Builder mergeFrom( 651 | com.google.protobuf.CodedInputStream input, 652 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 653 | throws java.io.IOException { 654 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem parsedMessage = null; 655 | try { 656 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 657 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 658 | parsedMessage = (object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem) e.getUnfinishedMessage(); 659 | throw e.unwrapIOException(); 660 | } finally { 661 | if (parsedMessage != null) { 662 | mergeFrom(parsedMessage); 663 | } 664 | } 665 | return this; 666 | } 667 | private int bitField0_; 668 | 669 | private java.lang.Object name_ = ""; 670 | /** 671 | *
 672 |              * String name. The most common practice is to set this to a MID or synsets
 673 |              * id.
 674 |              * 
675 | * 676 | * optional string name = 1; 677 | */ 678 | public boolean hasName() { 679 | return ((bitField0_ & 0x00000001) == 0x00000001); 680 | } 681 | /** 682 | *
 683 |              * String name. The most common practice is to set this to a MID or synsets
 684 |              * id.
 685 |              * 
686 | * 687 | * optional string name = 1; 688 | */ 689 | public java.lang.String getName() { 690 | java.lang.Object ref = name_; 691 | if (!(ref instanceof java.lang.String)) { 692 | com.google.protobuf.ByteString bs = 693 | (com.google.protobuf.ByteString) ref; 694 | java.lang.String s = bs.toStringUtf8(); 695 | if (bs.isValidUtf8()) { 696 | name_ = s; 697 | } 698 | return s; 699 | } else { 700 | return (java.lang.String) ref; 701 | } 702 | } 703 | /** 704 | *
 705 |              * String name. The most common practice is to set this to a MID or synsets
 706 |              * id.
 707 |              * 
708 | * 709 | * optional string name = 1; 710 | */ 711 | public com.google.protobuf.ByteString 712 | getNameBytes() { 713 | java.lang.Object ref = name_; 714 | if (ref instanceof String) { 715 | com.google.protobuf.ByteString b = 716 | com.google.protobuf.ByteString.copyFromUtf8( 717 | (java.lang.String) ref); 718 | name_ = b; 719 | return b; 720 | } else { 721 | return (com.google.protobuf.ByteString) ref; 722 | } 723 | } 724 | /** 725 | *
 726 |              * String name. The most common practice is to set this to a MID or synsets
 727 |              * id.
 728 |              * 
729 | * 730 | * optional string name = 1; 731 | */ 732 | public Builder setName( 733 | java.lang.String value) { 734 | if (value == null) { 735 | throw new NullPointerException(); 736 | } 737 | bitField0_ |= 0x00000001; 738 | name_ = value; 739 | onChanged(); 740 | return this; 741 | } 742 | /** 743 | *
 744 |              * String name. The most common practice is to set this to a MID or synsets
 745 |              * id.
 746 |              * 
747 | * 748 | * optional string name = 1; 749 | */ 750 | public Builder clearName() { 751 | bitField0_ = (bitField0_ & ~0x00000001); 752 | name_ = getDefaultInstance().getName(); 753 | onChanged(); 754 | return this; 755 | } 756 | /** 757 | *
 758 |              * String name. The most common practice is to set this to a MID or synsets
 759 |              * id.
 760 |              * 
761 | * 762 | * optional string name = 1; 763 | */ 764 | public Builder setNameBytes( 765 | com.google.protobuf.ByteString value) { 766 | if (value == null) { 767 | throw new NullPointerException(); 768 | } 769 | bitField0_ |= 0x00000001; 770 | name_ = value; 771 | onChanged(); 772 | return this; 773 | } 774 | 775 | private int id_ ; 776 | /** 777 | *
 778 |              * Integer id that maps to the string name above. Label ids should start from
 779 |              * 1.
 780 |              * 
781 | * 782 | * optional int32 id = 2; 783 | */ 784 | public boolean hasId() { 785 | return ((bitField0_ & 0x00000002) == 0x00000002); 786 | } 787 | /** 788 | *
 789 |              * Integer id that maps to the string name above. Label ids should start from
 790 |              * 1.
 791 |              * 
792 | * 793 | * optional int32 id = 2; 794 | */ 795 | public int getId() { 796 | return id_; 797 | } 798 | /** 799 | *
 800 |              * Integer id that maps to the string name above. Label ids should start from
 801 |              * 1.
 802 |              * 
803 | * 804 | * optional int32 id = 2; 805 | */ 806 | public Builder setId(int value) { 807 | bitField0_ |= 0x00000002; 808 | id_ = value; 809 | onChanged(); 810 | return this; 811 | } 812 | /** 813 | *
 814 |              * Integer id that maps to the string name above. Label ids should start from
 815 |              * 1.
 816 |              * 
817 | * 818 | * optional int32 id = 2; 819 | */ 820 | public Builder clearId() { 821 | bitField0_ = (bitField0_ & ~0x00000002); 822 | id_ = 0; 823 | onChanged(); 824 | return this; 825 | } 826 | 827 | private java.lang.Object displayName_ = ""; 828 | /** 829 | *
 830 |              * Human readable string label.
 831 |              * 
832 | * 833 | * optional string display_name = 3; 834 | */ 835 | public boolean hasDisplayName() { 836 | return ((bitField0_ & 0x00000004) == 0x00000004); 837 | } 838 | /** 839 | *
 840 |              * Human readable string label.
 841 |              * 
842 | * 843 | * optional string display_name = 3; 844 | */ 845 | public java.lang.String getDisplayName() { 846 | java.lang.Object ref = displayName_; 847 | if (!(ref instanceof java.lang.String)) { 848 | com.google.protobuf.ByteString bs = 849 | (com.google.protobuf.ByteString) ref; 850 | java.lang.String s = bs.toStringUtf8(); 851 | if (bs.isValidUtf8()) { 852 | displayName_ = s; 853 | } 854 | return s; 855 | } else { 856 | return (java.lang.String) ref; 857 | } 858 | } 859 | /** 860 | *
 861 |              * Human readable string label.
 862 |              * 
863 | * 864 | * optional string display_name = 3; 865 | */ 866 | public com.google.protobuf.ByteString 867 | getDisplayNameBytes() { 868 | java.lang.Object ref = displayName_; 869 | if (ref instanceof String) { 870 | com.google.protobuf.ByteString b = 871 | com.google.protobuf.ByteString.copyFromUtf8( 872 | (java.lang.String) ref); 873 | displayName_ = b; 874 | return b; 875 | } else { 876 | return (com.google.protobuf.ByteString) ref; 877 | } 878 | } 879 | /** 880 | *
 881 |              * Human readable string label.
 882 |              * 
883 | * 884 | * optional string display_name = 3; 885 | */ 886 | public Builder setDisplayName( 887 | java.lang.String value) { 888 | if (value == null) { 889 | throw new NullPointerException(); 890 | } 891 | bitField0_ |= 0x00000004; 892 | displayName_ = value; 893 | onChanged(); 894 | return this; 895 | } 896 | /** 897 | *
 898 |              * Human readable string label.
 899 |              * 
900 | * 901 | * optional string display_name = 3; 902 | */ 903 | public Builder clearDisplayName() { 904 | bitField0_ = (bitField0_ & ~0x00000004); 905 | displayName_ = getDefaultInstance().getDisplayName(); 906 | onChanged(); 907 | return this; 908 | } 909 | /** 910 | *
 911 |              * Human readable string label.
 912 |              * 
913 | * 914 | * optional string display_name = 3; 915 | */ 916 | public Builder setDisplayNameBytes( 917 | com.google.protobuf.ByteString value) { 918 | if (value == null) { 919 | throw new NullPointerException(); 920 | } 921 | bitField0_ |= 0x00000004; 922 | displayName_ = value; 923 | onChanged(); 924 | return this; 925 | } 926 | public final Builder setUnknownFields( 927 | final com.google.protobuf.UnknownFieldSet unknownFields) { 928 | return super.setUnknownFields(unknownFields); 929 | } 930 | 931 | public final Builder mergeUnknownFields( 932 | final com.google.protobuf.UnknownFieldSet unknownFields) { 933 | return super.mergeUnknownFields(unknownFields); 934 | } 935 | 936 | 937 | // @@protoc_insertion_point(builder_scope:object_detection.protos.StringIntLabelMapItem) 938 | } 939 | 940 | // @@protoc_insertion_point(class_scope:object_detection.protos.StringIntLabelMapItem) 941 | private static final object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem DEFAULT_INSTANCE; 942 | static { 943 | DEFAULT_INSTANCE = new object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem(); 944 | } 945 | 946 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem getDefaultInstance() { 947 | return DEFAULT_INSTANCE; 948 | } 949 | 950 | @java.lang.Deprecated public static final com.google.protobuf.Parser 951 | PARSER = new com.google.protobuf.AbstractParser() { 952 | public StringIntLabelMapItem parsePartialFrom( 953 | com.google.protobuf.CodedInputStream input, 954 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 955 | throws com.google.protobuf.InvalidProtocolBufferException { 956 | return new StringIntLabelMapItem(input, extensionRegistry); 957 | } 958 | }; 959 | 960 | public static com.google.protobuf.Parser parser() { 961 | return PARSER; 962 | } 963 | 964 | @java.lang.Override 965 | public com.google.protobuf.Parser getParserForType() { 966 | return PARSER; 967 | } 968 | 969 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem getDefaultInstanceForType() { 970 | return DEFAULT_INSTANCE; 971 | } 972 | 973 | } 974 | 975 | public interface StringIntLabelMapOrBuilder extends 976 | // @@protoc_insertion_point(interface_extends:object_detection.protos.StringIntLabelMap) 977 | com.google.protobuf.MessageOrBuilder { 978 | 979 | /** 980 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 981 | */ 982 | java.util.List 983 | getItemList(); 984 | /** 985 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 986 | */ 987 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem getItem(int index); 988 | /** 989 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 990 | */ 991 | int getItemCount(); 992 | /** 993 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 994 | */ 995 | java.util.List 996 | getItemOrBuilderList(); 997 | /** 998 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 999 | */ 1000 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder getItemOrBuilder( 1001 | int index); 1002 | } 1003 | /** 1004 | * Protobuf type {@code object_detection.protos.StringIntLabelMap} 1005 | */ 1006 | public static final class StringIntLabelMap extends 1007 | com.google.protobuf.GeneratedMessageV3 implements 1008 | // @@protoc_insertion_point(message_implements:object_detection.protos.StringIntLabelMap) 1009 | StringIntLabelMapOrBuilder { 1010 | private static final long serialVersionUID = 0L; 1011 | // Use StringIntLabelMap.newBuilder() to construct. 1012 | private StringIntLabelMap(com.google.protobuf.GeneratedMessageV3.Builder builder) { 1013 | super(builder); 1014 | } 1015 | private StringIntLabelMap() { 1016 | item_ = java.util.Collections.emptyList(); 1017 | } 1018 | 1019 | @java.lang.Override 1020 | public final com.google.protobuf.UnknownFieldSet 1021 | getUnknownFields() { 1022 | return this.unknownFields; 1023 | } 1024 | private StringIntLabelMap( 1025 | com.google.protobuf.CodedInputStream input, 1026 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1027 | throws com.google.protobuf.InvalidProtocolBufferException { 1028 | this(); 1029 | if (extensionRegistry == null) { 1030 | throw new java.lang.NullPointerException(); 1031 | } 1032 | int mutable_bitField0_ = 0; 1033 | com.google.protobuf.UnknownFieldSet.Builder unknownFields = 1034 | com.google.protobuf.UnknownFieldSet.newBuilder(); 1035 | try { 1036 | boolean done = false; 1037 | while (!done) { 1038 | int tag = input.readTag(); 1039 | switch (tag) { 1040 | case 0: 1041 | done = true; 1042 | break; 1043 | default: { 1044 | if (!parseUnknownField( 1045 | input, unknownFields, extensionRegistry, tag)) { 1046 | done = true; 1047 | } 1048 | break; 1049 | } 1050 | case 10: { 1051 | if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { 1052 | item_ = new java.util.ArrayList(); 1053 | mutable_bitField0_ |= 0x00000001; 1054 | } 1055 | item_.add( 1056 | input.readMessage(object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.PARSER, extensionRegistry)); 1057 | break; 1058 | } 1059 | } 1060 | } 1061 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1062 | throw e.setUnfinishedMessage(this); 1063 | } catch (java.io.IOException e) { 1064 | throw new com.google.protobuf.InvalidProtocolBufferException( 1065 | e).setUnfinishedMessage(this); 1066 | } finally { 1067 | if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { 1068 | item_ = java.util.Collections.unmodifiableList(item_); 1069 | } 1070 | this.unknownFields = unknownFields.build(); 1071 | makeExtensionsImmutable(); 1072 | } 1073 | } 1074 | public static final com.google.protobuf.Descriptors.Descriptor 1075 | getDescriptor() { 1076 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMap_descriptor; 1077 | } 1078 | 1079 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1080 | internalGetFieldAccessorTable() { 1081 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMap_fieldAccessorTable 1082 | .ensureFieldAccessorsInitialized( 1083 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.class, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.Builder.class); 1084 | } 1085 | 1086 | public static final int ITEM_FIELD_NUMBER = 1; 1087 | private java.util.List item_; 1088 | /** 1089 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1090 | */ 1091 | public java.util.List getItemList() { 1092 | return item_; 1093 | } 1094 | /** 1095 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1096 | */ 1097 | public java.util.List 1098 | getItemOrBuilderList() { 1099 | return item_; 1100 | } 1101 | /** 1102 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1103 | */ 1104 | public int getItemCount() { 1105 | return item_.size(); 1106 | } 1107 | /** 1108 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1109 | */ 1110 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem getItem(int index) { 1111 | return item_.get(index); 1112 | } 1113 | /** 1114 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1115 | */ 1116 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder getItemOrBuilder( 1117 | int index) { 1118 | return item_.get(index); 1119 | } 1120 | 1121 | private byte memoizedIsInitialized = -1; 1122 | public final boolean isInitialized() { 1123 | byte isInitialized = memoizedIsInitialized; 1124 | if (isInitialized == 1) return true; 1125 | if (isInitialized == 0) return false; 1126 | 1127 | memoizedIsInitialized = 1; 1128 | return true; 1129 | } 1130 | 1131 | public void writeTo(com.google.protobuf.CodedOutputStream output) 1132 | throws java.io.IOException { 1133 | for (int i = 0; i < item_.size(); i++) { 1134 | output.writeMessage(1, item_.get(i)); 1135 | } 1136 | unknownFields.writeTo(output); 1137 | } 1138 | 1139 | public int getSerializedSize() { 1140 | int size = memoizedSize; 1141 | if (size != -1) return size; 1142 | 1143 | size = 0; 1144 | for (int i = 0; i < item_.size(); i++) { 1145 | size += com.google.protobuf.CodedOutputStream 1146 | .computeMessageSize(1, item_.get(i)); 1147 | } 1148 | size += unknownFields.getSerializedSize(); 1149 | memoizedSize = size; 1150 | return size; 1151 | } 1152 | 1153 | @java.lang.Override 1154 | public boolean equals(final java.lang.Object obj) { 1155 | if (obj == this) { 1156 | return true; 1157 | } 1158 | if (!(obj instanceof object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap)) { 1159 | return super.equals(obj); 1160 | } 1161 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap other = (object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap) obj; 1162 | 1163 | boolean result = true; 1164 | result = result && getItemList() 1165 | .equals(other.getItemList()); 1166 | result = result && unknownFields.equals(other.unknownFields); 1167 | return result; 1168 | } 1169 | 1170 | @java.lang.Override 1171 | public int hashCode() { 1172 | if (memoizedHashCode != 0) { 1173 | return memoizedHashCode; 1174 | } 1175 | int hash = 41; 1176 | hash = (19 * hash) + getDescriptor().hashCode(); 1177 | if (getItemCount() > 0) { 1178 | hash = (37 * hash) + ITEM_FIELD_NUMBER; 1179 | hash = (53 * hash) + getItemList().hashCode(); 1180 | } 1181 | hash = (29 * hash) + unknownFields.hashCode(); 1182 | memoizedHashCode = hash; 1183 | return hash; 1184 | } 1185 | 1186 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1187 | java.nio.ByteBuffer data) 1188 | throws com.google.protobuf.InvalidProtocolBufferException { 1189 | return PARSER.parseFrom(data); 1190 | } 1191 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1192 | java.nio.ByteBuffer data, 1193 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1194 | throws com.google.protobuf.InvalidProtocolBufferException { 1195 | return PARSER.parseFrom(data, extensionRegistry); 1196 | } 1197 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1198 | com.google.protobuf.ByteString data) 1199 | throws com.google.protobuf.InvalidProtocolBufferException { 1200 | return PARSER.parseFrom(data); 1201 | } 1202 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1203 | com.google.protobuf.ByteString data, 1204 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1205 | throws com.google.protobuf.InvalidProtocolBufferException { 1206 | return PARSER.parseFrom(data, extensionRegistry); 1207 | } 1208 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom(byte[] data) 1209 | throws com.google.protobuf.InvalidProtocolBufferException { 1210 | return PARSER.parseFrom(data); 1211 | } 1212 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1213 | byte[] data, 1214 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1215 | throws com.google.protobuf.InvalidProtocolBufferException { 1216 | return PARSER.parseFrom(data, extensionRegistry); 1217 | } 1218 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom(java.io.InputStream input) 1219 | throws java.io.IOException { 1220 | return com.google.protobuf.GeneratedMessageV3 1221 | .parseWithIOException(PARSER, input); 1222 | } 1223 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1224 | java.io.InputStream input, 1225 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1226 | throws java.io.IOException { 1227 | return com.google.protobuf.GeneratedMessageV3 1228 | .parseWithIOException(PARSER, input, extensionRegistry); 1229 | } 1230 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseDelimitedFrom(java.io.InputStream input) 1231 | throws java.io.IOException { 1232 | return com.google.protobuf.GeneratedMessageV3 1233 | .parseDelimitedWithIOException(PARSER, input); 1234 | } 1235 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseDelimitedFrom( 1236 | java.io.InputStream input, 1237 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1238 | throws java.io.IOException { 1239 | return com.google.protobuf.GeneratedMessageV3 1240 | .parseDelimitedWithIOException(PARSER, input, extensionRegistry); 1241 | } 1242 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1243 | com.google.protobuf.CodedInputStream input) 1244 | throws java.io.IOException { 1245 | return com.google.protobuf.GeneratedMessageV3 1246 | .parseWithIOException(PARSER, input); 1247 | } 1248 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parseFrom( 1249 | com.google.protobuf.CodedInputStream input, 1250 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1251 | throws java.io.IOException { 1252 | return com.google.protobuf.GeneratedMessageV3 1253 | .parseWithIOException(PARSER, input, extensionRegistry); 1254 | } 1255 | 1256 | public Builder newBuilderForType() { return newBuilder(); } 1257 | public static Builder newBuilder() { 1258 | return DEFAULT_INSTANCE.toBuilder(); 1259 | } 1260 | public static Builder newBuilder(object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap prototype) { 1261 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); 1262 | } 1263 | public Builder toBuilder() { 1264 | return this == DEFAULT_INSTANCE 1265 | ? new Builder() : new Builder().mergeFrom(this); 1266 | } 1267 | 1268 | @java.lang.Override 1269 | protected Builder newBuilderForType( 1270 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 1271 | Builder builder = new Builder(parent); 1272 | return builder; 1273 | } 1274 | /** 1275 | * Protobuf type {@code object_detection.protos.StringIntLabelMap} 1276 | */ 1277 | public static final class Builder extends 1278 | com.google.protobuf.GeneratedMessageV3.Builder implements 1279 | // @@protoc_insertion_point(builder_implements:object_detection.protos.StringIntLabelMap) 1280 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapOrBuilder { 1281 | public static final com.google.protobuf.Descriptors.Descriptor 1282 | getDescriptor() { 1283 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMap_descriptor; 1284 | } 1285 | 1286 | protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1287 | internalGetFieldAccessorTable() { 1288 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMap_fieldAccessorTable 1289 | .ensureFieldAccessorsInitialized( 1290 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.class, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.Builder.class); 1291 | } 1292 | 1293 | // Construct using object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.newBuilder() 1294 | private Builder() { 1295 | maybeForceBuilderInitialization(); 1296 | } 1297 | 1298 | private Builder( 1299 | com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { 1300 | super(parent); 1301 | maybeForceBuilderInitialization(); 1302 | } 1303 | private void maybeForceBuilderInitialization() { 1304 | if (com.google.protobuf.GeneratedMessageV3 1305 | .alwaysUseFieldBuilders) { 1306 | getItemFieldBuilder(); 1307 | } 1308 | } 1309 | public Builder clear() { 1310 | super.clear(); 1311 | if (itemBuilder_ == null) { 1312 | item_ = java.util.Collections.emptyList(); 1313 | bitField0_ = (bitField0_ & ~0x00000001); 1314 | } else { 1315 | itemBuilder_.clear(); 1316 | } 1317 | return this; 1318 | } 1319 | 1320 | public com.google.protobuf.Descriptors.Descriptor 1321 | getDescriptorForType() { 1322 | return object_detection.protos.StringIntLabelMapOuterClass.internal_static_object_detection_protos_StringIntLabelMap_descriptor; 1323 | } 1324 | 1325 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap getDefaultInstanceForType() { 1326 | return object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.getDefaultInstance(); 1327 | } 1328 | 1329 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap build() { 1330 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap result = buildPartial(); 1331 | if (!result.isInitialized()) { 1332 | throw newUninitializedMessageException(result); 1333 | } 1334 | return result; 1335 | } 1336 | 1337 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap buildPartial() { 1338 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap result = new object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap(this); 1339 | int from_bitField0_ = bitField0_; 1340 | if (itemBuilder_ == null) { 1341 | if (((bitField0_ & 0x00000001) == 0x00000001)) { 1342 | item_ = java.util.Collections.unmodifiableList(item_); 1343 | bitField0_ = (bitField0_ & ~0x00000001); 1344 | } 1345 | result.item_ = item_; 1346 | } else { 1347 | result.item_ = itemBuilder_.build(); 1348 | } 1349 | onBuilt(); 1350 | return result; 1351 | } 1352 | 1353 | public Builder clone() { 1354 | return (Builder) super.clone(); 1355 | } 1356 | public Builder setField( 1357 | com.google.protobuf.Descriptors.FieldDescriptor field, 1358 | java.lang.Object value) { 1359 | return (Builder) super.setField(field, value); 1360 | } 1361 | public Builder clearField( 1362 | com.google.protobuf.Descriptors.FieldDescriptor field) { 1363 | return (Builder) super.clearField(field); 1364 | } 1365 | public Builder clearOneof( 1366 | com.google.protobuf.Descriptors.OneofDescriptor oneof) { 1367 | return (Builder) super.clearOneof(oneof); 1368 | } 1369 | public Builder setRepeatedField( 1370 | com.google.protobuf.Descriptors.FieldDescriptor field, 1371 | int index, java.lang.Object value) { 1372 | return (Builder) super.setRepeatedField(field, index, value); 1373 | } 1374 | public Builder addRepeatedField( 1375 | com.google.protobuf.Descriptors.FieldDescriptor field, 1376 | java.lang.Object value) { 1377 | return (Builder) super.addRepeatedField(field, value); 1378 | } 1379 | public Builder mergeFrom(com.google.protobuf.Message other) { 1380 | if (other instanceof object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap) { 1381 | return mergeFrom((object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap)other); 1382 | } else { 1383 | super.mergeFrom(other); 1384 | return this; 1385 | } 1386 | } 1387 | 1388 | public Builder mergeFrom(object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap other) { 1389 | if (other == object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap.getDefaultInstance()) return this; 1390 | if (itemBuilder_ == null) { 1391 | if (!other.item_.isEmpty()) { 1392 | if (item_.isEmpty()) { 1393 | item_ = other.item_; 1394 | bitField0_ = (bitField0_ & ~0x00000001); 1395 | } else { 1396 | ensureItemIsMutable(); 1397 | item_.addAll(other.item_); 1398 | } 1399 | onChanged(); 1400 | } 1401 | } else { 1402 | if (!other.item_.isEmpty()) { 1403 | if (itemBuilder_.isEmpty()) { 1404 | itemBuilder_.dispose(); 1405 | itemBuilder_ = null; 1406 | item_ = other.item_; 1407 | bitField0_ = (bitField0_ & ~0x00000001); 1408 | itemBuilder_ = 1409 | com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? 1410 | getItemFieldBuilder() : null; 1411 | } else { 1412 | itemBuilder_.addAllMessages(other.item_); 1413 | } 1414 | } 1415 | } 1416 | this.mergeUnknownFields(other.unknownFields); 1417 | onChanged(); 1418 | return this; 1419 | } 1420 | 1421 | public final boolean isInitialized() { 1422 | return true; 1423 | } 1424 | 1425 | public Builder mergeFrom( 1426 | com.google.protobuf.CodedInputStream input, 1427 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1428 | throws java.io.IOException { 1429 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap parsedMessage = null; 1430 | try { 1431 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); 1432 | } catch (com.google.protobuf.InvalidProtocolBufferException e) { 1433 | parsedMessage = (object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap) e.getUnfinishedMessage(); 1434 | throw e.unwrapIOException(); 1435 | } finally { 1436 | if (parsedMessage != null) { 1437 | mergeFrom(parsedMessage); 1438 | } 1439 | } 1440 | return this; 1441 | } 1442 | private int bitField0_; 1443 | 1444 | private java.util.List item_ = 1445 | java.util.Collections.emptyList(); 1446 | private void ensureItemIsMutable() { 1447 | if (!((bitField0_ & 0x00000001) == 0x00000001)) { 1448 | item_ = new java.util.ArrayList(item_); 1449 | bitField0_ |= 0x00000001; 1450 | } 1451 | } 1452 | 1453 | private com.google.protobuf.RepeatedFieldBuilderV3< 1454 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder> itemBuilder_; 1455 | 1456 | /** 1457 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1458 | */ 1459 | public java.util.List getItemList() { 1460 | if (itemBuilder_ == null) { 1461 | return java.util.Collections.unmodifiableList(item_); 1462 | } else { 1463 | return itemBuilder_.getMessageList(); 1464 | } 1465 | } 1466 | /** 1467 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1468 | */ 1469 | public int getItemCount() { 1470 | if (itemBuilder_ == null) { 1471 | return item_.size(); 1472 | } else { 1473 | return itemBuilder_.getCount(); 1474 | } 1475 | } 1476 | /** 1477 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1478 | */ 1479 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem getItem(int index) { 1480 | if (itemBuilder_ == null) { 1481 | return item_.get(index); 1482 | } else { 1483 | return itemBuilder_.getMessage(index); 1484 | } 1485 | } 1486 | /** 1487 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1488 | */ 1489 | public Builder setItem( 1490 | int index, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem value) { 1491 | if (itemBuilder_ == null) { 1492 | if (value == null) { 1493 | throw new NullPointerException(); 1494 | } 1495 | ensureItemIsMutable(); 1496 | item_.set(index, value); 1497 | onChanged(); 1498 | } else { 1499 | itemBuilder_.setMessage(index, value); 1500 | } 1501 | return this; 1502 | } 1503 | /** 1504 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1505 | */ 1506 | public Builder setItem( 1507 | int index, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder builderForValue) { 1508 | if (itemBuilder_ == null) { 1509 | ensureItemIsMutable(); 1510 | item_.set(index, builderForValue.build()); 1511 | onChanged(); 1512 | } else { 1513 | itemBuilder_.setMessage(index, builderForValue.build()); 1514 | } 1515 | return this; 1516 | } 1517 | /** 1518 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1519 | */ 1520 | public Builder addItem(object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem value) { 1521 | if (itemBuilder_ == null) { 1522 | if (value == null) { 1523 | throw new NullPointerException(); 1524 | } 1525 | ensureItemIsMutable(); 1526 | item_.add(value); 1527 | onChanged(); 1528 | } else { 1529 | itemBuilder_.addMessage(value); 1530 | } 1531 | return this; 1532 | } 1533 | /** 1534 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1535 | */ 1536 | public Builder addItem( 1537 | int index, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem value) { 1538 | if (itemBuilder_ == null) { 1539 | if (value == null) { 1540 | throw new NullPointerException(); 1541 | } 1542 | ensureItemIsMutable(); 1543 | item_.add(index, value); 1544 | onChanged(); 1545 | } else { 1546 | itemBuilder_.addMessage(index, value); 1547 | } 1548 | return this; 1549 | } 1550 | /** 1551 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1552 | */ 1553 | public Builder addItem( 1554 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder builderForValue) { 1555 | if (itemBuilder_ == null) { 1556 | ensureItemIsMutable(); 1557 | item_.add(builderForValue.build()); 1558 | onChanged(); 1559 | } else { 1560 | itemBuilder_.addMessage(builderForValue.build()); 1561 | } 1562 | return this; 1563 | } 1564 | /** 1565 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1566 | */ 1567 | public Builder addItem( 1568 | int index, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder builderForValue) { 1569 | if (itemBuilder_ == null) { 1570 | ensureItemIsMutable(); 1571 | item_.add(index, builderForValue.build()); 1572 | onChanged(); 1573 | } else { 1574 | itemBuilder_.addMessage(index, builderForValue.build()); 1575 | } 1576 | return this; 1577 | } 1578 | /** 1579 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1580 | */ 1581 | public Builder addAllItem( 1582 | java.lang.Iterable values) { 1583 | if (itemBuilder_ == null) { 1584 | ensureItemIsMutable(); 1585 | com.google.protobuf.AbstractMessageLite.Builder.addAll( 1586 | values, item_); 1587 | onChanged(); 1588 | } else { 1589 | itemBuilder_.addAllMessages(values); 1590 | } 1591 | return this; 1592 | } 1593 | /** 1594 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1595 | */ 1596 | public Builder clearItem() { 1597 | if (itemBuilder_ == null) { 1598 | item_ = java.util.Collections.emptyList(); 1599 | bitField0_ = (bitField0_ & ~0x00000001); 1600 | onChanged(); 1601 | } else { 1602 | itemBuilder_.clear(); 1603 | } 1604 | return this; 1605 | } 1606 | /** 1607 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1608 | */ 1609 | public Builder removeItem(int index) { 1610 | if (itemBuilder_ == null) { 1611 | ensureItemIsMutable(); 1612 | item_.remove(index); 1613 | onChanged(); 1614 | } else { 1615 | itemBuilder_.remove(index); 1616 | } 1617 | return this; 1618 | } 1619 | /** 1620 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1621 | */ 1622 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder getItemBuilder( 1623 | int index) { 1624 | return getItemFieldBuilder().getBuilder(index); 1625 | } 1626 | /** 1627 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1628 | */ 1629 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder getItemOrBuilder( 1630 | int index) { 1631 | if (itemBuilder_ == null) { 1632 | return item_.get(index); } else { 1633 | return itemBuilder_.getMessageOrBuilder(index); 1634 | } 1635 | } 1636 | /** 1637 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1638 | */ 1639 | public java.util.List 1640 | getItemOrBuilderList() { 1641 | if (itemBuilder_ != null) { 1642 | return itemBuilder_.getMessageOrBuilderList(); 1643 | } else { 1644 | return java.util.Collections.unmodifiableList(item_); 1645 | } 1646 | } 1647 | /** 1648 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1649 | */ 1650 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder addItemBuilder() { 1651 | return getItemFieldBuilder().addBuilder( 1652 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.getDefaultInstance()); 1653 | } 1654 | /** 1655 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1656 | */ 1657 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder addItemBuilder( 1658 | int index) { 1659 | return getItemFieldBuilder().addBuilder( 1660 | index, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.getDefaultInstance()); 1661 | } 1662 | /** 1663 | * repeated .object_detection.protos.StringIntLabelMapItem item = 1; 1664 | */ 1665 | public java.util.List 1666 | getItemBuilderList() { 1667 | return getItemFieldBuilder().getBuilderList(); 1668 | } 1669 | private com.google.protobuf.RepeatedFieldBuilderV3< 1670 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder> 1671 | getItemFieldBuilder() { 1672 | if (itemBuilder_ == null) { 1673 | itemBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< 1674 | object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItem.Builder, object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMapItemOrBuilder>( 1675 | item_, 1676 | ((bitField0_ & 0x00000001) == 0x00000001), 1677 | getParentForChildren(), 1678 | isClean()); 1679 | item_ = null; 1680 | } 1681 | return itemBuilder_; 1682 | } 1683 | public final Builder setUnknownFields( 1684 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1685 | return super.setUnknownFields(unknownFields); 1686 | } 1687 | 1688 | public final Builder mergeUnknownFields( 1689 | final com.google.protobuf.UnknownFieldSet unknownFields) { 1690 | return super.mergeUnknownFields(unknownFields); 1691 | } 1692 | 1693 | 1694 | // @@protoc_insertion_point(builder_scope:object_detection.protos.StringIntLabelMap) 1695 | } 1696 | 1697 | // @@protoc_insertion_point(class_scope:object_detection.protos.StringIntLabelMap) 1698 | private static final object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap DEFAULT_INSTANCE; 1699 | static { 1700 | DEFAULT_INSTANCE = new object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap(); 1701 | } 1702 | 1703 | public static object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap getDefaultInstance() { 1704 | return DEFAULT_INSTANCE; 1705 | } 1706 | 1707 | @java.lang.Deprecated public static final com.google.protobuf.Parser 1708 | PARSER = new com.google.protobuf.AbstractParser() { 1709 | public StringIntLabelMap parsePartialFrom( 1710 | com.google.protobuf.CodedInputStream input, 1711 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) 1712 | throws com.google.protobuf.InvalidProtocolBufferException { 1713 | return new StringIntLabelMap(input, extensionRegistry); 1714 | } 1715 | }; 1716 | 1717 | public static com.google.protobuf.Parser parser() { 1718 | return PARSER; 1719 | } 1720 | 1721 | @java.lang.Override 1722 | public com.google.protobuf.Parser getParserForType() { 1723 | return PARSER; 1724 | } 1725 | 1726 | public object_detection.protos.StringIntLabelMapOuterClass.StringIntLabelMap getDefaultInstanceForType() { 1727 | return DEFAULT_INSTANCE; 1728 | } 1729 | 1730 | } 1731 | 1732 | private static final com.google.protobuf.Descriptors.Descriptor 1733 | internal_static_object_detection_protos_StringIntLabelMapItem_descriptor; 1734 | private static final 1735 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1736 | internal_static_object_detection_protos_StringIntLabelMapItem_fieldAccessorTable; 1737 | private static final com.google.protobuf.Descriptors.Descriptor 1738 | internal_static_object_detection_protos_StringIntLabelMap_descriptor; 1739 | private static final 1740 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable 1741 | internal_static_object_detection_protos_StringIntLabelMap_fieldAccessorTable; 1742 | 1743 | public static com.google.protobuf.Descriptors.FileDescriptor 1744 | getDescriptor() { 1745 | return descriptor; 1746 | } 1747 | private static com.google.protobuf.Descriptors.FileDescriptor 1748 | descriptor; 1749 | static { 1750 | java.lang.String[] descriptorData = { 1751 | "\n\032string_int_label_map.proto\022\027object_det" + 1752 | "ection.protos\"G\n\025StringIntLabelMapItem\022\014" + 1753 | "\n\004name\030\001 \001(\t\022\n\n\002id\030\002 \001(\005\022\024\n\014display_name" + 1754 | "\030\003 \001(\t\"Q\n\021StringIntLabelMap\022<\n\004item\030\001 \003(" + 1755 | "\0132..object_detection.protos.StringIntLab" + 1756 | "elMapItem" 1757 | }; 1758 | com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = 1759 | new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { 1760 | public com.google.protobuf.ExtensionRegistry assignDescriptors( 1761 | com.google.protobuf.Descriptors.FileDescriptor root) { 1762 | descriptor = root; 1763 | return null; 1764 | } 1765 | }; 1766 | com.google.protobuf.Descriptors.FileDescriptor 1767 | .internalBuildGeneratedFileFrom(descriptorData, 1768 | new com.google.protobuf.Descriptors.FileDescriptor[] { 1769 | }, assigner); 1770 | internal_static_object_detection_protos_StringIntLabelMapItem_descriptor = 1771 | getDescriptor().getMessageTypes().get(0); 1772 | internal_static_object_detection_protos_StringIntLabelMapItem_fieldAccessorTable = new 1773 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 1774 | internal_static_object_detection_protos_StringIntLabelMapItem_descriptor, 1775 | new java.lang.String[] { "Name", "Id", "DisplayName", }); 1776 | internal_static_object_detection_protos_StringIntLabelMap_descriptor = 1777 | getDescriptor().getMessageTypes().get(1); 1778 | internal_static_object_detection_protos_StringIntLabelMap_fieldAccessorTable = new 1779 | com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( 1780 | internal_static_object_detection_protos_StringIntLabelMap_descriptor, 1781 | new java.lang.String[] { "Item", }); 1782 | } 1783 | 1784 | // @@protoc_insertion_point(outer_class_scope) 1785 | } -------------------------------------------------------------------------------- /src/main/protobuf/string_int_label_map.proto: -------------------------------------------------------------------------------- 1 | // Message to store the mapping from class label strings to class id. Datasets 2 | // use string labels to represent classes while the object detection framework 3 | // works with class ids. This message maps them so they can be converted back 4 | // and forth as needed. 5 | syntax = "proto2"; 6 | 7 | package object_detection.protos; 8 | 9 | message StringIntLabelMapItem { 10 | // String name. The most common practice is to set this to a MID or synsets 11 | // id. 12 | optional string name = 1; 13 | 14 | // Integer id that maps to the string name above. Label ids should start from 15 | // 1. 16 | optional int32 id = 2; 17 | 18 | // Human readable string label. 19 | optional string display_name = 3; 20 | }; 21 | 22 | message StringIntLabelMap { 23 | repeated StringIntLabelMapItem item = 1; 24 | }; -------------------------------------------------------------------------------- /src/main/resources/labels/mscoco_label_map.pbtxt: -------------------------------------------------------------------------------- 1 | item { 2 | name: "/m/01g317" 3 | id: 1 4 | display_name: "person" 5 | } 6 | item { 7 | name: "/m/0199g" 8 | id: 2 9 | display_name: "bicycle" 10 | } 11 | item { 12 | name: "/m/0k4j" 13 | id: 3 14 | display_name: "car" 15 | } 16 | item { 17 | name: "/m/04_sv" 18 | id: 4 19 | display_name: "motorcycle" 20 | } 21 | item { 22 | name: "/m/05czz6l" 23 | id: 5 24 | display_name: "airplane" 25 | } 26 | item { 27 | name: "/m/01bjv" 28 | id: 6 29 | display_name: "bus" 30 | } 31 | item { 32 | name: "/m/07jdr" 33 | id: 7 34 | display_name: "train" 35 | } 36 | item { 37 | name: "/m/07r04" 38 | id: 8 39 | display_name: "truck" 40 | } 41 | item { 42 | name: "/m/019jd" 43 | id: 9 44 | display_name: "boat" 45 | } 46 | item { 47 | name: "/m/015qff" 48 | id: 10 49 | display_name: "traffic light" 50 | } 51 | item { 52 | name: "/m/01pns0" 53 | id: 11 54 | display_name: "fire hydrant" 55 | } 56 | item { 57 | name: "/m/02pv19" 58 | id: 13 59 | display_name: "stop sign" 60 | } 61 | item { 62 | name: "/m/015qbp" 63 | id: 14 64 | display_name: "parking meter" 65 | } 66 | item { 67 | name: "/m/0cvnqh" 68 | id: 15 69 | display_name: "bench" 70 | } 71 | item { 72 | name: "/m/015p6" 73 | id: 16 74 | display_name: "bird" 75 | } 76 | item { 77 | name: "/m/01yrx" 78 | id: 17 79 | display_name: "cat" 80 | } 81 | item { 82 | name: "/m/0bt9lr" 83 | id: 18 84 | display_name: "dog" 85 | } 86 | item { 87 | name: "/m/03k3r" 88 | id: 19 89 | display_name: "horse" 90 | } 91 | item { 92 | name: "/m/07bgp" 93 | id: 20 94 | display_name: "sheep" 95 | } 96 | item { 97 | name: "/m/01xq0k1" 98 | id: 21 99 | display_name: "cow" 100 | } 101 | item { 102 | name: "/m/0bwd_0j" 103 | id: 22 104 | display_name: "elephant" 105 | } 106 | item { 107 | name: "/m/01dws" 108 | id: 23 109 | display_name: "bear" 110 | } 111 | item { 112 | name: "/m/0898b" 113 | id: 24 114 | display_name: "zebra" 115 | } 116 | item { 117 | name: "/m/03bk1" 118 | id: 25 119 | display_name: "giraffe" 120 | } 121 | item { 122 | name: "/m/01940j" 123 | id: 27 124 | display_name: "backpack" 125 | } 126 | item { 127 | name: "/m/0hnnb" 128 | id: 28 129 | display_name: "umbrella" 130 | } 131 | item { 132 | name: "/m/080hkjn" 133 | id: 31 134 | display_name: "handbag" 135 | } 136 | item { 137 | name: "/m/01rkbr" 138 | id: 32 139 | display_name: "tie" 140 | } 141 | item { 142 | name: "/m/01s55n" 143 | id: 33 144 | display_name: "suitcase" 145 | } 146 | item { 147 | name: "/m/02wmf" 148 | id: 34 149 | display_name: "frisbee" 150 | } 151 | item { 152 | name: "/m/071p9" 153 | id: 35 154 | display_name: "skis" 155 | } 156 | item { 157 | name: "/m/06__v" 158 | id: 36 159 | display_name: "snowboard" 160 | } 161 | item { 162 | name: "/m/018xm" 163 | id: 37 164 | display_name: "sports ball" 165 | } 166 | item { 167 | name: "/m/02zt3" 168 | id: 38 169 | display_name: "kite" 170 | } 171 | item { 172 | name: "/m/03g8mr" 173 | id: 39 174 | display_name: "baseball bat" 175 | } 176 | item { 177 | name: "/m/03grzl" 178 | id: 40 179 | display_name: "baseball glove" 180 | } 181 | item { 182 | name: "/m/06_fw" 183 | id: 41 184 | display_name: "skateboard" 185 | } 186 | item { 187 | name: "/m/019w40" 188 | id: 42 189 | display_name: "surfboard" 190 | } 191 | item { 192 | name: "/m/0dv9c" 193 | id: 43 194 | display_name: "tennis racket" 195 | } 196 | item { 197 | name: "/m/04dr76w" 198 | id: 44 199 | display_name: "bottle" 200 | } 201 | item { 202 | name: "/m/09tvcd" 203 | id: 46 204 | display_name: "wine glass" 205 | } 206 | item { 207 | name: "/m/08gqpm" 208 | id: 47 209 | display_name: "cup" 210 | } 211 | item { 212 | name: "/m/0dt3t" 213 | id: 48 214 | display_name: "fork" 215 | } 216 | item { 217 | name: "/m/04ctx" 218 | id: 49 219 | display_name: "knife" 220 | } 221 | item { 222 | name: "/m/0cmx8" 223 | id: 50 224 | display_name: "spoon" 225 | } 226 | item { 227 | name: "/m/04kkgm" 228 | id: 51 229 | display_name: "bowl" 230 | } 231 | item { 232 | name: "/m/09qck" 233 | id: 52 234 | display_name: "banana" 235 | } 236 | item { 237 | name: "/m/014j1m" 238 | id: 53 239 | display_name: "apple" 240 | } 241 | item { 242 | name: "/m/0l515" 243 | id: 54 244 | display_name: "sandwich" 245 | } 246 | item { 247 | name: "/m/0cyhj_" 248 | id: 55 249 | display_name: "orange" 250 | } 251 | item { 252 | name: "/m/0hkxq" 253 | id: 56 254 | display_name: "broccoli" 255 | } 256 | item { 257 | name: "/m/0fj52s" 258 | id: 57 259 | display_name: "carrot" 260 | } 261 | item { 262 | name: "/m/01b9xk" 263 | id: 58 264 | display_name: "hot dog" 265 | } 266 | item { 267 | name: "/m/0663v" 268 | id: 59 269 | display_name: "pizza" 270 | } 271 | item { 272 | name: "/m/0jy4k" 273 | id: 60 274 | display_name: "donut" 275 | } 276 | item { 277 | name: "/m/0fszt" 278 | id: 61 279 | display_name: "cake" 280 | } 281 | item { 282 | name: "/m/01mzpv" 283 | id: 62 284 | display_name: "chair" 285 | } 286 | item { 287 | name: "/m/02crq1" 288 | id: 63 289 | display_name: "couch" 290 | } 291 | item { 292 | name: "/m/03fp41" 293 | id: 64 294 | display_name: "potted plant" 295 | } 296 | item { 297 | name: "/m/03ssj5" 298 | id: 65 299 | display_name: "bed" 300 | } 301 | item { 302 | name: "/m/04bcr3" 303 | id: 67 304 | display_name: "dining table" 305 | } 306 | item { 307 | name: "/m/09g1w" 308 | id: 70 309 | display_name: "toilet" 310 | } 311 | item { 312 | name: "/m/07c52" 313 | id: 72 314 | display_name: "tv" 315 | } 316 | item { 317 | name: "/m/01c648" 318 | id: 73 319 | display_name: "laptop" 320 | } 321 | item { 322 | name: "/m/020lf" 323 | id: 74 324 | display_name: "mouse" 325 | } 326 | item { 327 | name: "/m/0qjjc" 328 | id: 75 329 | display_name: "remote" 330 | } 331 | item { 332 | name: "/m/01m2v" 333 | id: 76 334 | display_name: "keyboard" 335 | } 336 | item { 337 | name: "/m/050k8" 338 | id: 77 339 | display_name: "cell phone" 340 | } 341 | item { 342 | name: "/m/0fx9l" 343 | id: 78 344 | display_name: "microwave" 345 | } 346 | item { 347 | name: "/m/029bxz" 348 | id: 79 349 | display_name: "oven" 350 | } 351 | item { 352 | name: "/m/01k6s3" 353 | id: 80 354 | display_name: "toaster" 355 | } 356 | item { 357 | name: "/m/0130jx" 358 | id: 81 359 | display_name: "sink" 360 | } 361 | item { 362 | name: "/m/040b_t" 363 | id: 82 364 | display_name: "refrigerator" 365 | } 366 | item { 367 | name: "/m/0bt_c3" 368 | id: 84 369 | display_name: "book" 370 | } 371 | item { 372 | name: "/m/01x3z" 373 | id: 85 374 | display_name: "clock" 375 | } 376 | item { 377 | name: "/m/02s195" 378 | id: 86 379 | display_name: "vase" 380 | } 381 | item { 382 | name: "/m/01lsmm" 383 | id: 87 384 | display_name: "scissors" 385 | } 386 | item { 387 | name: "/m/0kmg4" 388 | id: 88 389 | display_name: "teddy bear" 390 | } 391 | item { 392 | name: "/m/03wvsk" 393 | id: 89 394 | display_name: "hair drier" 395 | } 396 | item { 397 | name: "/m/012xff" 398 | id: 90 399 | display_name: "toothbrush" 400 | } -------------------------------------------------------------------------------- /src/main/resources/tf_models/saved_model.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chen0040/java-ssd-object-detection/39435c0fbaf9cf6e3d605dc7c4ee8990a8888007/src/main/resources/tf_models/saved_model.zip --------------------------------------------------------------------------------