jantic / DeOldify

A Deep Learning based project for colorizing and restoring old images (and video!)
MIT License
18.02k stars 2.57k forks source link

Issue with colorization loop render_factor=i causing render factor to increase #229

Closed ghost closed 4 years ago

ghost commented 4 years ago

I been trying this today and in VideoColorizer the colorization code has a bug.

for i in range(10,45,2):
    colorizer.vis.plot_transformed_image('video/bwframes/' + file_name + '/00001.jpg', render_factor=i, display_render_factor=True, figsize=(8,8))

Notice that render_factor=i which makes each frame a higher render factor to the point where it will run out of memory and crash.

I fixed by doing render_factor=render_factor

Edit: Render factor is set here image

In fact this is my complete code which now successfully colorizes the video on my modest GTX 1050 Ti

for i in range(10,45,2):
    colorizer.vis.plot_transformed_image('video/bwframes/' + file_name + '/00001.jpg', render_factor=i, display_render_factor=True, figsize=(8,8))
    torch.cuda.empty_cache()
    gc.collect() 
jantic commented 4 years ago

That's totally intentional. The function of that is to serve as a preview of the frames at different render_factors. You're running out of memory with it because it goes up to a render_factor that your card can't handle. That's a 4GB card. That's not a lot to work with.

Please read the instructions next time before reporting a bug. It's a big waste of time not to for everybody involved. There's a reason I wrote this in the notebook:

If a video you downloaded doesn't play, it's probably because the cell didn't complete processing and the video is in a half-finished state. If you get a 'CUDA out of memory' error, you probably have the render_factor too high. The max is 44 on 11GB video cards.

And this:

If a video takes a long time to render and you're wondering how well the frames will actually be colorized, you can preview how well the frames will be rendered at each render_factor by using the code at the bottom. Just stop the video rendering by hitting the stop button on the cell, then run that bottom cell under "See how well render_factor values perform on a frame here". It's not perfect and you may still need to experiment a bit especially when it comes to figuring out how to reduce frame inconsistency. But it'll go a long way in narrowing down what actually works.

And even this title above the render_factor preview code you're citing:

See how well render_factor values perform on a frame here

Closing.

ghost commented 4 years ago

Is a waste of time for everyone using your project designing this so it only works for you and on top of it being very rude about it.

jantic commented 4 years ago

This seems a bit one sided. Just think about it- why exactly do I owe this to you...?

I'm just sharing research. You didn't pay for it, nor am I getting paid to play customer service. If you're not willing to read and are that ready to waste others' time, I'd consider that quite rude.

KeygenLLC commented 2 years ago

I know this is old, but in case anyone stumbles on this (like I did when looking for info on how to grab the render_factor), I'd like to share my 2¢ about this project and others like it on Github.

This software is not hard to use or modify if you have some knowledge of python. Yeah, you can't just type in make_pretty.py --now and get what you want. However, just because it's setup with jupyter notebooks doesn't mean you have to use it that way. It's python ffs and they gave us the source code. 😆

As an example, I've only been using python for about 2 weeks, am not a programmer by trade, and only have experience with PHP and markdown and such. With a reasonable amount of research and effort, I was able to convert the .ipynb notebook I needed into a .py file. I added custom environment variables with python-dotenv, input and output paths, turned the vis.plot_transformed_image into a method with args and modified the hell out of the script using lists, while and for loops, added keyboard exceptions, formatted the output so it's human readable with colorama and f-strings with tons of feedback I need, formatted the output filenames with date stamps and render_factor, setup a separate script with watchdog to watch folders, am firing off shell commands and controlling the keyboard and mouse programmatically, and even created my own socket server that I can connect to as a client with the script to send it data.

Now I can batch to my heart's content and output multiple files and multiple versions of them in one go with different render_factor by dropping images in a folder and typing one command.

Then I did the same with 15 more scripts.

Not everything was easy. Some days were 90% failures. Trying to make head or tail of visualize.py to add dynamic path variables and output the filenames I wanted, took almost a whole day and made me go cross-eyed when trying to grab the render_factor from the correct function, but I finally figured it out through trial and error. Still working out some bugs with the socket server because I coded it from scratch, but so what. I'm learning a lot and the tools worked... eventually. 😬

Don't get mad at these guys if they aren't handing you the keys to the castle and ushering you through the halls in a diaper. They're nice enough for providing this research tool for free. God only knows how much work they put in to build it, and how many years of learning were behind it. Between Github, StackOverflow, StackExchange and YouTube—not to mention all the free packages you can use in a heartbeat with pip and Anaconda—you can learn plenty and do plenty on your own if you are diligent and put in the time... and it's not even that much time that's needed.

jantic commented 2 years ago

@KeygenLLC I have to let you know that both @dana-kelley and I are fans of you and your comments here. I don't know if you realize just how much of a relief it is to hear someone with sense on the internet these days!

Oh and visualize.py is a bit of a hacky nightmare LOL. Sorry about that....

ghost commented 2 years ago

Still think is a bug.

jantic commented 2 years ago

@filipworksdev Cool story, bro.

ghost commented 2 years ago

@jantic You call yourself a project manager. Look how you talk.

ghost commented 2 years ago

Not everything was easy. Some days were 90% failures. Trying to make head or tail of visualize.py to add dynamic path Don't get mad at these guys if they aren't handing you the keys to the castle and ushering you through the halls in a diaper. They're nice enough for providing this research tool for free. God only knows how much work they put in to build it, and how many years of learning were behind it. Between Github, StackOverflow, StackExchange and YouTube—not to mention all the free packages you can use in a heartbeat with pip and Anaconda—you can learn plenty and do plenty on your own if you are diligent and put in the time... and it's not even that much time that's needed.

I think the problem with this project is the owner is a jerk and is a waste of anyone's time using this project because he uses it as a way to troll people who try it and realize the project doesn't work.

I posted in honest faith thinking is a bug. I still think is a bug. It doesn't make sense that you would want to render one video at multiple ratios when you clearly choose one specific ratio in the first function.

There was never any need for trolling or rude remarks. Absolutely no professionalism.

In reality this is an experimental project that only works for the creator and I didn't want to sink in anymore time only to get more rude and troll remarks instead of genuine help.

Edit: I am by no means a beginner and I was willing to put in the time and effort but this here was my first interaction with the project put me off.

KeygenLLC commented 2 years ago

When you work in production, you do tons of tests. It doesn't matter if you use closed-source software, which can be an even be a bigger nightmare. Trying to meet perishable deadlines, even in a big VFX studio, you need to find workarounds for workarounds, for your workarounds when your 3rd-string fall-backs fail and the client pushed the deadline back by a month. It doesn't matter whether you use After Effects, Maya, or something that has open source code. You need to be a hacker at heart, even if you're an artist and no excuses are allowed when big money is on the line. You have to be like Dustin Hoffman in Wag the Dog. That's my mantra, "This is nothing. Try a ten AM script meeting, coked to the gills, no sleep and you haven't even read the treatment."

The aforementioned closed-source apps can be even worse, because you can't access the source, can't reach the dev team to even pose a question, the customer service people know as much about the what we do as a blind hooker, and you have to hope Adobe or Autodesk decide to patch things, if ever.

This was my first look at jupyter notebooks and it didn't seem very user-friendly, so I worked around it. And yes, this is not the most user-friendly script on Github. Who cares? The developers wrote 8 paragraphs explaining why it is the way it is. They made it for them, not for us, and just let it loose in the wild to a thankless world. Dude's still smiling in his avatar and I'm laughing while smoking on my porch. I'm happy there's even software like this because I'm on a mac and don't have access to CUDA. Be a little greatful, ffs.

If you don't like it, just don't use it. There's plenty of other simpler colorization tools, with different looks. They don't all work with video, but you can just output an image sequence and batch them, even if you just dump the whole script in a function and use a for loop, you can build the video with any industry-standard video app or ffmpeg. It will take you like 5 minutes. When you work in production, you work with uncompressed frames, not mp4s, so this is standard practice. I work in 32-bit linear workflow and my next task is to figure out how to make these things work with EXR float files.

Check out colorization by richzhang. It uses 2 siggraph models to color images. Script is like 50 lines of code. Renders nearly instantly. Not the greatest, but not terrible, and you can augment output from different apps and scripts by compositing them to get what you want.

And you can call me whatever you want, kid. After going through the meat grinder of life, being called a jerk is a highlight.

☕️🚬

KeygenLLC commented 2 years ago

Some days were 90% failures.

P.S. Ask inventors about this one. It's probably higher than 90%. ☝🏻

jantic commented 2 years ago

I think the problem with this project is the owner is a jerk and is a waste of anyone's time using this project because he uses it as a way to troll people who try it and realize the project doesn't work.

Simply put, I'm not your Reek from Game of Thrones.

I don't bend over backwards to stroke the egos of people who refuse to take the time read what I actually wrote a year ago just enough to finally realize "Oh...there's an actual purpose to this that I missed." I don't expect you to do that now. Instead, despite my pointing this out, I fully expect you to double down on bestowing the honor of "jerk" on me and perhaps even throwing a few other choice insults my direction. After all, providing a year's worth of work to you and the rest of the world for free isn't enough. I must go further and embrace "professionalism". That is to say- I must surrender my personality, forgo any actual opinions and standards of basic human conduct expected in any other sphere of life- in order to please my masters. The CONSUMER*.

Or I can just say "fuck that" and move on with my life and feel satisfied that my work has gone far and wide already, instead of making myself miserable by conforming to the insane and completely unreasonable expectations of the increasingly unhinged masses on the internet.

Yeah, let's do that.

*Obviously this is a very liberal use of the term "consumer" as this is a completely free project.