def get_image_classifier(): """Load the CBCT HU slice classifier model. If the classifier is not locally available it will be downloaded.""" classifier_file = osp.join(osp.dirname(__file__), 'demo_files', 'singleimage_classifier.pkl.gz') # get the classifier if it's not downloaded if not osp.isfile(classifier_file): logger.info("Downloading classifier from the internet...") classifier_file = retrieve_demo_file('singleimage_classifier.pkl.gz') logger.info("Done downloading") with gzip.open(classifier_file, mode='rb') as m: clf = pickle.load(m) return clf
def get_image_classifier(img_type): """Load the CBCT HU slice classifier model. If the classifier is not locally available it will be downloaded.""" if img_type == 'single': classifier = 'singleimage_classifier.pkl.gz' elif img_type == 'vmat': classifier = 'vmat_classifier.pkl.gz' classifier_file = osp.join(osp.dirname(__file__), 'demo_files', classifier) # get the classifier if it's not downloaded if not osp.isfile(classifier_file): logger.info("Downloading classifier from the internet...") classifier_file = retrieve_demo_file(classifier) logger.info("Done downloading") with gzip.open(classifier_file, mode='rb') as m: clf = pickle.load(m) return clf
def from_demo_image(cls): """Load the demo image into an instance""" demo_file = retrieve_demo_file(url='flatsym_demo.dcm') return cls(demo_file)
def test_demo_is_reachable(self): if has_www_connection(): file = retrieve_demo_file(url='flatsym_demo.dcm') self.assertTrue(osp.isfile(file))
def get_filename(cls): return retrieve_demo_file(url='flatsym_demo.dcm')
def test_demo_is_reachable(self): if has_www_connection(): file = retrieve_demo_file(url=self.demo_name) self.assertTrue(osp.isfile(file))
def from_demo_image(cls): """Instantiate and load the demo image.""" demo_file = retrieve_demo_file(url=cls._demo_filename) return cls(demo_file)