forked from deepjavalibrary/djl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 0092f8e Author: Aziz Zayed <azayed01@gmail.com> Date: Tue Jun 15 08:22:51 2021 -0700 Fixed truncated-normal bug commit a6ded8c Author: Aziz Zayed <azayed01@gmail.com> Date: Mon Jun 14 13:33:30 2021 -0700 [pytorch] Add BigGAN demo commit f145614 Merge: a8a1a9b ec8405b Author: Abd-El-Aziz Zayed <48853777+AzizZayed@users.noreply.github.com> Date: Fri Jun 11 20:45:34 2021 -0700 Merge branch 'deepjavalibrary:master' into master commit ec8405b Author: Abd-El-Aziz Zayed <48853777+AzizZayed@users.noreply.github.com> Date: Fri Jun 11 14:53:59 2021 -0700 [pytorch] Add oneHot operator (deepjavalibrary#1014) [tensoflow] Add truncated normal operation commit 50600fd Author: Frank Liu <frankfliu2000@gmail.com> Date: Fri Jun 11 14:53:43 2021 -0700 upgrade dependencies version (deepjavalibrary#1012) Change-Id: I709938f69f21096bc5cd29a24191f0f282dcbc97 commit 3379fd2 Author: Frank Liu <frankfliu2000@gmail.com> Date: Fri Jun 11 14:53:29 2021 -0700 [serving] Fix flaky test (deepjavalibrary#1013) Change-Id: I13b89e04516c59a3d28ecafd49f4f808630b22fb commit 23157fd Author: Frank Liu <frankfliu2000@gmail.com> Date: Thu Jun 10 16:31:03 2021 -0700 Enable spotbugs for java 11+ (deepjavalibrary#1010) Change-Id: I74effbf45492a5cf50e09ba8af0223d2b1bcb5a5 commit 4f38708 Author: Frank Liu <frankfliu2000@gmail.com> Date: Thu Jun 10 16:30:50 2021 -0700 Fix model zoo test typo (deepjavalibrary#1009) Change-Id: I7c0109c6e5fc0ece16288082fd830718f20ad489 commit a8a1a9b Merge: 77809f4 30b03f4 Author: Aziz Zayed <azayed01@gmail.com> Date: Thu Jun 10 15:16:05 2021 -0700 Merge Truncated-Normal branch commit 77809f4 Author: Frank Liu <frankfliu2000@gmail.com> Date: Thu Jun 10 14:07:43 2021 -0700 Make model zoo test weekly (deepjavalibrary#1004) Change-Id: I1c73df17cb077b9ce8905fcc2fc8bbb37b9688d8 commit 0aec8ca Author: Abd-El-Aziz Zayed <48853777+AzizZayed@users.noreply.github.com> Date: Thu Jun 10 12:46:16 2021 -0700 [tensoflow] Add truncated normal operation (deepjavalibrary#1005) commit 30b03f4 Author: Aziz Zayed <azayed01@gmail.com> Date: Wed Jun 9 01:40:33 2021 -0700 [tensoflow] Add truncated normal operation commit d8e7e1d Author: Frank Liu <frankfliu2000@gmail.com> Date: Wed Jun 9 07:55:15 2021 -0700 Fixes deepjavalibrary#999, hanlde UTF16 surrogate charactors properly. (deepjavalibrary#1003) Change-Id: I19e77cf5a8282bea901434041806eb102549ec0f commit b0fe73a Author: Frank Liu <frankfliu2000@gmail.com> Date: Tue Jun 8 17:56:19 2021 -0700 [pytorch] Update load model jupyter notebook (deepjavalibrary#1002) Change-Id: I1889aa93d2002e6ce02c740d2d1d3517bf586760 commit 8286930 Author: Frank Liu <frankfliu2000@gmail.com> Date: Tue Jun 8 15:29:27 2021 -0700 [tensorflow] fix optOption usage document (deepjavalibrary#1001) Change-Id: Ie044839cf082d63010a5c26d3f2f8833447919c6 commit a26f5b2 Author: Abd-El-Aziz Zayed <48853777+AzizZayed@users.noreply.github.com> Date: Tue Jun 8 15:29:10 2021 -0700 Updated PyTorch Docs (deepjavalibrary#1000) * Added auto softmax metadata for action_recognition * Update PyTorch Docs commit e6890f9 Author: Lanking <qingla@amazon.com> Date: Mon Jun 7 18:25:19 2021 -0700 upgrade xgboost (deepjavalibrary#993) commit a0dcf3a Author: Lanking <qingla@amazon.com> Date: Mon Jun 7 18:25:12 2021 -0700 bump up onnx runtime version (deepjavalibrary#992)
- Loading branch information
Showing
29 changed files
with
1,657 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
examples/src/main/java/ai/djl/examples/inference/biggan/BigGANCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance | ||
* with the License. A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
package ai.djl.examples.inference.biggan; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class BigGANCategory { | ||
private static final Logger logger = LoggerFactory.getLogger(BigGANCategory.class); | ||
|
||
public static final int NUMBER_OF_CATEGORIES = 1000; | ||
private static final Map<String, BigGANCategory> CATEGORIES_BY_NAME = | ||
new ConcurrentHashMap<>(NUMBER_OF_CATEGORIES); | ||
private static String[] categoriesById; | ||
|
||
private int id; | ||
private String[] names; | ||
|
||
static { | ||
try { | ||
parseCategories(); | ||
} catch (IOException e) { | ||
logger.error("Error parsing the ImageNet categories: {}", e); | ||
} | ||
createCategoriesByName(); | ||
} | ||
|
||
private BigGANCategory(int id, String[] names) { | ||
this.id = id; | ||
this.names = names; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String[] getNames() { | ||
return names.clone(); | ||
} | ||
|
||
public static BigGANCategory id(int id) { | ||
String names = categoriesById[id]; | ||
int index = names.indexOf(','); | ||
if (index < 0) { | ||
return of(names); | ||
} else { | ||
return of(names.substring(0, index)); | ||
} | ||
} | ||
|
||
public static BigGANCategory of(String name) { | ||
if (!CATEGORIES_BY_NAME.containsKey(name)) { | ||
throw new IllegalArgumentException(name + " is not a valid category."); | ||
} | ||
return CATEGORIES_BY_NAME.get(name); | ||
} | ||
|
||
private static void createCategoriesByName() { | ||
for (int i = 0; i < NUMBER_OF_CATEGORIES; i++) { | ||
String[] categoryNames = categoriesById[i].split(", "); | ||
BigGANCategory category = new BigGANCategory(i, categoryNames); | ||
|
||
for (String name : categoryNames) { | ||
CATEGORIES_BY_NAME.put(name, category); | ||
} | ||
} | ||
} | ||
|
||
private static void parseCategories() throws IOException { | ||
String filePath = "src/main/resources/categories.txt"; | ||
|
||
List<String> fileLines = Files.readAllLines(Paths.get(filePath)); | ||
List<String> categories = new ArrayList<>(NUMBER_OF_CATEGORIES); | ||
for (String line : fileLines) { | ||
int nameIndex = line.indexOf(':') + 2; | ||
categories.add(line.substring(nameIndex)); | ||
} | ||
|
||
categoriesById = categories.toArray(new String[] {}); | ||
} | ||
} |
Oops, something went wrong.