Skip to content

Commit

Permalink
improve robustness and correct a couple of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 15, 2024
1 parent 8efb7bc commit 583dd79
Showing 1 changed file with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public class DownloadModel {
* Key for the map that contains the test outputs of the model
*/
private static String TEST_OUTPUTS_KEY = "test_output";
/**
* Key for the map that contains the covers for the model
*/
private static String COVERS_KEY = "covers";

/**
* Constructor that contains all the info and is able to download a BioImage.io model
Expand Down Expand Up @@ -293,10 +297,10 @@ private void addWeights() {
private void addCovers() {
int c = 0;
for (String ss : descriptor.getCovers()) {
if (!checkURL(ss))
downloadableLinks.put(TEST_INPUTS_KEY + "_" + c ++, this.descriptor.getModelURL() + ss);
else
downloadableLinks.put(TEST_INPUTS_KEY + "_" + c ++, ss);
if (ss != null && !checkURL(ss))
downloadableLinks.put(COVERS_KEY + "_" + c ++, this.descriptor.getModelURL() + ss);
else if (ss != null)
downloadableLinks.put(COVERS_KEY + "_" + c ++, ss);
}
}

Expand All @@ -307,8 +311,11 @@ private void addTestInputs() {
List<String> fileNames = descriptor.getInputTensors().stream()
.map(tt -> tt.getTestTensorName()).collect(Collectors.toList());
int c = 0;
for (String ss : fileNames)
for (String ss : fileNames) {
if (ss == null)
continue;
downloadableLinks.put(TEST_INPUTS_KEY + "_" + c ++, this.descriptor.getModelURL() + ss);
}
}

/**
Expand All @@ -318,8 +325,11 @@ private void addTestOutputs() {
List<String> fileNames = descriptor.getOutputTensors().stream()
.map(tt -> tt.getTestTensorName()).collect(Collectors.toList());
int c = 0;
for (String ss : fileNames)
for (String ss : fileNames) {
if (ss == null)
continue;
downloadableLinks.put(TEST_OUTPUTS_KEY + "_" + c ++, this.descriptor.getModelURL() + ss);
}
}

/**
Expand All @@ -329,8 +339,11 @@ private void addSampleInputs() {
List<String> fileNames = descriptor.getInputTensors().stream()
.map(tt -> tt.getSampleTensorName()).collect(Collectors.toList());
int c = 0;
for (String ss : fileNames)
for (String ss : fileNames) {
if (ss == null)
continue;
downloadableLinks.put(SAMPLE_INPUTS_KEY + "_" + c ++, this.descriptor.getModelURL() + ss);
}
}

/**
Expand All @@ -340,8 +353,11 @@ private void addSampleOutputs() {
List<String> fileNames = descriptor.getOutputTensors().stream()
.map(tt -> tt.getSampleTensorName()).collect(Collectors.toList());
int c = 0;
for (String ss : fileNames)
for (String ss : fileNames) {
if (ss == null)
continue;
downloadableLinks.put(SAMPLE_OUTPUTS_KEY + "_" + c ++, this.descriptor.getModelURL() + ss);
}
}

/**
Expand Down

0 comments on commit 583dd79

Please sign in to comment.