Skip to content

Commit

Permalink
handle zenodo shit
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 31, 2023
1 parent ec14b9d commit 290e5f7
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
package io.bioimage.modelrunner.bioimageio.description.weights;

import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.bioimage.modelrunner.utils.CommonUtils;
import io.bioimage.modelrunner.utils.Constants;

/**
* Class that contains the information for Keras weights.
* For more information about the parameters go to:
Expand Down Expand Up @@ -276,7 +280,15 @@ public void setArchitectureSha256(Object architectureSha256) {
public String getSourceFileName() {
if (source == null)
return source;
return new File(source).getName();
try {
return CommonUtils.getFileNameFromURLString(source);
} catch (MalformedURLException e) {
if (source.startsWith(Constants.ZENODO_DOMAIN) && source.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return new File(source.substring(0,
source.length() - Constants.ZENODO_ANNOYING_SUFFIX.length())).getName();
else
return new File(source).getName();
}
}

boolean gpu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
package io.bioimage.modelrunner.bioimageio.description.weights;

import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.bioimage.modelrunner.utils.CommonUtils;
import io.bioimage.modelrunner.utils.Constants;
import io.bioimage.modelrunner.versionmanagement.SupportedVersions;

/**
Expand Down Expand Up @@ -295,7 +298,15 @@ public void setArchitectureSha256(Object architectureSha256) {
public String getSourceFileName() {
if (source == null)
return source;
return new File(source).getName();
try {
return CommonUtils.getFileNameFromURLString(source);
} catch (MalformedURLException e) {
if (source.startsWith(Constants.ZENODO_DOMAIN) && source.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return new File(source.substring(0,
source.length() - Constants.ZENODO_ANNOYING_SUFFIX.length())).getName();
else
return new File(source).getName();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
package io.bioimage.modelrunner.bioimageio.description.weights;

import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.bioimage.modelrunner.utils.CommonUtils;
import io.bioimage.modelrunner.utils.Constants;

/**
* Class that contains the information for Pytorch state dic weights.
* For more information about the parameters go to:
Expand Down Expand Up @@ -151,7 +155,13 @@ public void setSha256(Object s) {
* {@inheritDoc}
*/
public String getSource() {
return source;
if (source != null &&
source.startsWith(Constants.ZENODO_DOMAIN)
&& source.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return source.substring(0,
source.length() - Constants.ZENODO_ANNOYING_SUFFIX.length());
else
return source;
}

/**
Expand Down Expand Up @@ -276,7 +286,15 @@ public void setArchitectureSha256(Object architectureSha256) {
public String getSourceFileName() {
if (source == null)
return source;
return new File(source).getName();
try {
return CommonUtils.getFileNameFromURLString(source);
} catch (MalformedURLException e) {
if (source.startsWith(Constants.ZENODO_DOMAIN) && source.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return new File(source.substring(0,
source.length() - Constants.ZENODO_ANNOYING_SUFFIX.length())).getName();
else
return new File(source).getName();
}
}

boolean gpu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@
package io.bioimage.modelrunner.bioimageio.description.weights;

import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.bioimage.modelrunner.utils.CommonUtils;
import io.bioimage.modelrunner.utils.Constants;

/**
* Class that contains the information for Tensorflow Javascript weights.
* For more information about the parameters go to:
Expand Down Expand Up @@ -276,7 +280,15 @@ public void setArchitectureSha256(Object architectureSha256) {
public String getSourceFileName() {
if (source == null)
return source;
return new File(source).getName();
try {
return CommonUtils.getFileNameFromURLString(source);
} catch (MalformedURLException e) {
if (source.startsWith(Constants.ZENODO_DOMAIN) && source.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return new File(source.substring(0,
source.length() - Constants.ZENODO_ANNOYING_SUFFIX.length())).getName();
else
return new File(source).getName();
}
}

boolean gpu = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
package io.bioimage.modelrunner.bioimageio.description.weights;

import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.bioimage.modelrunner.utils.CommonUtils;
import io.bioimage.modelrunner.utils.Constants;
import io.bioimage.modelrunner.versionmanagement.SupportedVersions;

/**
Expand Down Expand Up @@ -297,7 +300,15 @@ public void setArchitectureSha256(Object architectureSha256) {
public String getSourceFileName() {
if (source == null)
return source;
return new File(source).getName();
try {
return CommonUtils.getFileNameFromURLString(source);
} catch (MalformedURLException e) {
if (source.startsWith(Constants.ZENODO_DOMAIN) && source.endsWith(Constants.ZENODO_ANNOYING_SUFFIX))
return new File(source.substring(0,
source.length() - Constants.ZENODO_ANNOYING_SUFFIX.length())).getName();
else
return new File(source).getName();
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/bioimage/modelrunner/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,9 @@ void doTiling(List<Tensor<R>> inputTensors, List<Tensor<T>> outputTensors,
int[] tilesPerAxis = inTileSpecs.values().stream().findFirst().get().getPatchGridSize();
int nTiles = 1;
for (int i : tilesPerAxis) nTiles *= i;
tileCounter.acceptTotal(new Long(nTiles));
tileCounter.acceptTotal(Long.valueOf(nTiles));
for (int j = 0; j < nTiles; j ++) {
tileCounter.acceptProgress(new Long(j));
tileCounter.acceptProgress(Long.valueOf(j));
int tileCount = j + 0;
List<Tensor<?>> inputTileList = IntStream.range(0, inputTensors.size()).mapToObj(i -> {
if (!inputTensors.get(i).isImage())
Expand Down

0 comments on commit 290e5f7

Please sign in to comment.