Skip to content

Commit

Permalink
Fixed model loading (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spiess authored May 17, 2022
1 parent 29da078 commit 130a9f4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ allprojects {
group = 'org.vitrivr'

/* Our current version, on dev branch this should always be release+1-SNAPSHOT */
version = '3.11.4'
version = '3.11.5'

apply plugin: 'java-library'
apply plugin: 'maven-publish'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<ScoreElement> getSimilar(SegmentContainer sc, ReadableQueryConfig qc
return getSimilar(embeddingArray, queryConfig);
}

private void initializeModel() {
private synchronized static void initializeModel() {
if (model == null) {
model = SavedModelBundle.load(RESOURCE_PATH + EMBEDDING_MODEL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public CLIPText() {
loadModel();
}

private static void loadModel() {
private synchronized static void loadModel() {
if (model == null) {
model = SavedModelBundle.load(RESOURCE_PATH + EMBEDDING_MODEL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class SkeletonPose extends AbstractFeatureModule {
private static final String PERSON_ID_COL = "person";
private static final String FEATURE_COL = "skeleton";
private static final String WEIGHT_COL = "weights";
private final PoseDetector detector = new MergingPoseDetector();
private static PoseDetector detector;

public SkeletonPose() {
super("features_skeletonpose", (float) (16 * Math.PI), 12);
Expand Down Expand Up @@ -129,7 +129,14 @@ public void persist(Collection<Pair<String, Skeleton>> skeletons) {
this.phandler.persist(tuples);
}

private synchronized static void initializeDetector() {
if (detector == null) {
detector = new MergingPoseDetector();
}
}

private synchronized List<Skeleton> detectSkeletons(MultiImage img) {
initializeDetector();
return detector.detectPoses(img.getBufferedImage());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public List<ScoreElement> getSimilar(String segmentId, ReadableQueryConfig qc) {
return super.getSimilar(segmentId, queryConfig);
}

private void initializeTextEmbedding() {
private synchronized static void initializeTextEmbedding() {
if (textEmbedding == null) {
textEmbedding = SavedModelBundle.load(RESOURCE_PATH + TEXT_EMBEDDING_MODEL);
}
Expand All @@ -139,7 +139,7 @@ private void initializeTextEmbedding() {
}
}

private void initializeVisualEmbedding() {
private synchronized static void initializeVisualEmbedding() {
if (visualEmbedding == null) {
visualEmbedding = InceptionResnetV2.getModel();
}
Expand Down

0 comments on commit 130a9f4

Please sign in to comment.