-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add Neural Style Transfer to apply to image(s)
- Loading branch information
Showing
31 changed files
with
635 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/src/main/java/m/co/rh/id/a_jarwis/app/provider/command/NSTApplyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package m.co.rh.id.a_jarwis.app.provider.command; | ||
|
||
import android.net.Uri; | ||
|
||
import java.io.File; | ||
import java.util.concurrent.ExecutorService; | ||
|
||
import io.reactivex.rxjava3.core.Single; | ||
import m.co.rh.id.a_jarwis.base.provider.component.helper.FileHelper; | ||
import m.co.rh.id.a_jarwis.ml_engine.provider.component.NSTEngine; | ||
import m.co.rh.id.aprovider.Provider; | ||
|
||
public class NSTApplyCommand { | ||
private final ExecutorService mExecutorService; | ||
private final FileHelper mFileHelper; | ||
private final NSTEngine mNSTEngine; | ||
|
||
public NSTApplyCommand(Provider provider) { | ||
mExecutorService = provider.get(ExecutorService.class); | ||
mFileHelper = provider.get(FileHelper.class); | ||
mNSTEngine = provider.get(NSTEngine.class); | ||
} | ||
|
||
public Single<File> execute(Uri uriFile, int theme) { | ||
return Single.fromFuture(mExecutorService.submit(() -> { | ||
String fullPath = uriFile.getPath(); | ||
int cut = fullPath.lastIndexOf("/"); | ||
File result = mFileHelper | ||
.createImageTempFile(fullPath.substring(cut + 1), uriFile); | ||
mNSTEngine.enqueueNsT(result, theme); | ||
return result; | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/m/co/rh/id/a_jarwis/app/ui/page/common/SelectNSTThemePage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package m.co.rh.id.a_jarwis.app.ui.page.common; | ||
|
||
import android.app.Activity; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import m.co.rh.id.a_jarwis.R; | ||
import m.co.rh.id.a_jarwis.app.ui.page.nav.param.SelectedTheme; | ||
import m.co.rh.id.a_jarwis.ml_engine.provider.component.NSTEngine; | ||
import m.co.rh.id.anavigator.StatefulView; | ||
import m.co.rh.id.anavigator.annotation.NavInject; | ||
import m.co.rh.id.anavigator.component.INavigator; | ||
|
||
public class SelectNSTThemePage extends StatefulView<Activity> implements View.OnClickListener { | ||
|
||
@NavInject | ||
private transient INavigator mNavigator; | ||
|
||
@Override | ||
protected View createView(Activity activity, ViewGroup container) { | ||
View rootView = activity.getLayoutInflater().inflate(R.layout.page_select_nst_theme, container, false); | ||
View mosaic = rootView.findViewById(R.id.container_mosaic_theme); | ||
mosaic.setOnClickListener(this); | ||
View candy = rootView.findViewById(R.id.container_candy_theme); | ||
candy.setOnClickListener(this); | ||
View rainPrincess = rootView.findViewById(R.id.container_rain_princess_theme); | ||
rainPrincess.setOnClickListener(this); | ||
View udnie = rootView.findViewById(R.id.container_udnie_theme); | ||
udnie.setOnClickListener(this); | ||
View pointilism = rootView.findViewById(R.id.container_pointilism_theme); | ||
pointilism.setOnClickListener(this); | ||
View backButton = rootView.findViewById(R.id.button_back); | ||
backButton.setOnClickListener(this); | ||
return rootView; | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
int id = view.getId(); | ||
if (id == R.id.container_mosaic_theme) { | ||
mNavigator.pop(new SelectedTheme(NSTEngine.THEME_MOSAIC)); | ||
} else if (id == R.id.container_candy_theme) { | ||
mNavigator.pop(new SelectedTheme(NSTEngine.THEME_CANDY)); | ||
} else if (id == R.id.container_rain_princess_theme) { | ||
mNavigator.pop(new SelectedTheme(NSTEngine.THEME_RAIN_PRINCESS)); | ||
} else if (id == R.id.container_udnie_theme) { | ||
mNavigator.pop(new SelectedTheme(NSTEngine.THEME_UDNIE)); | ||
} else if (id == R.id.container_pointilism_theme) { | ||
mNavigator.pop(new SelectedTheme(NSTEngine.THEME_POINTILISM)); | ||
} else if (id == R.id.button_back) { | ||
mNavigator.pop(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/m/co/rh/id/a_jarwis/app/ui/page/nav/param/SelectedTheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package m.co.rh.id.a_jarwis.app.ui.page.nav.param; | ||
|
||
import java.io.Serializable; | ||
|
||
public class SelectedTheme implements Serializable { | ||
private int selectedTheme; | ||
|
||
public SelectedTheme(int selectedTheme) { | ||
this.selectedTheme = selectedTheme; | ||
} | ||
|
||
public int getSelectedTheme() { | ||
return selectedTheme; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.