c3b334e73b33a046d912de419d8d9110dbce52e5,pliers/extractors/models.py,TensorFlowInceptionV3Extractor,_extract,#TensorFlowInceptionV3Extractor#Any#,65

Before Change


        tf_dir = os.path.dirname(tf.__file__)
        script = os.path.join(tf_dir, "classify_image.py")

        if stim.filename is None:
            img_file = tempfile.mktemp() + ".jpg"
            imsave(img_file, stim.data)
            use_tmp = True
        else:
            img_file = stim.filename
            use_tmp = False

        args = " --image_file %s --model_dir %s --num_top_prediction %d" % \
            (img_file, self.model_dir, self.num_predictions)
        cmd = ("python " + script + args).split()
        process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
        output, errors = process.communicate()
        hits = output.decode("utf-8").splitlines()[-self.num_predictions:]

        values, features = [], []
        for i, h in enumerate(hits):
            m = re.search("(.*?)\s\(score\s\=\s([0-9\.]+)\)", h.strip())
            values.extend(m.groups())
            ind = i + 1
            features.extend(["label_%d" % ind, "score_%d" % ind])

        if use_tmp:
            os.remove(img_file)

        return ExtractorResult([values], stim, self, features=features)

After Change


        tf_dir = os.path.dirname(tf.__file__)
        script = os.path.join(tf_dir, "classify_image.py")

        with stim.get_filename() as filename:
            args = " --image_file %s --model_dir %s --num_top_prediction %d" % \
                (filename, self.model_dir, self.num_predictions)
            cmd = ("python " + script + args).split()
            process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
            output, errors = process.communicate()
            hits = output.decode("utf-8").splitlines()[-self.num_predictions:]

        values, features = [], []
        for i, h in enumerate(hits):
            m = re.search("(.*?)\s\(score\s\=\s([0-9\.]+)\)", h.strip())
            values.extend(m.groups())
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 15

Instances


Project Name: tyarkoni/pliers
Commit Name: c3b334e73b33a046d912de419d8d9110dbce52e5
Time: 2017-03-23
Author: quinten.mcnamara@gmail.com
File Name: pliers/extractors/models.py
Class Name: TensorFlowInceptionV3Extractor
Method Name: _extract


Project Name: tyarkoni/pliers
Commit Name: c3b334e73b33a046d912de419d8d9110dbce52e5
Time: 2017-03-23
Author: quinten.mcnamara@gmail.com
File Name: pliers/extractors/models.py
Class Name: TensorFlowInceptionV3Extractor
Method Name: _extract


Project Name: tyarkoni/pliers
Commit Name: c3b334e73b33a046d912de419d8d9110dbce52e5
Time: 2017-03-23
Author: quinten.mcnamara@gmail.com
File Name: pliers/extractors/api.py
Class Name: ClarifaiAPIExtractor
Method Name: _extract


Project Name: tyarkoni/pliers
Commit Name: c3b334e73b33a046d912de419d8d9110dbce52e5
Time: 2017-03-23
Author: quinten.mcnamara@gmail.com
File Name: pliers/google.py
Class Name: GoogleVisionAPITransformer
Method Name: _build_request