private void ExecuteClarifai(byte[] imageBytes) { var generalModel = client.DefaultModels.GeneralModel(); var response = generalModel .Predict() .WithInputs(ClarifaiInput.ForImage(ClarifaiImage.Of(imageBytes))) .ExecuteSync(); if (!response.IsSuccessful) { return; } var predictions = (Java.Util.ArrayList)response.Get(); if (predictions.IsEmpty) { return; } var clarifaiOutput = (ClarifaiOutput)predictions.Get(0); var data = clarifaiOutput.Data(); RunOnUiThread(() => { conceptsAdapter.SetData(data.Cast <Concept>()); }); }
void RecognizeImage(UIImage image) { var app = new ClarifaiApp("e995372b2d2b4225a82c52741a60a540"); app.GetModelByName("general-v1.3", (model, error) => { var clafifaiImage = new ClarifaiImage(image); if (error != null) { ShowText(error.DebugDescription); return; } model.PredictOnImages(new[] { clafifaiImage }, (outputs, errors) => { if (errors != null) { ShowText(error.DebugDescription); return; } var tags = outputs[0].Concepts.Select(x => x.ConceptName); ShowText($"Tags: {string.Join(", ", tags)}"); }); }); }