Commit 09ae7fa2 authored by  Rathnayaka R.M.N.A's avatar Rathnayaka R.M.N.A

Merge branch 'master' into 'master'

Disease Identification

See merge request 2022-226/intelligent_system_for_skin_diseases!4
parents 43228676 40b4bfca
...@@ -47,7 +47,7 @@ android { ...@@ -47,7 +47,7 @@ android {
applicationId "com.example.canis_care" applicationId "com.example.canis_care"
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
......
Dandruff
Invalid_images
Ring_Worm
Yeast_Infection
\ No newline at end of file
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:tflite/tflite.dart';
class DiseaseIdentification extends StatefulWidget {
const DiseaseIdentification({Key? key}) : super(key: key);
@override
State<DiseaseIdentification> createState() => _DiseaseIdentificationState();
}
class _DiseaseIdentificationState extends State<DiseaseIdentification> {
late File pickedImage;
bool _busy = false;
late List _recognitions;
bool isImageLoaded = false;
late List resultList;
String _confidence = "";
String _name = "";
String numbers = "";
getImageFromGallery() async {
var image =
await ImagePicker.platform.getImage(source: ImageSource.gallery);
print("11111:");
setState(() {
_busy = true;
});
pickedImage = File(image!.path);
isImageLoaded = true;
predictImage(pickedImage);
}
getImageFromCamera() async {
var image = await ImagePicker.platform.getImage(source: ImageSource.camera);
setState(() {
_busy = true;
});
pickedImage = File(image!.path);
isImageLoaded = true;
predictImage(pickedImage);
}
void predictImage(File image) async {
await applyModelOnImage(image);
}
loadDetectionModel() async {
try {
String? res = await Tflite.loadModel(
model: "assets/newdog1model1.tflite",
labels: "assets/labels.txt",
numThreads: 1,
// defaults to 1
isAsset: true,
// defaults to true, set to false to load resources outside assets
useGpuDelegate:
false // defaults to false, set to true to use GPU delegate
);
print("Model Result : $res");
} on PlatformException {
print('Failed to load model.');
}
}
applyModelOnImage(File image) async {
int startTime = new DateTime.now().millisecondsSinceEpoch;
var recognitions = await Tflite.runModelOnImage(
path: image.path,
// required
imageMean: 0.0,
// defaults to 117.0
imageStd: 255.0,
// defaults to 1.0
numResults: 2,
// defaults to 5
threshold: 0.2,
// defaults to 0.1
asynch: true // defaults to true
);
setState(() {
_recognitions = recognitions!;
print("res result : $_recognitions");
String str = _recognitions[0]["label"];
_name = str.substring(2);
print("Detected Disease: $_name");
_confidence = _recognitions != null
? (_recognitions[0]["confidence"] * 100.0)
.toString()
.substring(0, 2) +
"%"
: "";
print("Confidence: $_confidence");
});
int endTime = new DateTime.now().millisecondsSinceEpoch;
print("Inference took ${endTime - startTime}ms"); // setState(() {
}
@override
void initState() {
super.initState();
loadDetectionModel();
}
void objectRecocnition() async {}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Skin Diseases Identification")),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
left: 20,
right: 20,
top: 35,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(height: 350),
isImageLoaded
? Center(
child: Container(
height: 350,
width: 350,
decoration: BoxDecoration(
image: DecorationImage(
image: FileImage(
File(pickedImage.path)),
fit: BoxFit.contain)),
),
)
: Container(),
]),
Padding(
padding: const EdgeInsets.only(
left: 20,
right: 20,
top: 100,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Identified Disease: $_name \n Confidence: $_confidence"
// style: TextStyle(
// color: Color(0xFFF05A22),
// fontFamily: 'Montserrat',
// fontSize: 16,
// fontWeight: FontWeight.w600,
// letterSpacing: 1,
// ),
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: 331.4,
height: 50.0,
child: GestureDetector(
onTap: () {
getImageFromGallery();
},
child: Container(
// padding: EdgeInsets.fromLTRB(20, 30, 10, 15),
decoration: BoxDecoration(
border: Border.all(
// color: const Color(0xFFF05A22),
style: BorderStyle.none,
width: 1.0,
),
color: Colors.blue[200],
borderRadius:
BorderRadius.circular(10.0),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: const <Widget>[
Center(
child: Text(
"Launch Gallery",
style: TextStyle(
color: Color(0xFFFFFFFF),
fontFamily: 'Montserrat',
fontSize: 16,
fontWeight: FontWeight.w600,
letterSpacing: 1,
),
),
)
],
),
),
),
),
]),
Padding(
padding: const EdgeInsets.only(
// left: 20,
// right: 20,
top: 30,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: 331.4,
height: 50.0,
child: GestureDetector(
onTap: () {
getImageFromCamera();
},
child: Container(
// padding: EdgeInsets.fromLTRB(20, 30, 10, 15),
decoration: BoxDecoration(
border: Border.all(
// color: const Color(0xFFF05A22),
style: BorderStyle.none,
width: 1.0,
),
color: Colors.blue[200],
borderRadius:
BorderRadius.circular(
10.0),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: const <Widget>[
Center(
child: Text(
"Take a Picture ",
style: TextStyle(
color:
Color(0xFFFFFFFF),
fontFamily:
'Montserrat',
fontSize: 16,
fontWeight:
FontWeight.w600,
letterSpacing: 1,
),
),
)
],
),
),
),
),
]),
],
),
),
],
)),
],
)),
],
),
));
}
}
...@@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; ...@@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart';
import '../data/disease_sub_topics.dart'; import '../data/disease_sub_topics.dart';
import '../widgets/side_drawer.dart'; import '../widgets/side_drawer.dart';
import 'disease_identification.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key);
...@@ -99,11 +100,17 @@ class _HomePageState extends State<HomePage> { ...@@ -99,11 +100,17 @@ class _HomePageState extends State<HomePage> {
maxCrossAxisExtent: 280.0, maxCrossAxisExtent: 280.0,
children: [ children: [
GestureDetector( GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DiseaseIdentification()),
);
},
child: Container( child: Container(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
top: 10, left: 10, right: 10, bottom: 10), top: 10, left: 10, right: 10, bottom: 10),
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(40), borderRadius: BorderRadius.circular(60),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.blueAccent.withOpacity(0.6)), color: Colors.blueAccent.withOpacity(0.6)),
......
...@@ -7,7 +7,7 @@ packages: ...@@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2" version: "2.9.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
...@@ -21,21 +21,14 @@ packages: ...@@ -21,21 +21,14 @@ packages:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
...@@ -43,6 +36,13 @@ packages: ...@@ -43,6 +36,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.16.0" version: "1.16.0"
cross_file:
dependency: transitive
description:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3+2"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
...@@ -63,7 +63,7 @@ packages: ...@@ -63,7 +63,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.1"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
...@@ -90,6 +90,13 @@ packages: ...@@ -90,6 +90,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
flutter_staggered_animations: flutter_staggered_animations:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -102,6 +109,11 @@ packages: ...@@ -102,6 +109,11 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
font_awesome_flutter: font_awesome_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -130,6 +142,48 @@ packages: ...@@ -130,6 +142,48 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.1" version: "4.0.1"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.6"
image_picker_android:
dependency: transitive
description:
name: image_picker_android
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.5+3"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.10"
image_picker_ios:
dependency: transitive
description:
name: image_picker_ios
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.6+1"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.2"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
lints: lints:
dependency: transitive dependency: transitive
description: description:
...@@ -143,28 +197,28 @@ packages: ...@@ -143,28 +197,28 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.12"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.4" version: "0.1.5"
meta: meta:
dependency: transitive dependency: "direct main"
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
path_provider: path_provider:
dependency: transitive dependency: transitive
description: description:
...@@ -246,7 +300,7 @@ packages: ...@@ -246,7 +300,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2" version: "1.9.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
...@@ -267,14 +321,14 @@ packages: ...@@ -267,14 +321,14 @@ packages:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.1"
ternav_icons: ternav_icons:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -288,7 +342,14 @@ packages: ...@@ -288,7 +342,14 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.12"
tflite:
dependency: "direct main"
description:
name: tflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
......
...@@ -40,6 +40,9 @@ dependencies: ...@@ -40,6 +40,9 @@ dependencies:
font_awesome_flutter: ^10.2.1 font_awesome_flutter: ^10.2.1
flutter_staggered_animations: any flutter_staggered_animations: any
google_fonts: google_fonts:
tflite: ^1.1.2
meta: ^1.8.0
image_picker: ^0.8.5+3
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
...@@ -98,6 +101,9 @@ flutter: ...@@ -98,6 +101,9 @@ flutter:
- images/symbols/bacterial.png - images/symbols/bacterial.png
- images/symbols/viral.png - images/symbols/viral.png
- images/symbols/2.jpg - images/symbols/2.jpg
- assets/skinDiseaseIdentificationModel.tflite
- assets/labels.txt
- assets/newdog1model1.tflite
# - images/a_dot_ham.jpeg # - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment