diff --git a/python/smqtk/algorithms/descriptor_generator/caffe_descriptor.py b/python/smqtk/algorithms/descriptor_generator/caffe_descriptor.py index 48d68e4dc..2ab64c39d 100644 --- a/python/smqtk/algorithms/descriptor_generator/caffe_descriptor.py +++ b/python/smqtk/algorithms/descriptor_generator/caffe_descriptor.py @@ -181,11 +181,9 @@ def _setup_network(self): # - ``caffe.TEST`` indicates phase of either TRAIN or TEST self._log.debug("Initializing network") self._log.debug("Loading Caffe network from network/model configs") - self.network = caffe.Net(self.network_prototxt.write_temp(), + self.network = caffe.Net(self.network_prototxt, caffe.TEST, - weights=self.network_model.write_temp()) - self.network_prototxt.clean_temp() - self.network_model.clean_temp() + weights=self.network_model) # Assuming the network has a 'data' layer and notion of data shape self.net_data_shape = self.network.blobs[self.data_layer].data.shape self._log.debug("Network data shape: %s", self.net_data_shape) @@ -201,7 +199,7 @@ def _setup_network(self): if self.image_mean is not None: self._log.debug("Loading image mean (reducing to single pixel " "mean)") - image_mean_bytes = self.image_mean.get_bytes() + image_mean_bytes = open(self.image_mean, "rb").read() try: a = numpy.load(io.BytesIO(image_mean_bytes)) self._log.info("Loaded image mean from numpy bytes") diff --git a/python/smqtk/web/search_app/modules/file_upload/FileUploadMod.py b/python/smqtk/web/search_app/modules/file_upload/FileUploadMod.py index a0fb7ee65..accf69fe4 100644 --- a/python/smqtk/web/search_app/modules/file_upload/FileUploadMod.py +++ b/python/smqtk/web/search_app/modules/file_upload/FileUploadMod.py @@ -4,7 +4,7 @@ import os import tempfile -from six.moves import cStringIO as StringIO +from six import BytesIO from smqtk.utils import SmqtkObject from smqtk.utils.file import safe_create_dir @@ -45,7 +45,7 @@ def __init__(self, name, parent_app, working_directory, url_prefix=None): # Top level key is the file ID of the upload. The dictionary # underneath that is the index ID'd chunks. When all chunks are # present, the file is written and the entry in this map is removed. - #: :type: dict of (str, dict of (int, StringIO)) + #: :type: dict of (str, dict of (int, BytesIO)) self._file_chunks = {} # Lock per file ID so as to not collide when uploading multiple chunks #: :type: dict of (str, RLock) @@ -82,7 +82,7 @@ def upload_file(): # - Need to explicitly copy the buffered data as the file object # closes between chunk messages. self._file_chunks.setdefault(fid, {})[current_chunk] \ - = StringIO(chunk_data.read()) + = BytesIO(chunk_data.read()) message = "Uploaded chunk #%d of %d for file '%s'" \ % (current_chunk, total_chunks, filename) @@ -178,7 +178,7 @@ def _write_file_chunks(self, chunk_map, file_extension=''): Returned file path should be manually removed by the user. :param chunk_map: Mapping of integer index to file-like chunk - :type chunk_map: dict of (int, StringIO) + :type chunk_map: dict of (int, BytesIO) :param file_extension: String extension to suffix the temporary file with :type file_extension: str