Uses the Vision API to detect faces in the given file.
 [START vision_face_detection_tutorial_send_request]
436808
async function detectFaces(inputFile) {
  // Make a call to the Vision API to detect the faces
  const request = {image: {source: {filename: inputFile}}};
  const results = await client.faceDetection(request);
  const faces = results[0].faceAnnotations;
  const numFaces = faces.length;
  console.log(`Found ${numFaces} face${numFaces === 1 ? '' : 's'}.`);
  return faces;
}
921985
static public IParserInput getInstance(final File file) throws IOException
    {
        final List<String> args = new ArrayList<>();
        try (BufferedReader reader = new BufferedReader(new FileReader(file)))
        {
            String aConfigLine = null;
            while ((aConfigLine = reader.readLine()) != null)
                if (aConfigLine.length() > 0 && aConfigLine.charAt(0) != '#')
                    args.add(aConfigLine);
        }

        final NamespaceParser parser = new NamespaceParser();
        parser.args = args.toArray(new String[args.size()]);
        return parser;
    }
595400
def file_is_image?(file)
      return unless file && file.respond_to?(:url)
      return file.content_type.start_with? "image" if file.content_type.present?
      Mime::Type.lookup_by_extension(File.extname(file.url)[1..-1]).to_s.start_with? "image" if file.url.present?
    end
1334813
public static void easy( GrayF32 image ) {
		// create the detector and descriptors
		DetectDescribePoint<GrayF32,BrightFeature> surf = FactoryDetectDescribe.
				surfStable(new ConfigFastHessian(0, 2, 200, 2, 9, 4, 4), null, null,GrayF32.class);

		 // specify the image to process
		surf.detect(image);

		System.out.println("Found Features: "+surf.getNumberOfFeatures());
		System.out.println("First descriptor's first value: "+surf.getDescription(0).value[0]);
	}
684653
async function main(inputFile, outputFile) {
  const Canvas = require('canvas');
  outputFile = outputFile || 'out.png';
  const faces = await detectFaces(inputFile);
  console.log('Highlighting...');
  await highlightFaces(inputFile, faces, outputFile, Canvas);
  console.log('Finished!');
}
513562
@Override
	public boolean accept(File file) {
		return file != null ? match(file.getName(), pattern) : false;
	}
848076
async function getTextFromFiles(index, inputFiles) {
  // Read all of the given files and provide request objects that will be
  // passed to the Cloud Vision API in a batch request.
  const requests = await Promise.all(
    inputFiles.map(async filename => {
      const content = await readFile(filename);
      console.log(` 👉 ${filename}`);
      return {
        image: {
          content: content.toString('base64'),
        },
        features: [{type: 'TEXT_DETECTION'}],
      };
    })
  );

  // Make a call to the Vision API to detect text
  const results = await client.batchAnnotateImages({requests});
  const detections = results[0].responses;
  await Promise.all(
    inputFiles.map(async (filename, i) => {
      const response = detections[i];
      if (response.error) {
        console.info(`API Error for ${filename}`, response.error);
        return;
      }
      await extractDescriptions(filename, index, response);
    })
  );
}
494632
function predict(face) {
      return getNet().computeFaceDescriptorAsync(face)
        .then(inputDescriptor =>
          getDescriptorsByClass().map(ds => ({
            className: ds.className,
            distance: computeMeanDistance(ds.faceDescriptors, inputDescriptor)
          }))
        )
    }
1202113
def face_and_energy_detector(image_path, detect_faces=True):
    
    source = Image.open(image_path)
    work_width = 800
    if source.mode != 'RGB' or source.bits != 8:
        source24 = source.convert('RGB')
    else:
        source24 = source.copy()

    grayscaleRMY = source24.convert('L', (0.5, 0.419, 0.081, 0))
    w = min(grayscaleRMY.size[0], work_width)
    h = w * grayscaleRMY.size[1] / grayscaleRMY.size[0]
    b = grayscaleRMY.resize((w, h), Image.BICUBIC)
    # b.save('step2.jpg')
    if detect_faces:
        info = do_face_detection(image_path)
        if info:
            return CropInfo(gravity=info)
    b = b.filter(ImageFilter.GaussianBlur(7))
    # b.save('step3.jpg')
    sobelXfilter = ImageFilter.Kernel((3, 3), (1, 0, -1, 2, 0, -2, 1, 0, -1), -.5)
    sobelYfilter = ImageFilter.Kernel((3, 3), (1, 2, 1, 0, 0, 0, -1, -2, -1), -.5)
    b = ImageChops.lighter(b.filter(sobelXfilter), b.filter(sobelYfilter))
    b = b.filter(ImageFilter.FIND_EDGES)
    # b.save('step4.jpg')
    ec = energy_center(b)
    return CropInfo(gravity=ec)
120551
def __send_main_file(self, file_name):
        

        file_name = join(self.app.static_folder, file_name)

        with codecs.open(file_name, 'r', 'utf-8') as file:
            data = file.read()

        data = data.replace(
            'fields.article.url = apiProject.url + fields.article.url;',
            '''if (fields.article.url.substr(0, 4).toLowerCase() !== \'http\')
                        fields.article.url = apiProject.url + fields.article.url;''')

        headers = Headers()
        headers['Content-Length'] = getsize(file_name)

        response = self.app.response_class(data,
                                           mimetype=mimetypes.guess_type(file_name)[0],
                                           headers=headers,
                                           direct_passthrough=True)

        response.last_modified = int(getmtime(file_name))

        return response
1106552
def suggest_features 
      sel_features = Array.new
  
      File.open(@directory + "/train", "w") do |f| f.puts @fv_train.to_libSVM end
  
      Dir.chdir('./rsvm/bin/tools') do
        output = `python fselect.py #{@directory}/train`
  
        puts output if (@verbose)
        
        x = File.read("train.select")
        sel_f_ids = x[1..-2].split(", ")
        sel_f_ids.each do |f|
          s_f = @features.term(f.to_i)
          if s_f.instance_of? String then
            s_f     = s_f.split("||")
            s_f[0]  = s_f[0].to_sym
          end
          sel_features.push(s_f)
        end
        
        #Remove temporary files
        File.delete("train.select") if File.exist?("train.select")
        File.delete("train.fscore") if File.exist?("train.fscore")
        File.delete("train.tr.out") if File.exist?("train.tr.out")
      end
      
      return sel_features
    end
616917
function(file, callback) {
        if (isBrowser && file instanceof window.File) {
            // Browser File instance
            return this.addImageFromBuffer(file, callback);
        }

        // File on filesystem. Note: the reason why we need the size of the file
        // is because of reverse proxies like Varnish which doesn't handle chunked
        // Transfer-Encoding properly - instead we need to explicitly pass the
        // content length so it knows not to terminate the HTTP connection
        readers.getLengthOfFile(file, function(err, fileSize) {
            if (err) {
                return callback(err);
            }

            readers.createReadStream(file).pipe(request({
                method: 'POST',
                uri: this.getSignedResourceUrl('POST', this.getImagesUrl()),
                json: true,
                headers: {
                    'Accept': 'application/json',
                    'User-Agent': 'imboclient-js',
                    'Content-Length': fileSize
                },
                onComplete: function(addErr, res, body) {
                    callback(addErr, body ? body.imageIdentifier : null, body, res);
                }
            }));
        }.bind(this));

        return this;
    }
1306968
@Override
    public T fromFile(final File file) throws IllegalArgumentException, DescriptorImportException {
        // Precondition checks
        if (file == null) {
            throw new IllegalArgumentException("File not specified");
        }

        // Delegate
        try {
            return this.fromStream(new FileInputStream(file));
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("Specified file does not exist or is a directory: "
                + file.getAbsolutePath());
        }
    }
988775
def _parse_file(self, file_obj):
        
        byte_data = file_obj.read(self.size)
        self._parse_byte_data(byte_data)
231299
function detectFaces(img, faceSize = 150) {
      return locateFaces(img)
        .then(rects => getFacesFromLocations(img, rects.map(mmodRect => mmodRect.rect), faceSize))
    }
996001
def load(filters="*.*", text='Select a file, FACEFACE!', default_directory='default_directory'):
    
    # make sure the filters contains "*.*" as an option!
    if not '*' in filters.split(';'): filters = filters + ";;All files (*)"
    
    # if this type of pref doesn't exist, we need to make a new one
    if default_directory in _settings.keys(): default = _settings[default_directory]
    else:                                     default = ""
    
    # pop up the dialog
    result = _qtw.QFileDialog.getOpenFileName(None,text,default,filters)
    
    # If Qt5, take the zeroth element
    if _s._qt.VERSION_INFO[0:5] == "PyQt5": result = result[0]
    
    # Make sure it's a string
    result = str(result)    
    
    if result == '': return None
    else:
        _settings[default_directory] = _os.path.split(result)[0]
        return result
1342610
def from_file(cls, image_descriptor):
        
        if is_string(image_descriptor):
            path = image_descriptor
            with open(path, 'rb') as f:
                blob = f.read()
                stream = BytesIO(blob)
            filename = os.path.basename(path)
        else:
            stream = image_descriptor
            stream.seek(0)
            blob = stream.read()
            filename = None
        return cls._from_stream(stream, blob, filename)