Skip to content

Commit

Permalink
Release: 1.2.1
Browse files Browse the repository at this point in the history
Fixed an issue where 'nvidia-smi' was not available
New optional path to set 'th' in case it cannot be found
  • Loading branch information
cameronleger committed Aug 5, 2017
1 parent 2b4cbbd commit 227c62a
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Unzip the release to a folder of your choice (or build from source and check the
8. Press Start!

# Usage
After you have performed the Minimum Required Steps and chosen an Output Folder path, you may want to use the Save button in the Settings Pane to save all of this information into a 'default' settings file that you can load next time you run the application.
After you have performed the Minimum Required Steps and chosen an Output Folder path, you may want to use the Save button in the Settings Pane to save all of this information into a 'default' settings file that you can load next time you run the application. If you're getting a File Not Found exception for the 'th' command because it's not properly in your PATH, you can set the path to 'th' below the Neural Style path.

The Chaining section of the Settings Pane allows you to quickly run multiple Neural Style commands that feed into each other with the previous result. A few settings that are commonly changed in this method are available. First, pick how many times to run the network. Then, the ratios determine those settings' values for each run. Basically, the current settings will apply to the final image in the chain, and for each result before the final image the values are multiplied by the ratio. For example, with a 0.5 Size Ratio over 3 runs for a final result of 1200px, the runs will start at 300px before going to 600px and finally 1200px. This can allow you to make higher quality and larger images than with a single run with single settings, and sometimes faster because less iterations are typically used with this.

Expand All @@ -65,6 +65,9 @@ In the Output Tab and next to the Image is the Output Queue Tree. Any started pr
The Neural Style Log Tab will show the output from the most recent running process. This is rarely used, but it's helpful to understand why a process might have failed, usually because of out-of-memory errors.

# Changelog
### 1.2.1
* Fixed an issue where 'nvidia-smi' was not available
* New optional path to set 'th' in case it cannot be found
### 1.2.0
* Support for recent neural-style features:
* Initialization Image
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<name>Neural Style GUI</name>
<groupId>com.cameronleger</groupId>
<artifactId>neural-style-gui</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>

<dependencies>
<dependency>
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/cameronleger/neuralstyle/NeuralStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class NeuralStyle implements Cloneable {
public final static int FINISHED = 4;
private int queueStatus = QUEUED;

private File thPath;
private File neuralStylePath;
private File[] styleImages;
private double[] styleWeights;
Expand Down Expand Up @@ -69,6 +70,14 @@ public void setQueueStatus(int queueStatus) {
this.queueStatus = queueStatus;
}

public File getThPath() {
return thPath;
}

public void setThPath(File thPath) {
this.thPath = thPath;
}

public File getNeuralStylePath() {
return neuralStylePath;
}
Expand Down Expand Up @@ -469,8 +478,12 @@ public String[] buildCommand() {
gpuIndicesBuilder.append(",");
}

String th = "th";
if (getThPath() != null)
th = getThPath().getAbsolutePath();

ArrayList<String> commandList = new ArrayList<>(
Arrays.asList("th",
Arrays.asList(th,
"neural_style.lua",
"-style_image",
styleImagesBuilder.toString(),
Expand Down
28 changes: 25 additions & 3 deletions src/main/java/com/cameronleger/neuralstylegui/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
import com.cameronleger.neuralstylegui.service.NvidiaService;
import com.cameronleger.neuralstylegui.service.OutputService;
import javafx.beans.Observable;
import javafx.beans.property.Property;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Point2D;
Expand Down Expand Up @@ -74,6 +71,11 @@ public class MainController implements Initializable {

private final KeyCombination spaceBar = new KeyCodeCombination(KeyCode.SPACE);

@FXML
private Button thPathButton;
@FXML
private TextField thPath;

@FXML
private Button neuralPathButton;
@FXML
Expand Down Expand Up @@ -384,6 +386,14 @@ private void updateImageView() {
outputImageView.setImage(imageFile);
}

private void setThPath(File newThPath) {
if (newThPath == null)
thPath.setText("");
else
thPath.setText(newThPath.getAbsolutePath());
neuralStyle.setThPath(newThPath);
}

private void setNeuralPath(File neuralStylePath) {
if (neuralStylePath == null)
neuralPath.setText("");
Expand Down Expand Up @@ -820,6 +830,7 @@ private void loadStyle(NeuralStyle loadedNeuralStyle) {
styleMultipleSelect.setSelected(selectedStyleImages.length != 1);

// Set paths
setThPath(neuralStyle.getThPath());
setNeuralPath(neuralStyle.getNeuralStylePath());
setProtoFile(neuralStyle.getProtoFile());
setModelFile(neuralStyle.getModelFile());
Expand Down Expand Up @@ -909,6 +920,8 @@ private void showTooltipNextTo(Region region, String text) {
}

private void checkInjections() {
assert thPathButton != null : "fx:id=\"thButton\" was not injected.";
assert thPath != null : "fx:id=\"thPath\" was not injected.";
assert neuralPathButton != null : "fx:id=\"neuralPathButton\" was not injected.";
assert neuralPath != null : "fx:id=\"neuralPath\" was not injected.";
assert saveStyleButton != null : "fx:id=\"saveStyleButton\" was not injected.";
Expand Down Expand Up @@ -1020,6 +1033,15 @@ private void setupObservableLists() {
}

private void setupButtonListeners() {
log.log(Level.FINER, "Setting TH listener.");
EventStreams.eventsOf(thPathButton, ActionEvent.ACTION).subscribe(actionEvent -> {
log.log(Level.FINER, "Showing th file chooser.");
fileChooser.setTitle(bundle.getString("thPathChooser"));
File thPath = fileChooser.showOpenDialog(stage);
log.log(Level.FINE, "th file chosen: {0}", thPath);
setThPath(thPath);
});

log.log(Level.FINER, "Setting Neural Path listener.");
EventStreams.eventsOf(neuralPathButton, ActionEvent.ACTION).subscribe(actionEvent -> {
log.log(Level.FINER, "Showing neural-style folder chooser.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ protected Task<Integer> createTask() {

exitCode = p.waitFor();
log.log(Level.FINER, String.format("nvidia-smi process exit code: %s", exitCode));
} catch (IOException e) {
// No NVIDIA SMI tools, oh well
} catch (Exception e) {
log.log(Level.SEVERE, e.toString(), e);
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</HBox>
<HBox>
<children>
<Button fx:id="thPathButton" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" text="%thPathButton">
<tooltip>
<Tooltip maxWidth="300.0" text="%thPathTooltip" wrapText="true" />
</tooltip>
</Button>
<TextField fx:id="thPath" editable="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" promptText="%thPathHint" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets left="4.0" />
</HBox.margin>
<tooltip>
<Tooltip maxWidth="300.0" text="%thPathTooltip" wrapText="true" />
</tooltip>
</TextField>
</children>
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</HBox>
<HBox alignment="CENTER">
<children>
<Button fx:id="saveStyleButton" mnemonicParsing="false" text="%saveStyleButton" />
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/main_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ neuralPathButton=Neural-Style
neuralPathHint=Path to the neural-style folder
neuralPathChooser=Open neural-style folder

thPathButton=th
thPathTooltip=If you get a File Not Found error for th, you may need to set this
thPathHint=Optional path to th
thPathChooser=th executable

saveStyleButton=Save
saveStyleChooser=Save neural-style parameters
saveStyleSuccess=Saved!
Expand Down

0 comments on commit 227c62a

Please sign in to comment.