Skip to content

Commit

Permalink
Add dockerfile, update readme (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultserti authored Feb 9, 2021
1 parent beac867 commit df08530
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ celerybeat-schedule
# virtualenv
venv/
ENV/
.venv

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# Pictures
*.jpg
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.6

COPY . /app

WORKDIR /app

RUN pip install -r requirements.txt && ./download_styling_models.sh

WORKDIR /data

ENTRYPOINT ["python", "/app/neural_style/neural_style.py"]
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ The model uses the method described in [Perceptual Losses for Real-Time Style Tr
## Requirements
The program is written in Python, and uses [pytorch](http://pytorch.org/), [scipy](https://www.scipy.org). A GPU is not necessary, but can provide a significant speed up especially for training a new model. Regular sized images can be styled on a laptop, desktop using saved models.

## Setup the environnment

### Run with virtualenv

Create a virtualenv with python3.5 or python3.6. Older versions are not supported due to a lack of compatibilty with pytorch.

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

### Run with Docker

Build the image:
```bash
docker build . -t fast-neural-style
```

Run the container:
```bash
docker run --rm --volume "$(pwd)/:/data" style eval --content-image /data/image.jpg --model /app/saved-models/mosaic.pth --output-image /data/output.jpg --cuda 0
```

## Usage
Stylize image
```
Expand Down Expand Up @@ -47,7 +71,7 @@ Refer to ``neural_style/neural_style.py`` for other command line arguments.
Models for the examples shown below can be downloaded from [here](https://www.dropbox.com/s/gtwnyp9n49lqs7t/saved-models.zip?dl=0) or by running the script ``download_styling_models.sh``.

<div align='center'>
<img src='images/content-images/amber.jpg' height="174px">
<img src='images/content-images/amber.jpg' height="174px">
</div>

<div align='center'>
Expand Down
5 changes: 3 additions & 2 deletions download_styling_models.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
wget https://www.dropbox.com/s/gtwnyp9n49lqs7t/saved-models.zip?dl=1
unzip saved-models.zip?dl=1
#!/bin/bash
wget https://www.dropbox.com/s/gtwnyp9n49lqs7t/saved-models.zip?dl=1 -O saved-models.zip
unzip saved-models.zip
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
torch==0.4.0
torchvision==0.2.2
numpy==1.14.3

0 comments on commit df08530

Please sign in to comment.