-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM nvidia/cuda:10.0-cudnn7-devel | ||
|
||
LABEL organization="One-Off Coder" | ||
LABEL email="[email protected]" | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV CONDA_HOME="/opt/anaconda" | ||
ENV PATH="${CONDA_HOME}/bin:${PATH}" | ||
|
||
# setup environment | ||
RUN apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install wget -y | ||
|
||
# setup conda | ||
RUN wget -q https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh -O /tmp/anaconda.sh \ | ||
&& /bin/bash /tmp/anaconda.sh -b -p $CONDA_HOME \ | ||
&& conda install --yes -c pytorch pytorch torchvision cudatoolkit=10.0 \ | ||
&& python -c "from torchvision import models; models.vgg19(pretrained=True)" | ||
|
||
# setup app | ||
COPY . /app | ||
VOLUME [ "/app/images" ] | ||
WORKDIR /app | ||
ENTRYPOINT [ "python", "app.py" ] | ||
CMD [ "--help" ] | ||
|
||
# clean up | ||
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
 | ||
|
||
# Purpose | ||
|
||
This project is an executable container for Neural Style Transfer. At a high level, you supply content and style images as inputs, and the application will mix the style and content to produce a new image that is as faithful as possible to the style in the style image and the content in the content image. | ||
|
||
Content Image | ||
|
||
 | ||
|
||
Style Image | ||
|
||
 | ||
|
||
Output Image | ||
|
||
 | ||
|
||
# Docker Hub | ||
|
||
[Image](https://hub.docker.com/r/oneoffcoder/dl-transfer) | ||
|
||
# Usage | ||
|
||
To use the container, type in the following. Note that the `-s` flag specifies the style image and `-c` specifies the content image. By default, an `image/output.jpg` file be created. To control the output image, specify `-o` (e.g. `-o image/final.jpg`). | ||
|
||
```bash | ||
docker run -it \ | ||
-v `pwd`/image:/app/image \ | ||
--gpus=all \ | ||
--shm-size=5g \ | ||
oneoffcoder/dl-transfer -s image/picasso-01.jpg -c image/dancing.jpg | ||
|
||
docker run -it \ | ||
-v `pwd`/image:/app/image \ | ||
--gpus=all \ | ||
--shm-size=5g \ | ||
dl-transfer:local -s image/picasso-01.jpg -c image/dancing.jpg | ||
|
||
docker run -it \ | ||
-v `pwd`/image:/app/image \ | ||
--gpus=all \ | ||
--shm-size=5g \ | ||
dl-transfer:local -s image/picasso.jpg -c image/dancing.jpg -o image/final.jpg | ||
``` | ||
|
||
# Citation | ||
|
||
``` | ||
@misc{oneoffcoder_dl_transfer_2019, | ||
title={An executable docker container with Neural Style Transfer}, | ||
url={https://github.com/oneoffcoder/docker-containers/tree/master/dl-transfer}, | ||
journal={GitHub}, | ||
author={One-Off Coder}, | ||
year={2020}, | ||
month={Jan}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
REPOSITORY=dl-transfer | ||
TAG=local | ||
|
||
docker build --no-cache -t $REPOSITORY:$TAG . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
ORGANIZATION=oneoffcoder | ||
REPOSITORY=dl-transfer | ||
VERSION=0.0.1 | ||
IMAGEID=${REPOSITORY}:local | ||
|
||
echo ${IMAGEID} | ||
|
||
docker tag ${IMAGEID} ${ORGANIZATION}/${REPOSITORY}:${VERSION} | ||
docker tag ${IMAGEID} ${ORGANIZATION}/${REPOSITORY}:latest | ||
|
||
docker push ${ORGANIZATION}/${REPOSITORY}:${VERSION} | ||
docker push ${ORGANIZATION}/${REPOSITORY}:latest |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
updateAptPackages() { | ||
echo "installing packages via APT" | ||
apt-get update -y | ||
apt-get upgrade -y | ||
apt-get install wget -y | ||
} | ||
|
||
installAnaconda() { | ||
echo "installing anaconda" | ||
wget -q https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh -O /tmp/anaconda.sh | ||
/bin/bash /tmp/anaconda.sh -b -p $CONDA_HOME | ||
rm -fr /tmp/anaconda.sh | ||
} | ||
|
||
installPytorch() { | ||
echo "installing pytorch" | ||
conda install --yes \ | ||
-c pytorch pytorch torchvision cudatoolkit=10.0 | ||
} | ||
|
||
downloadModels() { | ||
echo "downloading models" | ||
declare -a models=("vgg19") | ||
|
||
for model in ${models[@]}; do | ||
package="from torchvision import models; models.${model}(pretrained=True)" | ||
echo $package | ||
python -c "$package" | ||
done | ||
} | ||
|
||
updateAptPackages | ||
installAnaconda | ||
installPytorch | ||
downloadModels |