Code Monkey home page Code Monkey logo

neural-tile's Introduction

Neural-Tile

Creating a larger Neural-Style images through automated tiling.


The idea for the script comes from a combination of techniques discovered by SwoosHkiD/bododge and ProGamerGov which was posted on the Neural-Style Wiki.

0000sir created the original skeleton of the script.

Requirements

A Neural Art project like Neural-Style

And ImageMagick, install it with:

sudo apt-get install imagemagick

Usage

The default version of the script is 3x3 tiles.

Copy this script to neural-style directory and add your Neural-Style or other neural network based image project settings on lines 109-124 for the initial run through of the script. Then add the same settings, or different ones, to lines 139-156 for the tiles. Whether or not you are doing multires, or the normal process, make sure that -content_image $1, -style_image $2, and -output_image $3 remain the same for everytime the neural art project is ran with your settings. If using multires, then -output_image $3 only needs to remain for the last run through/step in the chain.

Then run:

./neural-tile.sh content_image style_image

If you face a permission error, try using chmod to fix the issue:

chmod u+x ./neural-tile.sh

If you have an already styled image, or had to stop the script before all the tiles were made, the script will automaticaly pickup where it left off at:

  • To use a previously styled image, place the image into in your Neural-Style/output/<Styled_Image> directory and change your specified "content_image" parameter to the name of your previously styled image. You also need to place a copy of you previously styled image into the Neural-Style directory.

  • To continue with already processed tiles, place the original tiles into the Neural-Style/output/<Image_Name>/ directory. Place the previvously styled tiles into the Neural-Style/output/<Image_Name>/tiles/ directory. Note that it if you are using tiles that you ran through Neural-Style in a previous session, make sure you are using the Neural-Style parameters for both sessions.

Due to the way the script creates and procceses the tiles, it should be possible to safely use the -save_iter command during the processing of the tiles. This can be done to save different iteration sets of tiles, that can be renamed by the user, so that the script will put them together.

If you are using multires or the normal single step process and want the tiled image to look similar to your original styled image:

  • The style scale value that results in zero style change, is the square root of the number of tiles the image was divided into. This equation will need to be adjusted if you use a style scale value other than 1 for the initial image styling.

  • Using -original_colors 1 may also help prevent style drift, at least in terms of color.

  • The amount of drift a tile undergoes, is dependent on the tile's content.

You can adjust the amount of overlap in any of the tiling scripts by changing the values on these lines:

#Defines the overlap overlap_w=50 overlap_h=50

  • Generally speaking, the larger the overlap value, the better your tiles will blend together. Though a larger overlap value results in a smaller output image. The default values have been tested to work with many different output images.

  • Using two different overlap values for the height and width has not been tested yet, so it is recommended you use the same value for both.

How It Works

1. Generate The First Output Image:

It is recommended that you change the Neural-Style parameters to your linking.

2. Split The Initial Output Image Into Tiles:

ImageMagick is used to divide your first Neural-Style output image into a series of overlapping cropped images.

3. Run The Tiles Through Neural-Style To Increase Their Quality And Size:

The same Neural-Style parameters are then used to "U-Pres" the overlapping crop pieces, resulting in a higher resolution output.

4. Feather The Tiles:

Feathering is used to blend the overlapping cropped tiles that have gone through Neural-Style in order to increase their resolution. Feathering values can be manipulated in order to find the best values for blending the tiles together.

5. Merge The Feathered And Non-feathered Tiles Into Separate Outputs:

The feathered tiles are put back together into an image that is larger than your original Neural-Style output image.

6. Layer The Feathered Image Above the Non-feathered Image:

This is done to disguise the feathering that is done to blend the tiles together.

neural-tile's People

Contributors

progamergov avatar velocityra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

neural-tile's Issues

image_size 640 then 768?

Is there any rationale for the example command first using 640 then 768 as image size?

I understand that always using 512 makes the most sense. And my 660 2GB GPU barely manages 512 if I kill Xorg.

Will the tiling be affected if I just use 512 in all 4 places?

Or do I have to use like 512, then 614 to keep the ratio?

Windows

If anyone has a Windows version of this, that would be awesome. Otherwise, I will start on one.

style_scale scale preservation

To preserve the initial image style at a higher resolution, and assuming an initial styleScale=1, then for a 2x2 script (and assuming we do single-scale at the same resolution to get roughly a 2x higher resolution output) we would want to set the neuralTile styleScale=2. This would require roughly 2x2=4 times as much GPU RAM, which defeats the purpose of doing tiling to increase the res. How else could we use Neural-Tile to increase the resolution while preserving the initial image style?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.