Giter VIP home page Giter VIP logo

Comments (10)

Ichaelus avatar Ichaelus commented on June 2, 2024 1

Some hints for those trying to execute your (awesome 😍 ) piece of software without a Cuda-supporting GPU:

In ColorizeVisualization.ipynb

  • Remove the line torch.cuda.set_device(0), since you don't use cuda
  • Remove the line "IMAGENET = Path('data/imagenet/ILSVRC/Data/CLS-LOC/train')\n",
  • Modify the following to "colorizer_path = 'colorize_gen_192.h5'\n",

In DeFadeVisualization.ipynb

  • Replace all .cuda(gpu) calls with .cpu()

Bonus, if you want to transform an entire input folder (e.g. called "input_images"):

    "import os\n",
    "for subdir, dirs, files in os.walk('input_images'):\n",
    "    for file in files:\n",
    "        vis.plot_transformed_image(os.path.join(subdir, file))"

For this, you might also want to patch fastai, since it does keep the figures in memory which will eventually cause you to run out of memory.

In fasterai/visualize.py:37

  • Add plt.close(fig)

Cheers, Ichaelus

from deoldify.

Ichaelus avatar Ichaelus commented on June 2, 2024 1

Hi again!

Yes, I followed your installation guide and chose "CPU" whenever possible 😉 That said, I am launching the application with conda activate fastai-cpu && jupyter notebook. The render speed is not that regarding the possible outcome. Yesterday, I went over to creating colorizations for 8 different render factors per image to spot the right one (which is by far not always the highest possible render factor!), and it takes me about 1-2 minutes per batch (of 8). The bottleneck of choosing higher render factors was rather my 16GB of RAM than the Coffee Lake CPU. Code see Appendinx.

Colab/Jupyter and all this was new to me, so I felt more comfortable having all set up locally at first.

That's a good point with mathplotlib, I always went straight to the result_images directory to see the images and didn't mind the plotted figure :)


Appendix: Code to create multiple versions of the input image. I needed to patch the underlying method to create different output images, though.

import os
for subdir, dirs, files in os.walk('input_images'):
    for file in files:
        print(file)
        for render_factor in [6, 12, 18, 24, 30, 36, 42, 48]:
            new_path = os.path.join(subdir, file)
            vis.plot_transformed_image(new_path, render_factor=render_factor)

from deoldify.

jantic avatar jantic commented on June 2, 2024 1

I'm going to close this. It's not actually worth it if you have a gpu (almost everybody does these days) and there's a Colab notebook that provides the hardware if you don't have it.

from deoldify.

jantic avatar jantic commented on June 2, 2024

Thanks! This will be a good reference before I try to programmatically support this stuff.

The plt.close(fig) thing in particular- great catch. I'll look at fixing that today.

Did you use the pytorch-cpu install for this? That was the only way I got it working at a reasonable speed (it's a PITA to have a separate install just for cpu though). For rendering mind you (don't try to train with CPU!) And by reasonable I mean slow as fuck but not infinitely slow (like maybe a minute or two for some renders on a 16 core threadripper lol).

conda install -c pytorch pytorch-cpu

from deoldify.

jantic avatar jantic commented on June 2, 2024

Also- ultimately if you're just interested in rendering with pretrained weights, I strongly recommend to just use the Colab notebook. They give you a free 11GB (!!!) gpu and it's as hassle free as you can get right now. Though I do understand it's nice to just have it on your own machine and do whatever you want with it.

from deoldify.

jantic avatar jantic commented on June 2, 2024

Update on the plt.close(fig) thing- It turns out that if you close the figure, it makes the image disappear in Juptyer (doh!). Currently at least- I'm sure there's a way around it. I do wonder if it's worth trying to address it though. I suppose if somebody is doing a huge batch then yeah...problem. But then really should they be plotting to matplotlib to begin with...(and therefore the plot_transformed_image function)? Sounds like it should just be going straight to file, because it'd also be problematic to load up Jupyter with tons of images (I've tried...it doesn't like it).

I'm going to let this go for now unless I hear of concrete problems with this that convince me it needs to be changed. #TradeOffs and whatnot.

from deoldify.

Hyfred avatar Hyfred commented on June 2, 2024

I have a problem fou you. I follow your guidance. Everything went successful until this step:
image
image
Hope get your help, thanks!!

from deoldify.

jantic avatar jantic commented on June 2, 2024

So what are you attempting to do here- gpu or cpu rendering?

from deoldify.

Hyfred avatar Hyfred commented on June 2, 2024

I attempted the -cpu rendering. @jantic

from deoldify.

jantic avatar jantic commented on June 2, 2024

You might have to do this

conda remove pytorch

then

conda install -c pytorch=0.4.1 pytorch-cpu=0.4.1

I -think- the second command will work but haven't tried it.

I say that because it's complaining about CUDA, yet CUDA is only relevant to GPUs. And it shouldn't even get to this point unless something's screwed up with the pytorch-cpu install.

from deoldify.

Related Issues (20)

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.