Skip to content

Commit

Permalink
Merge pull request #39 from deepimagej/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
carlosuc3m authored Jun 16, 2022
2 parents f315538 + 278fbf0 commit 248ea23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/main/java/deepimagej/DeepImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ public boolean findZippedBiozooModel(File modelFolder) throws IOException {
modelName = modelName.substring(modelName.indexOf("/") + 1);
} else if (checkURL(modelName)) {
modelName = new File(modelName).getName();
} else {
modelName = new File(modelName).getName();
}
String auxModelName = "tensorflow_saved_model_bundle.zip";
boolean auxPresent = false;
Expand All @@ -454,7 +456,8 @@ public boolean findZippedBiozooModel(File modelFolder) throws IOException {
if (file.equals(modelName) && !this.presentYaml) {
tfName = modelName;
return true;
} else if (file.equals(modelName) && FileTools.createSHA256(modelFolder.getPath() + File.separator + file).equals(params.tfSha256)) {
} else if (file.equals(modelName) ) {//&& FileTools.createSHA256(modelFolder.getPath() + File.separator + file).equals(params.tfSha256)) {
String sha = FileTools.createSHA256(modelFolder.getPath() + File.separator + file);
tfName = modelName;
return true;
} else if (file.equals(modelName)) {
Expand Down Expand Up @@ -497,6 +500,8 @@ public boolean findPytorchModel(File modelFolder) {
modelName = modelName.substring(modelName.indexOf("/") + 1);
} else if (checkURL(modelName)) {
modelName = new File(modelName).getName();
} else {
modelName = new File(modelName).getName();
}
String auxModelName = "pytorch_script.pt";
String auxModelName2 = "weights-torchscript.pt";
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/deepimagej/InstallerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,23 @@ private void installModelBioimageio() {
@Override
public void run() {
install.setEnabled(false);
if (downloadURLs.size() == 1 && new File(downloadURLs.get(0)).isFile()) {
if (tab.getSelectedIndex() == 0 && downloadURLs != null) {
downloadModelFromInternet();
} else if (tab.getSelectedIndex() == 0 && downloadURLs == null) {
IJ.error("This model does not have links to download.");
}
if (tab.getSelectedIndex() == 1 && rbZIP.isSelected() && new File(txtZIP.getText()).isFile()) {
downloadURLs = new ArrayList<String>();
downloadURLs.add(txtZIP.getText());
copyFromPath();
} else {
} else if (tab.getSelectedIndex() == 1 && rbURL.isSelected() && Model.checkURL(txtURL.getText())) {
downloadURLs = new ArrayList<String>();
downloadURLs.add(txtURL.getText());
downloadModelFromInternet();
} else if (tab.getSelectedIndex() == 1 && rbURL.isSelected() && !Model.checkURL(txtURL.getText())) {
IJ.error("Introduced String does not correspond to a valid URL");
} else if (tab.getSelectedIndex() == 1 && rbZIP.isSelected() && !(new File(txtZIP.getText()).isFile())) {
IJ.error("Introduced String does not correspond to a valid local file.");
}

stopped = true;
Expand All @@ -454,7 +467,7 @@ public void copyFromPath() {
File destFile = new File(modelsDir + File.separator + fileName);
progressScreen.setFileName(modelsDir + File.separator + fileName);
progressScreen.setmodelName(fileName);
progressScreen.setFileSize(webFileSize);
progressScreen.setFileSize(originalModel.length());
progressScreen.buildScreen();
progressScreen.setVisible(true);
FileTools.copyFile(originalModel, destFile);
Expand Down Expand Up @@ -550,7 +563,12 @@ public void downloadSingleFileModelFromInternet(String url) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("ddMMYYYY_HHmmss");
String dateString = sdf.format(cal.getTime());
fileName = model.name + "_" + dateString + ".zip";
String modelName;
if (model == null || model.name == null)
modelName = "model";
else
modelName = model.name;
fileName = modelName + "_" + dateString + ".zip";
URL website = new URL(url);
webFileSize = getFileSize(website);
rbc = Channels.newChannel(website.openStream());
Expand Down

0 comments on commit 248ea23

Please sign in to comment.