Skip to content

Commit

Permalink
[NEW] Combine images of any dimensions (as long as the images' dimens…
Browse files Browse the repository at this point in the history
…ions match together)
  • Loading branch information
boromir674 committed Nov 18, 2021
2 parents 515b923 + 6c7bff0 commit 854d83c
Show file tree
Hide file tree
Showing 39 changed files with 1,032 additions and 608 deletions.
20 changes: 10 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ jobs:
visualize_dependency_graphs:
executor: py38-docker-image
environment:
NEURAL_STYLE_TRANSFER_DEPS_GRAPHS: dependencies-graphs
NST_DEPS_GRAPHS: dependency-graphs
steps:
- checkout
- run: sudo apt-get update -y
- run: sudo apt-get update -y --allow-releaseinfo-change
- run: python -m pip install -U pip
- run:
name: Install the dot binary included in the graphviz package/distribution
Expand All @@ -135,7 +135,7 @@ jobs:
name: Visualize dependency graphs as .svg files
command: tox -e graphs -vv
- store_artifacts:
path: dependencies-graphs
path: dependency-graphs
destination: dep-graphs
- run:
name: Visualize uml diagrams as .svg files
Expand Down Expand Up @@ -164,13 +164,13 @@ workflows:
filters:
tags:
only: /.*/
# - visualize_dependency_graphs:
# filters:
# branches:
# only:
# - master
# - dev
# - release-staging
- visualize_dependency_graphs:
filters:
branches:
only:
- master
- dev
- release-staging
# - build-documentation:
# filters:
# branches:
Expand Down
72 changes: 68 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Neural Style Transfer - CLI
===========================

Create artificial artwork by transfering the appearance of one image (eg a famous painting) to another
user-supplied image (eg your favourite photograph).

Uses a Neural Style Transfer algorithm to transfer the appearance, which you can run though a CLI program.

`Neural Style Tranfer` (NST) is an algorithm that applies the `style` of an image to the `contents` of another and produces a `generated` image.
The idea is to find out how someone, with the `painting style` shown in one image, would depict the `contents` shown in another image.

Expand All @@ -17,6 +22,11 @@ This Python package runs a Neural Style Tranfer algorithm on input `content` and
* - tests
- | |circleci| |codecov|

* - package
- | |pypi| |wheel| |py_versions| |commits_since|

* - containerization
- | |docker| |image_size|

* - code quality
- |better_code_hub| |code_climate| |maintainability| |codacy| |scrutinizer|
Expand All @@ -40,9 +50,9 @@ Key features of the package:

Installation
------------
| The Neural Style Transfer - CLI heavely depends on Tensorflow (tf) and therefor it is crucial that tf is installed correctly in your Python environment.
| The Neural Style Transfer - CLI heavely depends on Tensorflow (tf) and therefore it is crucial that tf is installed correctly in your Python environment.
Sample commands to install NST CLI using a terminal:
Sample commands to install the NST CLI from source, using a terminal:

::

Expand All @@ -60,6 +70,18 @@ Sample commands to install NST CLI using a terminal:
# Install NST CLI (in virtual environment)
pip install -e .


Alternative command to install the NST CLI by downloading the `artificial_artwork` python package from pypi:

::

pip install artificial_artwork


Make the cli available for your host system:

::

# Setup a symbolic link (in your host system) in a location in your PATH
# Assuming ~/.local/bin is in your PATH
ln -s $PWD/env/bin/neural-style-transfer ~/.local/bin/neural-style-transfer
Expand All @@ -71,7 +93,7 @@ Sample commands to install NST CLI using a terminal:
Usage
-----

Download the Vgg-Verydeep-19 pretrained `model` from https://mega.nz/file/i5xDWI4Y.
Download the Vgg-Verydeep-19 pretrained `model` from https://drive.protonmail.com/urls/7RXGN23ZRR#hsw4STil0Hgc.

Exctract the model (weights and layer architecture).

Expand Down Expand Up @@ -115,6 +137,21 @@ image generated on a different iteration while running the algorithm. The bigger
Check out your artificial artwork!


Docker image
------------

We have included a docker file that we use to build an image where both the `artificial_artwork` package (source code)
and the pretrained model are present. That way you can immediately start creating artwork!

::

docker pull boromir674/neural-style-transfer

mkdir nst-output

docker run -it --rm -v nst-output:/app/nst-output boromir674/neural-style-transfer




.. |circleci| image:: https://img.shields.io/circleci/build/github/boromir674/neural-style-transfer/master?logo=circleci
Expand All @@ -124,9 +161,28 @@ Check out your artificial artwork!

.. |codecov| image:: https://codecov.io/gh/boromir674/neural-style-transfer/branch/master/graph/badge.svg?token=3POTVNU0L4
:alt: Codecov
:target: https://codecov.io/gh/boromir674/neural-style-transfer
:target: https://codecov.io/gh/boromir674/neural-style-transfer



.. |pypi| image:: https://img.shields.io/pypi/v/artificial-artwork?color=blue&label=pypi&logo=pypi&logoColor=%23849ed9
:alt: PyPI
:target: https://pypi.org/project/artificial-artwork/

.. |wheel| image:: https://img.shields.io/pypi/wheel/artificial-artwork?logo=python&logoColor=%23849ed9
:alt: PyPI - Wheel
:target: https://pypi.org/project/artificial-artwork

.. |py_versions| image:: https://img.shields.io/pypi/pyversions/artificial-artwork?color=blue&logo=python&logoColor=%23849ed9
:alt: PyPI - Python Version
:target: https://pypi.org/project/artificial-artwork

.. |commits_since| image:: https://img.shields.io/github/commits-since/boromir674/neural-style-transfer/v0.5/master?color=blue&logo=Github
:alt: GitHub commits since tagged version (branch)
:target: https://github.com/boromir674/neural-style-transfer/compare/v0.5..master



.. |better_code_hub| image:: https://bettercodehub.com/edge/badge/boromir674/neural-style-transfer?branch=master
:alt: Better Code Hub
:target: https://bettercodehub.com/
Expand Down Expand Up @@ -161,3 +217,11 @@ Check out your artificial artwork!
:alt: Supported versions
:target: https://pypi.org/project/topic-modeling-toolkit



.. |docker| image:: https://img.shields.io/docker/v/boromir674/neural-style-transfer/latest?logo=docker&logoColor=%23849ED9
:alt: Docker Image Version (tag latest semver)
:target: https://hub.docker.com/r/boromir674/neural-style-transfer

.. |image_size| image:: https://img.shields.io/docker/image-size/boromir674/neural-style-transfer/latest?logo=docker&logoColor=%23849ED9
:alt: Docker Image Size (tag)
6 changes: 2 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[metadata]
## Setuptools specific information
name = artificial_artwork
version = 0.5
description = Create artificial artwork by transfering the appearance of
one image (eg a famous painting) to another user-supplied image (eg your favourite photograph).
Uses a Neural Style Transfer algorithm to transfer the appearance which you can run though a CLI program.
version = 0.6
description = Create artificial artwork by transfering the appearance of one image (eg a famous painting) to another user-supplied image (eg your favourite photograph).
long_description = file: README.rst
long_description_content_type = text/x-rst
license = AGPLv3
Expand Down
37 changes: 2 additions & 35 deletions src/artificial_artwork/algorithm.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
from abc import ABC
import attr


class AlgorithmInterface(ABC):
"""An algorithm is a series of execution steps, aiming to solve a problem.
This interface provides a 'run' method that sequentially runs the
algorithm's steps.
"""
def run(self, *args, **kwargs) -> None:
"""Run the algorithm."""
raise NotImplementedError


class IterativeAlgorithm(AlgorithmInterface):

def run(self, *args, **kwargs) -> None:
pass


class LearningAlgorithm(IterativeAlgorithm):

def run(self, *args, **kwargs) -> None:
pass

def compute_cost(self, *args, **kwargs) -> float:
raise NotImplementedError
from .style_layer_selector import NSTLayersSelection


@attr.s
class NSTAlgorithm(IterativeAlgorithm):
class NSTAlgorithm:
parameters = attr.ib()
image_config = attr.ib()

def run(self, *args, **kwargs) -> None:
return super().run(*args, **kwargs)


from .style_layer_selector import NSTLayersSelection


@attr.s
Expand All @@ -47,7 +15,6 @@ class AlogirthmParameters:
# from the algo input (runtime objects that are the INPUT to the algo)
content_image = attr.ib()
style_image = attr.ib()
cv_model = attr.ib()
style_layers = attr.ib(converter=NSTLayersSelection.from_tuples)
termination_condition = attr.ib()
output_path = attr.ib()
49 changes: 0 additions & 49 deletions src/artificial_artwork/algorithm_progress.py

This file was deleted.

Loading

0 comments on commit 854d83c

Please sign in to comment.