예제 #1
0
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
예제 #2
0
파일: watcher.py 프로젝트: jrkerns/pylinac
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
예제 #3
0
 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)
예제 #4
0
 def test_demo_is_reachable(self):
     if has_www_connection():
         file = retrieve_demo_file(url='flatsym_demo.dcm')
         self.assertTrue(osp.isfile(file))
예제 #5
0
 def get_filename(cls):
     return retrieve_demo_file(url='flatsym_demo.dcm')
예제 #6
0
 def test_demo_is_reachable(self):
     if has_www_connection():
         file = retrieve_demo_file(url=self.demo_name)
         self.assertTrue(osp.isfile(file))
예제 #7
0
 def from_demo_image(cls):
     """Instantiate and load the demo image."""
     demo_file = retrieve_demo_file(url=cls._demo_filename)
     return cls(demo_file)