Improve performance (#15)

* Add deeper nima profiling

* Switch to bmp format

* Switch NIMA to GPU

* Update tensorflow-gpu version

* Remove NIMA profiling

* Remove unused imports
This commit is contained in:
Adam Svystun 2018-11-10 13:50:19 +01:00 committed by Maciej Pęśko
parent 244a7deb53
commit 75810f7c84
4 changed files with 7 additions and 6 deletions

View file

@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y apt-utils software-properties-common &&
libavformat-dev libswscale-dev unzip && \
python3.6 -m pip install --upgrade pip && \
python3.6 -m pip install jupyter ipywidgets jupyterlab && \
python3.6 -m pip install tensorflow-gpu h5py keras && \
python3.6 -m pip install h5py keras && \
python3.6 -m pip install scikit-image opencv-contrib-python pyyaml
RUN mkdir /comixify

View file

@ -61,7 +61,7 @@ class KeyFramesExtractor:
jj(f"{settings.TMP_DIR}", f"{all_frames_tmp_dir}", "%06d.jpeg")])
else:
call(["ffmpeg", "-i", video.file.path, "-vf", "select=not(mod(n\\,15))", "-vsync", "vfr", "-q:v", "2",
jj(settings.TMP_DIR, all_frames_tmp_dir, "%06d.jpeg")])
jj(settings.TMP_DIR, all_frames_tmp_dir, "%06d.bmp")])
frames_paths = []
for dirname, dirnames, filenames in os.walk(jj(settings.TMP_DIR, all_frames_tmp_dir)):
for filename in filenames:

View file

@ -2,11 +2,12 @@ import os
import errno
import numpy as np
from keras.models import load_model
from keras.preprocessing.image import load_img, img_to_array
from keras.preprocessing.image import img_to_array
from keras.applications.nasnet import preprocess_input
import tensorflow as tf
from PIL import Image
MODEL_PATH = 'neural_image_assessment/pretrained_model/nima_model.h5'
@ -16,12 +17,11 @@ class NeuralImageAssessment:
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), MODEL_PATH)
self.graph = tf.Graph()
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.001
config.gpu_options.per_process_gpu_memory_fraction = 0.1
config.gpu_options.allow_growth = True
self.session = tf.Session(graph=self.graph, config=config)
with self.graph.as_default():
with tf.device('/CPU:0'):
self.model = load_model(MODEL_PATH)
self.model = load_model(MODEL_PATH)
@staticmethod
def resize_image(bgr_img_array, target_size=(224, 224), interpolation='nearest'):

View file

@ -13,3 +13,4 @@ torch==0.4.1
torchvision==0.2.1
scikit-learn==0.19.2
youtube-dl==2018.9.18
tensorflow-gpu==1.10.1