classify method
Implementation
@override
Future<List<Predictions>> classify(File image) async {
const url =
'https://dentalprediction-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/1b465330-89d1-4acf-90c3-a64f76114ad3/detect/iterations/Iteration3/image';
final headers = {
'Prediction-Key': '6c41e9fb16f64bf39c334fb6ae1761bc',
'Content-Type': 'application/octet-stream',
};
var bytes = await image.readAsBytes();
var response = await http.post(
Uri.parse(url),
headers: headers,
body: bytes,
);
if (response.statusCode == 200) {
var data = jsonDecode(response.body);
List<dynamic> predictionsJson = data['predictions'];
List<Predictions> predictions = predictionsJson
.map((json) => Predictions.fromJson(json))
.toList();
return predictions;
} else {
throw Exception('Failed to classify image');
}
}