-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathML_service.dart
34 lines (29 loc) · 900 Bytes
/
ML_service.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'dart:convert';
import 'dart:typed_data';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
class MLService {
Dio dio = Dio();
// ml server
// https://github.com/PuzzleLeaf/tensorflow_flask_api_server
Future<Uint8List> analyzeSentiment (String inputstring) async {
try {
var encodedData = await compute(base64Encode, inputstring);
// compute(함수, 변수)
// Response response = await dio.post('https://puzzleleaf-ml-server.herokuapp.com/v1/image/convert_cartoon',
// data: {
// 'image': encodedData
// }
// );
Response response = await dio.post('http://localhost:5000/v1/image/convert_cartoon',
data: {
'image': encodedData
}
);
String result = response.data;
return compute(base64Decode, result);
} catch (e) {
return null;
}
}
}