DeOldify: a program for coloring black and white images

 3r33464. 3r3-31. In short, the task of this project is to color and restore old images. I’ll go into the details a little bit, but first let's see the pictures! By the way, most of the original images are taken from the r /TheWayWeWere subdit, thank you all for such high-quality large images. 3r33450.  3r33464. 3r33450.  3r33464. 3r33383. These are just a few examples, and they are quite typical! [/b] 3r33450.  3r33464. 3r33450.  3r33464. Maria Anderson as Little Fairy and her page Lyubov Ryabtsova in the Sleeping Beauty ballet at the Imperial Theater, St. Petersburg, Russia, 1890 3-3-312. 3r33450.  3r33464. forked her here . Again, updating to the latest version is on the agenda, I apologize in advance. 3r33393.  3r33464. 3r33333. 3r33383. All dependencies are Fast.AI [/b] : there are convenient requirements.txt and environment.yml files. 3r33393.  3r33464. 3r33333. 3r33383. Pytorch ??? [/b] (spectral_norm is required, so the last stable release is needed). 3r33393.  3r33464. 3r33333. 3r33383. JupyterLab [/b] . 3r33393.  3r33464. 3r33333. 3r33383. Tensorboard [/b] (i.e. Tensorflow installation) and 3r33257. 3r33383. TensorboardX [/b]
. I think this is not strictly necessarily, but so much easier. For your convenience, I have already provided all the necessary hooks /callbacks in the Tensorboard! There are examples of their use. It is noteworthy that by default, images are processed in the Tensorboard every 200 iterations, so you get a constant and convenient view of what the model does. 3r33393.  3r33464. 3r33333. 3r33383. ImageNet 3r3r. : A great data set for learning. 3r33393.  3r33464. 3r33333. 3r33383. Powerful graphics card [/b] . I would really like to have more memory than 11 GB in my GeForce 1080Ti. If you have something weaker, it will be difficult. Unet and Critic are absurdly large, but the bigger they are, the better the results. 3r33393.  3r33464. 3r33395. 3r33450.  3r33464. 3r33383. If you want to start image processing yourself right now [/b] without learning the model, you can download the finished weight here is . Then open ColorizationVisualization.ipynb in JupyterLab. Make sure that there is a line with a reference to the weight:
 3r33464. 3r33450.  3r33464. 3r3306. 3r3307. colorizer_path = Path ('/path /to /colorizer_gen_192.h5') 3r3309. 3r33450.  3r33464. Then you need to load the colorizer model after netG:
is initialized.  3r33464. 3r33450.  3r33464. 3r3306. 3r3307. load_model (netG, colorizer_path) 3r3309. 3r33450.  3r33464. Then simply place any images in the /test_images /folder from where you run the program. You can visualize the results in Jupyter Notebook with the following lines:
 3r33464. 3r33450.  3r33464. 3r3306. 3r3307. vis.plot_transformed_image ("test_images /derp.jpg", netG, md.val_ds, tfms = x_tfms, sz = 500) 3r3309. 3r33450.  3r33464. I would keep the size around 500px, plus or minus, if you run the program on a GPU with a lot of memory (for example, GeForce 1080Ti 11 GB). If the memory is less, then you will have to reduce the size of the pictures or try to run on the CPU. I actually tried to do the latter, but for some reason the model worked very, absurdly slowly, and I did not find the time to investigate the problem. Connoisseurs recommended building Pytorch from source, then you’ll get a big performance boost. Hmm At that moment it was not before. 3r33450.  3r33464. 3r33450.  3r33464. 3r33400. Additional information
3r33450.  3r33464. Render generated images as you learn 3-333410. can be [/i] run in Jupyter: you just need to set the value true when creating an instance of this visualization hook:
 3r33464. 3r33450.  3r33464. GANVisualizationHook (TENSORBOARD_PATH, trainer, 'trainer', jupyter = True, visual_iters = 100
 3r33464. 3r33450.  3r33464. I prefer to leave false and just use Tensorboard. Believe me, you also want to do just that. In addition, if left to work for too long, Jupyter will eat a lot of memory with such images. 3r33450.  3r33464. 3r33450.  3r33464. Model weights are also automatically saved during the GANTrainer training runs. By default, they are saved every 1000 iterations (this is an expensive operation). They are stored in the root folder that you specified for training, and the name corresponds to the save_base_name specified in the training schedule. Weights are stored separately for each workout size. 3r33450.  3r33464. 3r33450.  3r33464. I would recommend navigating the code from top to bottom, starting with Jupyter Notebook. I treat these notes simply as a convenient interface for prototyping and visualization, everything else will go into .py files as soon as I find a place for them. I already have examples of visualization that can be conveniently included and viewed: just open xVisualization in Notebook, the test images included in the project are listed there (they are in test_images). 3r33450.  3r33464. 3r33450.  3r33464. If you see GAN Schedules, then this is the ugliest thing in the project, just my version of the implementation of progressive GAN learning, suitable for the Unet generator. 3r33450.  3r33464. 3r33450.  3r33464. The pre-learned weights for the colorizer generator are also 3r33352. here is
. The project DeFade while in work, I will try to lay out a good weight in a few days. 3r33450.  3r33464. 3r33450.  3r33464. Usually, when training, you will see the first good results halfway, that is, with a size of 192px (if you use the provided training examples). 3r33450.  3r33464. 3r33450.  3r33464. I’m sure I screwed up somewhere, so please let me know if this is the case. 3r33450.  3r33464. 3r33450.  3r33464. 3r33400. Known issues
3r33450.  3r33464.
 3r33464. 3r33333. It will be a little Play around with image size to get the best result. The model clearly suffers from some dependence on the aspect ratio and size when generating images. It used to be much worse, but the situation improved significantly with the increase in lighting /contrast and the introduction of progressive learning. I want to completely eliminate this problem and focus on it, but do not despair if the image looks excessively saturated or with strange glitches. Most likely, everything will be fine after a small size change. As a rule, for oversaturated images you need to increase the size. 3r33393.  3r33464. 3r33333. In addition to the above: getting the best images really comes down to the art of choosing the optimal parameters . Yes, the results are selected manually. I am very pleased with the quality, and the model works quite reliably, but not perfectly. The project is still ongoing! I think the tool can be used as an "artist's AI", but it is not yet ready for the general public. Just not time yet. 3r33393.  3r33464. 3r33333. To complicate matters: the current model is eagerly guzzles memory , so on my 1080Ti card it turns out to process images with a maximum of 500-600px. I bet there are a lot of optimization options here, but I haven’t done that yet. 3r33393.  3r33464. 3r33333. I added a zero fill (zero padding) to the Unet generator for everything that does not fit the expected size (this is how I can upload an image of arbitrary size). It was a very fast hack, and it leads to silly right and lower bounds on the output of test images of arbitrary size. I am sure that there is a better way, but I have not found it yet. 3r33393.  3r33464. 3r33333. Model loves blue clothes. Not quite sure why the solution is in the search! 3r33393.  3r33464. 3r33395. 3r33450.  3r33464. 3r33450.  3r33464. 3r33400. Want more? 3r3013. 3r33450.  3r33464. I will post new results 3r3404. on twitter
. 3r33450.  3r33464. 3r33450.  3r33464. 3r33410. Addition from the translator. 3r33411. 3r33450.  3r33464. From the last on Twitter:
 3r33464. 3r33450.  3r33464. Representatives of the nationality themselves from their dugout, 1880 3-333450.  3r33464. 3r33420. 3r33450.  3r33464. ( Original )
 3r33464. 3r33450.  3r33464. Construction of the London Underground, 1860
 3r33464. DeOldify: a program for coloring black and white images Original
)
 3r33464. 3r33450.  3r33464. The Slums of Baltimore, 1938 3-3-3450.  3r33464. 3r3442. 3r33450.  3r33464. 3r33450.  3r33464. The gym on the Titanic, 1912 3-3-33450.  3r33464. Original
)
3r33464. 3r33464.
3r33464. 3r33460. 3r33464. 3r33464. 3r33464. 3r33464.
+ 0 -

Add comment