Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-226
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Anuththara K.G.S.N
2022-226
Commits
a4ed7747
Commit
a4ed7747
authored
Oct 09, 2022
by
Rathnayaka R.M.N.A
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Severity Level Detection
parent
09ae7fa2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
297 additions
and
1 deletion
+297
-1
assets/levels-s.txt
assets/levels-s.txt
+3
-0
assets/severitymodel.tflite
assets/severitymodel.tflite
+0
-0
lib/screens/home_screen.dart
lib/screens/home_screen.dart
+8
-1
lib/screens/severity-level-detection.dart
lib/screens/severity-level-detection.dart
+284
-0
pubspec.yaml
pubspec.yaml
+2
-0
No files found.
assets/levels-s.txt
0 → 100644
View file @
a4ed7747
None
Moderate
Severe
\ No newline at end of file
assets/severitymodel.tflite
0 → 100644
View file @
a4ed7747
File added
lib/screens/home_screen.dart
View file @
a4ed7747
import
'package:canis_care/models/component.dart'
;
import
'package:canis_care/screens/disease_intelligence_screen.dart'
;
import
'package:canis_care/screens/severity-level-detection.dart'
;
import
'package:flutter/material.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
...
...
@@ -140,11 +141,17 @@ class _HomePageState extends State<HomePage> {
),
),
GestureDetector
(
onTap:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
(
builder:
(
context
)
=>
SeverityLevelDetection
()),
);
},
child:
Container
(
padding:
const
EdgeInsets
.
only
(
top:
10
,
left:
10
,
right:
10
,
bottom:
10
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
4
0
),
borderRadius:
BorderRadius
.
circular
(
6
0
),
child:
Container
(
decoration:
BoxDecoration
(
color:
Colors
.
blueAccent
.
withOpacity
(
0.6
)),
...
...
lib/screens/severity-level-detection.dart
0 → 100644
View file @
a4ed7747
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'
;
// severityLevelDetectionState
class
SeverityLevelDetection
extends
StatefulWidget
{
const
SeverityLevelDetection
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
SeverityLevelDetection
>
createState
()
=>
_severityLevelDetectionState
();
}
class
_severityLevelDetectionState
extends
State
<
SeverityLevelDetection
>
{
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/severitymodel.tflite"
,
labels:
"assets/levels-s.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 Levels:
$_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
(
"Severity Level Detection"
)),
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 Severity Level:
$_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
,
),
),
)
],
),
),
),
),
]),
],
),
),
],
)),
],
)),
],
),
));
}
}
pubspec.yaml
View file @
a4ed7747
...
...
@@ -104,6 +104,8 @@ flutter:
-
assets/skinDiseaseIdentificationModel.tflite
-
assets/labels.txt
-
assets/newdog1model1.tflite
-
assets/levels-s.txt
-
assets/severitymodel.tflite
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment