gustavla / autocolorize Goto Github PK
View Code? Open in Web Editor NEWAutomatic colorizaton of grayscale images using Deep Learning
License: BSD 3-Clause "New" or "Revised" License
Automatic colorizaton of grayscale images using Deep Learning
License: BSD 3-Clause "New" or "Revised" License
I was able to install the program the standard way, however the command cannot execute (unknown command). Probably a certain environment variable is not set, but I couldn't find out which one it is.
What file does the command "autocolorize" relate to?
In my Anaconda directory, I have two autocolorize folders under lib\site-packages.
There are many execututable python files, but all with different names.
E.g., when I execute main.pyc, it says "ValueError: Attemted relative import in non-package"
I know I am very close, but I don't know how to solve it. Any help would be appreciated!
I cannot get correct result from the python code, but when I use the command like
' autocolorize grayscale.png -o colorized.png' I get the correct results
My code is following:
import cv2
import os
import autocolorize
path2 = 'input/'
path3 = 'output/'
files= os.listdir(path2)
classifier = autocolorize.load_default_classifier()
for ff in files:
gray_image = cv2.imread(path2+ff)
rgb_image = autocolorize.colorize(gray_image, classifier=classifier)
cv2.imwrite(path3+rgb_image,rgb_image)
Maybe because "python" is called ?
Caffe works while be called via pyhton3.
/home>pip install autocolorize
Collecting autocolorize
Downloading https://files.pythonhosted.org/packages/4a/bd/7d4d2359de90526ec147ab98da032843261b7ee22e964cd1699e12093d2a/autocolorize-0.2.1-py2.py3-none-any.whl
Collecting scipy (from autocolorize)
Using cached https://files.pythonhosted.org/packages/24/40/11b12af7f322c1e20446c037c47344d89bab4922b8859419d82cf56d796d/scipy-1.2.3-cp27-cp27mu-manylinux1_x86_64.whl
Collecting numpy (from autocolorize)
Downloading https://files.pythonhosted.org/packages/3a/5f/47e578b3ae79e2624e205445ab77a1848acdaa2929a00eeef6b16eaaeb20/numpy-1.16.6-cp27-cp27mu-manylinux1_x86_64.whl (17.0MB)
100% |████████████████████████████████| 17.0MB 77kB/s
Collecting requests (from autocolorize)
Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 7.2MB/s
Collecting scikit-image (from autocolorize)
Using cached https://files.pythonhosted.org/packages/bb/7f/d27fadff2c2b8cd45fffe44330b3f26014e94e856d4b61e5bfd2701b1ccb/scikit_image-0.14.5-cp27-cp27mu-manylinux1_x86_64.whl
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->autocolorize)
Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
100% |████████████████████████████████| 133kB 7.6MB/s
Collecting certifi>=2017.4.17 (from requests->autocolorize)
Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
100% |████████████████████████████████| 163kB 6.2MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests->autocolorize)
Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 6.5MB/s
Collecting idna<2.9,>=2.5 (from requests->autocolorize)
Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
100% |████████████████████████████████| 61kB 7.0MB/s
Collecting PyWavelets>=0.4.0 (from scikit-image->autocolorize)
Using cached https://files.pythonhosted.org/packages/fa/f1/81d3ba0b461699a5e0dbd1a1c2c98c0b5a2e1757b7a54d49246e0a557aea/PyWavelets-1.0.3-cp27-cp27mu-manylinux1_x86_64.whl
Collecting cloudpickle>=0.2.1 (from scikit-image->autocolorize)
Using cached https://files.pythonhosted.org/packages/ea/0b/189cd3c19faf362ff2df5f301456c6cf8571ef6684644cfdfdbff293825c/cloudpickle-1.3.0-py2.py3-none-any.whl
Collecting six>=1.10.0 (from scikit-image->autocolorize)
Using cached https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Collecting networkx>=1.8 (from scikit-image->autocolorize)
Using cached https://files.pythonhosted.org/packages/f3/f4/7e20ef40b118478191cec0b58c3192f822cace858c19505c7670961b76b2/networkx-2.2.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named setuptools
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-aUZ6SF/networkx/
Hi,
Firstly, I want to congratulate you for this brilliant piece of work. I have tried your autocolorize and it works great ! Many thanks for making it publicly available.
I am trying to work on NIR images. Idea is to convert this single channel image to a color image. Since the nature of image is different from a normal grayscale image, I have to train the system from scratch / fine-tune your model. I followed your simple training instructions and I guess I am successful in copying the required files and setting up the training environment. I have setup the training without 'extended data layer'.
My input is LMDB (converted .jpg files to LMDB using create_imagenet.sh) and it contains 3 channel 640x480. When I run the training in CPU-only mode, I get the following error:
I0905 16:48:48.431213 14444 net.cpp:434] sr_x_minus_one <- sr_minus_one
I0905 16:48:48.431243 14444 net.cpp:408] sr_x_minus_one -> sr_x_minus_one
F0905 16:48:48.431275 14444 eltwise_layer.cpp:34] Check failed: bottom[i]->shape() == bottom[0]->shape()
I apologize if this is a trivial issue. I am not much experienced in CAFFE, thus, I request you to kindly help me to figure out the possible issue and get the training running.
Thank you in advance,
Kimi
I installed version '0.2.1-00' using pip
. This package depends on python python-numpy python-scikit-image python-requests python-scipy
packages.
But when I was trying to colorize one image, I got such an error
Traceback (most recent call last):
File "/usr/bin/autocolorize", line 8, in <module>
from autocolorize.__main__ import main
File "/usr/lib/python3.9/site-packages/autocolorize/__init__.py", line 7, in <module>
from .checker import checker_main
File "/usr/lib/python3.9/site-packages/autocolorize/checker.py", line 5, in <module>
import caffe
ModuleNotFoundError: No module named 'caffe'
Hello,
I installed caffe and autocolarize, but when I try to run for a png image(512x512) I get the following error.
F0417 13:52:09.999788 2561 hdf5.cpp:79] Check failed: blob_dims == blob->shape() Cannot load blob from hdf5; shape mismatch. Source shape is 4096 25088 (102760448) target shape is 4096 512 7 7 (102760448)
This causes the code to abort. Does anyone know how to solve this issue?
Hi Gustav,
Trying to train the network from scratch using your extended data layer (I did not find any quick way to avoid using that layer):
I am stuck at an error in when doing make all
in the caffe directory.
It seems that the ExtendedImageDataLayer
class is missing a lot of member attributes.
Could you please help?
CXX src/caffe/layers/extended_image_data_layer.cpp
src/caffe/layers/extended_image_data_layer.cpp: In instantiation of ‘void caffe::ExtendedImageDataLayer<Dtype>::DataLayerSetUp(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]’:
src/caffe/layers/extended_image_data_layer.cpp:703:1: required from here
src/caffe/layers/extended_image_data_layer.cpp:574:21: error: ‘class caffe::ExtendedImageDataLayer<float>’ has no member named ‘PREFETCH_COUNT’
for (int i = 0; i < this->PREFETCH_COUNT; ++i) {
^
src/caffe/layers/extended_image_data_layer.cpp:575:5: error: ‘__gnu_cxx::__alloc_traits<std::allocator<boost::shared_ptr<caffe::Batch<float> > > >::value_type’ has no member named ‘data_’
this->prefetch_[i].data_.Reshape(top_shape);
Hello, excuse me, can you provide a pre-trained model, the previous connection can no longer be opened
I use only cpu to run, but the output is 'killed'
Hi,
I am trying to compile caffe by including your layers, however i get following error message
src/caffe/layers/extended_image_data_layer.cpp:39:21: fatal error: maskApi.h: No such file or directory
I installed caffe in cpu-only mode on my laptop, which is sufficient for my use cases and also much easier to install. autocolorize by standard only works in gpu mode, it would be great if that would be parametrized! (Thanks to the source code I got it running in cpu-only mode (great!), I just uncommented the set parameter section).
https://github.com/gustavla/autocolorize/blob/master/autocolorize/__main__.py#L130
This won't work when the desired h_method
is expectation-cf
since the delimiting character is in one of the components.
Hello,
I have the same problem as #8.
I try to run: autocolorize grayscale.png -o colorized.png
I already run: rm ~/.autocolorize/autocolorize.caffemodel.h5 as told in #8
But the autocolorize still aborts.
In #8 it shows: 7 7 (102760448).
My results shows:
F0906 12:04:59.769284 24443 hdf5.cpp:79] Check failed: blob_dims == blob->shape() Cannot load blob from hdf5; shape mismatch. Source shape is 1024 12417 (12715008) target shape is 1024 12417 1 1 (12715008)
Does anyone know what is going on?
Thanks.
Can you provide code or network to train model on custom dataset ?
Hi,
I had no problems compiling caffe with GPU support and running your pip package to colorize some images, by the way congratulations for your work, deep learning colorization is really awesome!
On the training code, apparently "bgr_to_hsv_layer.hpp" include is missing.
Also I had to uncomment SoftmaxKLDLossParameter and SparseHistogramExtractorParameter on LayerParameter in order to try to recompile caffe.
Best regards
Hello,
In the README, I'm trying to find the proto folder containing this file but it's not there?
Thanks!
Actually, I managed to install Caffe and autocolorize and then, I try to get it working with an image.
I use GitBash, Windows 10, conda.
autocolorize grayscale.png -o colorized.png
I get the following error:File "C:/Users/xxx/anaconda3/envs/caffe/Scripts/autocolorize", line 11, in <module>
main()
File "C:\Users\xxx\anaconda3\envs\caffe\lib\site-packages\autocolorize\__main__.py", line 57, in main
weights=args.weights)
File "C:\Users\xxx\anaconda3\envs\caffe\lib\site-packages\autocolorize\extraction.py", line 66, in load_default_classifier
classifier = load_classifier(f.name, weights=weights_fn)
File "C:\Users\xxx\anaconda3\envs\caffe\lib\site-packages\autocolorize\extraction.py", line 44, in load_classifier
classifier = caffe.Classifier(bare_fn, fn)
File "C:\Users\xxx\anaconda3\envs\caffe\lib\site-packages\caffe\classifier.py", line 26, in __init__
caffe.Net.__init__(self, model_file, caffe.TEST, weights=pretrained_file)
RuntimeError: Could not open file C:\Users\xxx\AppData\Local\Temp\tmp1ndjgn6lprototxt
(caffe)
Loading C:\Users\xxx/.autocolorize\autocolorize.caffemodel.h5
Traceback (most recent call last):
File "colorize.py", line 3, in <module>
classifier = autocolorize.load_default_classifier()
File "C:\Users\xxx\anaconda3\lib\site-packages\autocolorize\extraction.py",
line 66, in load_default_classifier
classifier = load_classifier(f.name, weights=weights_fn)
File "C:\Users\xxx\anaconda3\lib\site-packages\autocolorize\extraction.py",
line 44, in load_classifier
classifier = caffe.Classifier(bare_fn, fn)
AttributeError: module 'caffe' has no attribute 'Classifier'
Could you help in here?
I've installed caffe-cpu
and get:
F1229 12:32:06.315968 6270 split_layer.cpp:53] Cannot use GPU in CPU-only Caffe: check mode.
While writing this and trying to fix it, I found issue #1 - maybe it should be added in the README?
I have ubuntu 16.04.
Seems the dependencies are quite hard to install.
(protobuf, ... cv 3.0.0) either wrong headers/too new compiler... etc.
any better tutorial on that?
How to install all from the source and in which order?
Hi,
I have view the structure of autocolorize.prototxt and train_vgg16.prototxt in netscope,I think the train_vgg16.prototxt is for training and the autocolorize.prototxt is for inference,but I found that except the layers in VGG, there are many layers in autocolorize.prototxt but not in train_vgg16.prototxt ,for example, _reshaped,_full_reshaped,*_full,prediction_h,prediction_c, many of these layers have params to learn when there type is conv or deconv,but there are no these layers in the training protxt,so How can you get these params when you inference? Could you please help ,me,Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.