Skip to content

PR for project 5 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
imagenet-vgg-verydeep-19.mat
31 changes: 31 additions & 0 deletions Evaluator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import numpy as np
import scipy.optimize as sio


class Evaluator:

def __init__(self, lg_evaluator):

self._gradient = None
self._lg_eval = lg_evaluator

# inputs = [input_img]
def optimize(self, input_img, img_rows, img_cols):

def loss(inputs):

inputs = np.reshape(inputs, newshape=(1, img_rows, img_cols, 3))
l, g = self._lg_eval([inputs])

self._gradient = g.astype(np.float64)
return l.astype(np.float64)

def gradient(inputs):
return self._gradient.flatten()

op = sio.fmin_l_bfgs_b(func=loss, fprime=gradient, x0=input_img, maxiter=500, iprint=10)
print(op)

op_x = np.reshape(op[0], (1, img_rows, img_cols, 3))

return op_x[0]
9 changes: 9 additions & 0 deletions jobscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#PBS -l nodes=n21:ppn=2
#PBS -N Unet
#PBS -m e
#PBS -l walltime=48:00:00
cd $PBS_O_WORKDIR
cd ~/CompVision/project_5_neural_style_transfer/
module load python cuda
python3 neural_style_transfer.py > output.txt
89 changes: 89 additions & 0 deletions libs/GPUtil/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
Loading