Neural Style Transfer Tutorial with Tensorflow and Python in 10 Minutes

  Рет қаралды 42,149

Nicholas Renotte

Nicholas Renotte

Күн бұрын

Getting started with generative AI?
Want to learn how to make art with Tensorflow?
Maybe, you just can't be bothered with basic image filters?!
You need to check out Neural Style Transfer. Neural Style Transfer is a process that uses neural networks to apply the artistic style from one image to another. This means that you can take famous artworks and their styles and apply them to your own images. Even better yet, you can do it in just 10ish minutes using Python and Open Source tools like Tensorflow and Matplotlib.
In this video you'll go through:
1. Downloading a model from Tensorflow Model Hub
2. Preprocessing images for neural style transfer
3. Applying and visualizing style transfer
Get the CODE: github.com/nicknochnack/Pytho...
Chapters
0:00 - Start
0:30 - What is Neural Style Transfer
2:42 - Importing Dependencies for Neural Style Transfer with Python
3:33 - Loading a Neural Style Transfer model from Tensorflow Hub
5:10 - Preprocessing and Loading Images
8:38 - Visualising Images
9:34 - Running the Neural Style Transfer Algorithm
10:38 - Exporting Images
Oh, and don't forget to connect with me!
LinkedIn: / nicholasrenotte
Facebook: / nickrenotte
GitHub: github.com/nicknochnack
Happy coding!
Nick
P.s. Let me know how you go and drop a comment if you need a hand!

Пікірлер: 92
@Andy-rq6rq
@Andy-rq6rq 3 жыл бұрын
back at it again Nick, love the unique intros
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
🤣 I never know if people like them but I lmao when i'm making them!
@daidraich
@daidraich 6 ай бұрын
Wow thank you so much!
@joshcummins3916
@joshcummins3916 3 жыл бұрын
Very straight forward and awesome brother. Can't wait to make some art with this.
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Awesome!! Let me know how you go! Got some music generation vids planned as well!
@noahorosw
@noahorosw 2 жыл бұрын
Hi Nick! I just wanted to say this is so cool . I've always wished I could paint like Van Gough , and now I have like 50 brand new Masterpieces I just keep making more and more so cool . And I have so many pictures I've taken over the years with my drones from way up high and I haven't even tapped into those files yet . If you come up with anything new on this subject please make another video for all of us artist's so we can dive deeper into this , and create some serious real stuff . Like to take an image such as one we have created here . A profile picture with a Van Gough , and a deep learning code that will actually enhance , and beatify our finished image ? I don't know ? You are the master .
@onetwo203
@onetwo203 3 жыл бұрын
Top notch quality, keep going
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Definitely, thanks @one two!
@apristen
@apristen 2 жыл бұрын
nice tutorial for total beginners without deep tech details :-)
@_ept_
@_ept_ Жыл бұрын
Thanks, it's so just and beautiful
@zbmadon
@zbmadon 2 жыл бұрын
Hey Nicholas, is there a way to add multiple images to create a mash GAN artwork?
@doudou3580
@doudou3580 2 жыл бұрын
hi Nick! I followed your fantastic tutorial but was stuck in ‘ Loading a Neural Style Transfer model from Tensorflow Hub’. My program just could not run further and it's driving me crazy! I'm wondering if it's the Internet problem or the model itself. Lots of thanks.
@ashleysami1640
@ashleysami1640 3 жыл бұрын
Nick R, the next Monet 🧑🏾‍🎨
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
🤣 painting is my passion *furiously paints portrait*
@LuddeWessen
@LuddeWessen Жыл бұрын
Thank you for the demo, and code! You are very enthusiastic and inspiring! (I have spent hours tinkering with it.) It is amazing how these powerful things are available at our fingertips! When I started using NN:s 6 years ago, you had to script your caffee models in bash, on your own workstation, for days. And not reach very far, compared to today.
@5minupsc723
@5minupsc723 Ай бұрын
code is working ? I went through the github repository link but couldn't find code in the repository
@NoMercy8008
@NoMercy8008 2 жыл бұрын
This is super super fascinating :D I love art, I love ML .. this is perfect
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Did you check out the projects video then come straight here? 🤗🤗 Definitely, I think there's so many sick applications for GANs, I only really just got my head around them this week when building the super res project. I think I've kinda got it down pat, ready to start building some sick stuff!!
@NoMercy8008
@NoMercy8008 2 жыл бұрын
@@NicholasRenotte Yup, as soon as the projects video ended, I hurried over to this one like a madman :D As I said, I love ML, I love art, I love programming, so I really enjoy doing "generative/procedural art" and have done a couple of smaller creative coding projects with it in the past. And it constantly keeps blowing my mind what we can do with machine learning and AI in general, again for example this style transfer model is super interesting and fascinating to me :)
@funny11744
@funny11744 2 жыл бұрын
Hi ! Do you kow some free software to increase the size of image obtained with NICK software without affecting the quality ?
@NoMercy8008
@NoMercy8008 2 жыл бұрын
@@funny11744 There are ML super-resolution models that can be used to up-res an image, I think Nick is doing that kind of project more or less right now, so he might have a video about exactly that soon :)
@NoMercy8008
@NoMercy8008 2 жыл бұрын
@@funny11744 In the meantime, there's also a project on github called image-super-resolution (ISR), you can check that out if you wanna take a little dive into that topic before Nick releases his video.
@waishingwong3208
@waishingwong3208 2 жыл бұрын
Hi Nick! Thanks for the tutorial. What versions did you use for tensorflow and tensorflow_hub? I keep getting errors on my tensorflow_hub import (cannot import name 'Layer' from 'keras.engine') or (cannot import __version__ from keras). I tried changing my tensorflow version a few times, and I get an error on my tensorflow_hub import everytime.
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
For this, I think I was using TF 2.3.1 and Python 3.7.3, lmk how you go!
@bashirmanafikhi
@bashirmanafikhi 2 жыл бұрын
wow that's great thanks
@creativebeetle
@creativebeetle 3 жыл бұрын
Excellent video! Unfortunately I get an error "NameError: name 'load_image' is not defined" in the "content_image =" cell. Any idea as to why?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Dennis, there was an error I made in the video. The function and function call should be load_image. Try out the baseline code: github.com/nicknochnack/Python-Neural-Style-Transfer/blob/main/Neural%20Style%20Transfer-Template.ipynb
@newnewkidsontheblock
@newnewkidsontheblock 2 жыл бұрын
What is the before steps to this? As far as actually trying to run this in Anaconda and Jupyter? So the images can import?
@tracywang1
@tracywang1 4 ай бұрын
Thanks for sharing I'm wondering how to train my own stylization model? Can you shaed some light on that? or is there resources to learn that? Thanks!
@vikashchand.
@vikashchand. 3 жыл бұрын
If Bob Ross was a programmer 🔥😂 Cool stuff man! 🤘
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
🤣🤣 *in Bob Ross voice* "And now we're going to paint some happy little trees"
@vikashchand.
@vikashchand. 3 жыл бұрын
😂😂
@muditrustagi5775
@muditrustagi5775 3 жыл бұрын
wowowowow superrrrrrr
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Thanks so much @Mudit!
@riis08
@riis08 3 жыл бұрын
@Nicholas Renotte. Great video again... thanks... Is it possible that you can do this in Nodejs with realtime images??
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Thanks so much!! Yah, let me add it to the list.
@funny11744
@funny11744 2 жыл бұрын
@@NicholasRenotte Hi Nick. I let you know that I solved the problems from ColabNotebook using Google drive for upload . So I erased my comment wit errors found for Colab Notebook . Thanks for support and for understanding.
@newmoneyideas
@newmoneyideas 2 жыл бұрын
Video is good...pls also tell where you are writing this code..i mean software to write and execute the code.
@anticipate_tv
@anticipate_tv 2 жыл бұрын
legend
@im_yuri_24
@im_yuri_24 Жыл бұрын
Hello, Nicholas! Help needed! You do a great job and I've used your notebook as a showcase and it was working fine just 2 weeks ago, but now something happened - I've got error message at step 2 - ValueError: Trying to load a model of incompatible/unknown type. How this can be?
@im_yuri_24
@im_yuri_24 Жыл бұрын
In case someone meets same problem - check folder \AppData\Local\Temp\tfhub_modules - empty folders there block the model. Interesting, that in fact you can use 2 models = /magenta/arbitrary-image-stylization-v1-256/2 as in Nickolas's video or this /magenta/arbitrary-image-stylization-v1-256/1 - but they both can be blocked by matching empty folder in the folder, mentioned above. You need just delete empty folder and it will work
@kathib2571
@kathib2571 3 жыл бұрын
can i use this code in google colab, too? or what has to be different there? i don´t know how to upload own pictures and so much more. what is the easiest solution to work with style transfer? thanks
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Yep, you should be able to execute the same code in Colab!
@robotixIIIX2017
@robotixIIIX2017 Жыл бұрын
can u give link to site where we can do this?
@SpecialAgentOso
@SpecialAgentOso 8 ай бұрын
woah back up... what even is that page you're on? what am i supposed to install to get this going?
@ATHARVA89
@ATHARVA89 2 жыл бұрын
Nick if you could zoom in a bit from next time !!! great tutorial
@hazel3899
@hazel3899 2 жыл бұрын
Hopefully you're still checking comments on this! ;) i get this error when trying to call the image "Error! is not UTF-8 encoded" - looking for solutions on stackoverflow but no luck so far
@WingtoKwong
@WingtoKwong 3 жыл бұрын
"stylized_image = model(tf.constant(content_image),tf.constant(style_image))[0]" this line it gave me a Unknowerror...and it told me that 'Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.'
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Hmmm, this is normally a TF error. What version of TF are you running?
@esmatpoya
@esmatpoya 3 жыл бұрын
for the last line of code I got error "stylizedimage can you please help me
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Esmat, can you share the full error?
@alexijohansen
@alexijohansen 2 жыл бұрын
How does this handle the difference in resolution?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Didn't read into it too much, but this is the paper behind it: arxiv.org/abs/1705.06830
@Comegax
@Comegax 2 жыл бұрын
Good day! I have been trying for a while now, but I don't seem to quite get this SSL URL Error "URLError: " any ideas on the fix?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
On this project @Cian?
@MohamedAli-hh3qm
@MohamedAli-hh3qm 3 жыл бұрын
What is your idea about quantum computing sir...
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
That it's AWESOME! I haven't done anything yet but I work pretty closely with some of the team that uses this www.ibm.com/quantum-computing/ hoping to do a video on it soon!
@gareven
@gareven 2 жыл бұрын
Can we get output image size bigger than 2000 x 2000 pixels?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Would need a new model, but definitely possible!
@ianmarlowe3936
@ianmarlowe3936 2 жыл бұрын
did you ever find a model for this?
@funny11744
@funny11744 2 жыл бұрын
Hi Nick. A kindly request and question : how to increase the size of stylized_image to 1or 2 MB at least, without affecting the quality of image ? The stylized_image is very small. Maybe you can find a solution to add some codes to this software , or please mention few free of charge Photo editing software . Many thanks.
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
Would likely require a rearchitect of the model as far as I understand @Costache Bicu. Definitely possible to do though.
@funny11744
@funny11744 2 жыл бұрын
@@NicholasRenotte Sorry for trouble Nick, I hardly wait your next video to increase (improve) the quality of result in order to use that software in place of basic image filters- very boring as you mentioned. I have important plans using that technique , please help to improve the quality- the size of image. thanks
@ashitashetty1038
@ashitashetty1038 3 жыл бұрын
Hi, this is a great video. How can we do the same for a video?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Let me dig into that!
@martinkaiser5263
@martinkaiser5263 3 жыл бұрын
Can i run this on Windows 10 ? Because i have a RTX 2080 TI only available on windows . And how to do it ? Have Anaconda installed
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Definitely, you should be able to open a Jupyter Notebook, pip install any packages you need, and run the code: github.com/nicknochnack/Python-Neural-Style-Transfer
@martinkaiser5263
@martinkaiser5263 3 жыл бұрын
@@NicholasRenotte Which packages do i need and wich version ?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
@@martinkaiser5263 for this run through you'll need tensorflow, tensorflow_hub, matplotlib, numpy and OpenCV (aka cv2).
@brunohuf9016
@brunohuf9016 3 жыл бұрын
your code worked?
@martinkaiser5263
@martinkaiser5263 3 жыл бұрын
@@brunohuf9016 I set up Ubuntu 20.04 on a external SSD and doing all this stuff in Ubuntu and it works great
@saichowdhury7294
@saichowdhury7294 Жыл бұрын
Import tensorflow_hub as hub(there I got module error
@allenwong9918
@allenwong9918 2 жыл бұрын
how do i choose the image quality?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
I think you're kinda limited with this model, possibly look at using an alternate model would be my suggestion.
@faraheldeshnawy1202
@faraheldeshnawy1202 3 жыл бұрын
stylized_image = model(tf.constant(content_image),tf.constant(style_image))[0]" this line it gave me a key and type error I am using TF 2.0
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Heya @Farah, can you share the error?
@iammayurn
@iammayurn 2 жыл бұрын
How to part 2 of this video optimization and gradient descent.
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
You got it!
@iammayurn
@iammayurn 2 жыл бұрын
Why we need channel 3 and dtype flot32?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
It's part of the requirement for the model inputs!
@ezequielaguilera130
@ezequielaguilera130 3 жыл бұрын
can load more than 1 image ?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Haven't tested it @Ezequiel Aguilera
@funny11744
@funny11744 2 жыл бұрын
@@NicholasRenotte Does the software work with bigger file size? 1 or 2 MB photos ?
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
@@funny11744 I think it scales them down when transforming. I haven't tried anything that big tbh.
@syahrulhidayatullah9666
@syahrulhidayatullah9666 3 жыл бұрын
hi sir, why i cant install a tensorflow on python 3.9?
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
Doesn't look like it's supported yet www.tensorflow.org/install/pip, try 3.8.x!
@thicccrusade2302
@thicccrusade2302 2 жыл бұрын
Whole thing is broken, nothing is defined. No idea what's going on.. EDIT: Ok, now it's working, had to pip install some packages.. pip install tensorflow pip install tensorflow-hub pip install matplotlib pip install numpy pip install opencv-python
@NicholasRenotte
@NicholasRenotte 2 жыл бұрын
All good now? 🙂
@Moctop
@Moctop 2 жыл бұрын
Seems it uses vegetation and water to draw the portrait simply because it was in the reference...vegetation and water isn't the "style". It should look at the brush strokes, palette use, not copy the colors straight off. It's a big ask, I know.
Tensorflow Tutorial for Python in 10 Minutes
11:33
Nicholas Renotte
Рет қаралды 404 М.
Basic Theory | Neural Style Transfer #2
15:20
Aleksa Gordić - The AI Epiphany
Рет қаралды 19 М.
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 104 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 21 МЛН
FOOLED THE GUARD🤢
00:54
INO
Рет қаралды 61 МЛН
Upscale your Images using DEEP SUPER RESOLUTION with ESRGAN
21:24
Nicholas Renotte
Рет қаралды 101 М.
How to Code a AI Trading bot (so you can make $$$)
35:09
Nicholas Renotte
Рет қаралды 531 М.
Image Processing with OpenCV and Python
20:38
Rob Mulla
Рет қаралды 132 М.
Machine Learning Projects You NEVER Knew Existed
15:20
Nicholas Renotte
Рет қаралды 158 М.
Pytorch Neural Style Transfer Tutorial
24:38
Aladdin Persson
Рет қаралды 22 М.
Building a Neural Network with PyTorch in 15 Minutes | Coding Challenge
20:34
The U-Net (actually) explained in 10 minutes
10:31
rupert ai
Рет қаралды 82 М.
How I would learn Machine Learning (if I could start over)
7:43
AssemblyAI
Рет қаралды 741 М.
Style Transfer Better Than GANs! Swapping Autoencoder Explained
6:09
What's AI by Louis-François Bouchard
Рет қаралды 6 М.
Собери ПК и Получи 10,000₽
1:00
build monsters
Рет қаралды 999 М.
Iphone or nokia
0:15
rishton vines😇
Рет қаралды 1,8 МЛН
Samsung S24 Ultra professional shooting kit #shorts
0:12
Photographer Army
Рет қаралды 29 МЛН
Неразрушаемый смартфон
1:00
Status
Рет қаралды 1,6 МЛН