Beispiel #1
0
        static void Main(string[] args)
        {
            List <ILayer <NeuralUnit> > layers = new List <ILayer <NeuralUnit> >
            {
                new Input(2),
                new Dense(2, Activation.Sigmoid),
                new Dense(2, Activation.Sigmoid),
                new Dense(1, Activation.Sigmoid)
            };

            CognitiveModel model = new CognitiveModel(layers);

            model.Compile();

            model.Fit((null, null), Cardiff.Fit.Algorithms.BackProp, 100);
        }
Beispiel #2
0
        public async Task <ActionResult> Upload(string userid, CognitiveModel request)
        {
            CloudStorageAccount storageConnection = CloudStorageAccount.Parse(ConnectionString);

            CloudBlobClient blobClient = storageConnection.CreateCloudBlobClient();

            CloudBlobContainer container = blobClient.GetContainerReference("faceimages");

            if (await container.CreateIfNotExistsAsync())
            {
                await container.SetPermissionsAsync(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
            }

            var fileName = Guid.NewGuid().ToString() + ".jpg";

            CloudBlockBlob cloudBlockBlob = container.GetBlockBlobReference(string.Format("{0}/{1}", userid, fileName));

            cloudBlockBlob.Properties.ContentType = "image/jpg";

            await cloudBlockBlob.UploadFromByteArrayAsync(request.ImgData, 0, request.ImgData.Length);

            var response = new UploadResponse()
            {
                FileURL = cloudBlockBlob.Uri.AbsoluteUri,
                UserId  = userid.ToString()
            };

            IFaceClient client = Authenticate(ENDPOINT, SUBSCRIPTION_KEY);
            var         face   = await DetectFaceExtract(client, cloudBlockBlob.Uri.AbsoluteUri, RecognitionModel.Recognition02);

            if (face != null)
            {
                response.FaceId = face.FaceId.ToString();
            }

            var json = JsonConvert.SerializeObject(face);

            response.Response = json;
            return(Ok(response));
        }