Skip to content

Commit

Permalink
Merge pull request #41 from deepimagej/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
carlosuc3m authored Oct 3, 2022
2 parents 248ea23 + db672b6 commit b4f0bbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>27.0.1</version>
<version>31.1.0</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -129,6 +129,8 @@ Universidad Carlos III de Madrid.</license.copyrightOwners>

<protobuf.version>3.2.0</protobuf.version>
<tensorflow.version>1.15.0</tensorflow.version>
<jna.version>5.11.0</jna.version>
<imagej-tensorflow.version>1.1.6</imagej-tensorflow.version>
</properties>
<repositories>
<repository>
Expand All @@ -150,12 +152,10 @@ Universidad Carlos III de Madrid.</license.copyrightOwners>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>libtensorflow</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>libtensorflow_jni</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
Expand All @@ -164,7 +164,6 @@ Universidad Carlos III de Madrid.</license.copyrightOwners>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej-tensorflow</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
Expand All @@ -189,18 +188,15 @@ Universidad Carlos III de Madrid.</license.copyrightOwners>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.26</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.3.0</version>
</dependency>
<!-- Dependencies for DJL Pytorch, END -->
<dependency>
Expand All @@ -211,7 +207,6 @@ Universidad Carlos III de Madrid.</license.copyrightOwners>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.72</version>
</dependency>
<!-- Test scope dependencies -->
<dependency>
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/deepimagej/InstallerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private void installModelZip() {
// Get the original name of the zip file
fileName = zipFile.getName();
fileName = fileName.substring(0, fileName.lastIndexOf("."));
fileName = fileName + "_" + dateString + ".zip";
fileName = removeInvalidCharacters(fileName + "_" + dateString + ".zip");

Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
Expand Down Expand Up @@ -378,7 +378,7 @@ private void installModelUrl() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("ddMMYYYY_HHmmss");
String dateString = sdf.format(cal.getTime());
fileName = "deepImageJModel" + "_" + dateString + ".zip";
fileName = removeInvalidCharacters("deepImageJModel" + "_" + dateString + ".zip");

Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
Expand Down Expand Up @@ -456,7 +456,7 @@ public void copyFromPath() {
try {
if (downloadURLs.size() != 1)
throw new Exception();
fileName = new File(downloadURLs.get(0)).getName();
fileName = removeInvalidCharacters(new File(downloadURLs.get(0)).getName());
// Add timestamp to the model name.
// The format consists on: modelName + date as ddmmyyyy + time as hhmmss
Calendar cal = Calendar.getInstance();
Expand Down Expand Up @@ -512,7 +512,7 @@ public void downloadSeveralFilesModelFromInternet() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("ddMMYYYY_HHmmss");
String dateString = sdf.format(cal.getTime());
fileName = model.name + "_" + dateString;
fileName = removeInvalidCharacters(model.name + "_" + dateString);
webFileSize = getFileSize();
new File(modelsDir + File.separator + fileName).mkdirs();
progressScreen.setFileName(modelsDir + File.separator + fileName);
Expand Down Expand Up @@ -568,7 +568,7 @@ public void downloadSingleFileModelFromInternet(String url) {
modelName = "model";
else
modelName = model.name;
fileName = modelName + "_" + dateString + ".zip";
fileName = removeInvalidCharacters(modelName + "_" + dateString + ".zip");
URL website = new URL(url);
webFileSize = getFileSize(website);
rbc = Channels.newChannel(website.openStream());
Expand Down Expand Up @@ -604,4 +604,12 @@ public void downloadSingleFileModelFromInternet(String url) {
}
progressScreen.stop();
}

public static String removeInvalidCharacters(String filename) {
String[] listForbidden = new String[] {"\\", "|", "/", "<", ">",
":", "\"", "?", "*"};
for (String invalid : listForbidden)
filename = filename.replace(invalid, "_");
return filename;
}
}

0 comments on commit b4f0bbf

Please sign in to comment.