Skip to content
Permalink
Browse files

fix(image encoder): define use_cuda variable via args

  • Loading branch information...
numb3r3 committed Jul 17, 2019
1 parent cba5e19 commit a7236308a834c2eb32686f00024ee31a405fedc1
Showing with 7 additions and 6 deletions.
  1. +4 −3 gnes/encoder/image/base.py
  2. +3 −3 gnes/encoder/image/inception.py
@@ -27,15 +27,16 @@ class BasePytorchEncoder(BaseImageEncoder):
def __init__(self, model_name: str,
layers: List[str],
model_dir: str,
batch_size: int = 64, *args, **kwargs):
batch_size: int = 64,
use_cuda: bool = False,
*args, **kwargs):
super().__init__(*args, **kwargs)

self.batch_size = batch_size
self.model_dir = model_dir
self.model_name = model_name
self.layers = layers
self.is_trained = True
self._use_cuda = False
self._use_cuda = use_cuda

def post_init(self):
import torch
@@ -26,14 +26,14 @@ class TFInceptionEncoder(BaseImageEncoder):
def __init__(self, model_dir: str,
batch_size: int = 64,
select_layer: str = 'PreLogitsFlatten',
use_gpu: bool = True,
use_cuda: bool = False,
*args, **kwargs):
super().__init__(*args, **kwargs)

self.model_dir = model_dir
self.batch_size = batch_size
self.select_layer = select_layer
self.use_gpu = use_gpu
self._use_cuda = use_cuda
self.inception_size_x = 299
self.inception_size_y = 299

@@ -54,7 +54,7 @@ def post_init(self):
dropout_keep_prob=1.0)

config = tf.ConfigProto(log_device_placement=False)
if self.use_gpu:
if self._use_cuda:
config.gpu_options.allow_growth = True
self.sess = tf.Session(config=config)
self.saver = tf.train.Saver()

0 comments on commit a723630

Please sign in to comment.
You can’t perform that action at this time.