GithubHelp home page GithubHelp logo

colorization-coreml's Introduction

Colorization CoreML

This is a repository for image colorization using CoreML. The model is based on the Colorful Image Colorization paper and the original GitHub repository. The model used in this repository is named siggraph17.

res1 res2

Installation

  1. Create a virtual environment:
virtualenv -p python3.9 .venv && source .venv/bin/activate
  1. Install all requirements:
pip install -r requirements.txt
  1. Use the project ๐ŸŽ‰

Usage

To run use command below:

python run_colorization.py --data-root images

If an image is not in black and white, it will be converted to black and white before colorization. It's worth noting that the model inference will only work on MacOS due to restrictions of the coremltools framework.

Models

The first model, colorizer_core.mlmodel, expects a PIL.Image named image_small with a size of (3, 256, 256). It returns an array containing colorized_small_image, an A and B values from the LAB color space (2, 256, 256).

Afterward, you need to resize colorized_small_image to the original image size, convert this array to PIL.Image. Let's name the result ab.

The second model, colorizer_tail.mlmodel, requires the original PIL.Image, image, of any size, as well as the ab (i.e., the resized colorized_small_image from the previous model). This model returns an array containing the colorized image, colorized_image, of the original size.

Built With

  • coremltools - The NNs inference framework used
  • OpenCV - Images processing framework used
  • Pillow - Images processing framework used
  • Typer - CLI framework used

License

This project is licensed under the MIT License - see the LICENSE file for details

Authors

colorization-coreml's People

Contributors

vadbeg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

colorization-coreml's Issues

converting script

Hello, Thanks for your converting, and you're great, I want to know how you to convert it to coreml so can you share your script? Thanks again.

ModuleNotFoundError: No module named 'coremltools.libmilstoragepython'

Hello. I tried to use your script, but it fails to load coremltools.libmilstoragepython.

โžœ colorization-coreml git:(master) python3 run_colorization.py --data-root ./images
Traceback (most recent call last):
File "/Users/myusername/Repo/colorization-coreml/run_colorization.py", line 5, in
import coremltools as ct
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/init.py", line 90, in
from . import converters
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/converters/init.py", line 7, in
from . import libsvm
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/converters/libsvm/init.py", line 7, in
from . import _libsvm_converter
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/converters/libsvm/_libsvm_converter.py", line 9, in
from coremltools.models import _METADATA_VERSION, _METADATA_SOURCE
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/models/init.py", line 37, in
from . import ml_program
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/models/ml_program/init.py", line 6, in
from . import compression_utils
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/models/ml_program/compression_utils.py", line 8, in
from coremltools.converters.mil.frontend.milproto.load import load as _milproto_to_pymil
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/converters/mil/frontend/milproto/init.py", line 6, in
from .load import load
File "/opt/homebrew/lib/python3.11/site-packages/coremltools/converters/mil/frontend/milproto/load.py", line 27, in
from coremltools.libmilstoragepython import _BlobStorageReader as BlobReader
ModuleNotFoundError: No module named 'coremltools.libmilstoragepython'
โžœ colorization-coreml git:(master) pip3 list
Package Version


click 8.1.3
contourpy 1.0.5
coremltools 6.0
cycler 0.11.0
fonttools 4.37.3
kiwisolver 1.4.4
matplotlib 3.6.0
mpmath 1.2.1
numpy 1.23.3
opencv-python 4.5.5.64
packaging 21.3
Pillow 9.2.0
pip 23.0.1
protobuf 3.20.1
pyparsing 3.0.9
python-dateutil 2.8.2
setuptools 65.6.3
six 1.16.0
sympy 1.11.1
TBB 0.2
tqdm 4.64.1
typer 0.6.1
wheel 0.38.4
โžœ colorization-coreml git:(master)

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.