Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
CHILD INTELLIGENT ASSESSMENT TOOL
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
2020-046
CHILD INTELLIGENT ASSESSMENT TOOL
Commits
d12f6964
Commit
d12f6964
authored
Oct 30, 2020
by
Dasun Madushanka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update dmt crash
parent
d6dfc560
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
MainAppDMT/lib/screens/details/dmt_crash.dart
MainAppDMT/lib/screens/details/dmt_crash.dart
+118
-0
No files found.
MainAppDMT/lib/screens/details/dmt_crash.dart
0 → 100644
View file @
d12f6964
import
'dart:io'
;
import
'package:DMTI_app/screens/Form/multi_form.dart'
;
import
'package:flutter/material.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:tflite/tflite.dart'
;
class
DMTCrash
extends
StatefulWidget
{
static
const
routeName
=
"dmt_crash"
;
@override
_DMTCrashState
createState
()
=>
_DMTCrashState
();
}
class
_DMTCrashState
extends
State
<
DMTCrash
>
{
List
_outputs
;
File
_image
;
bool
_loading
=
false
;
@override
void
initState
()
{
super
.
initState
();
_loading
=
true
;
loadModel
().
then
((
value
)
{
setState
(()
{
_loading
=
false
;
});
});
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Test Results'
),
actions:
[
FlatButton
(
child:
Text
(
'Next'
),
textColor:
Colors
.
white
,
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
MultiForm
()));
},
)
],
),
body:
_loading
?
Container
(
alignment:
Alignment
.
center
,
child:
CircularProgressIndicator
(),
)
:
Container
(
width:
MediaQuery
.
of
(
context
).
size
.
width
,
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
_image
==
null
?
Container
()
:
Image
.
file
(
_image
),
SizedBox
(
height:
20
,
),
_outputs
!=
null
?
Text
(
"
${_outputs[0]["label"]}
"
,
style:
TextStyle
(
color:
Colors
.
black
,
fontSize:
20.0
,
background:
Paint
()..
color
=
Colors
.
white
,
),
)
:
Container
()
],
),
),
floatingActionButton:
FloatingActionButton
(
onPressed:
pickImage
,
child:
Icon
(
Icons
.
image
),
),
);
}
pickImage
()
async
{
var
image
=
await
ImagePicker
.
pickImage
(
source
:
ImageSource
.
gallery
);
if
(
image
==
null
)
return
null
;
setState
(()
{
_loading
=
true
;
_image
=
image
;
});
classifyImage
(
image
);
}
classifyImage
(
File
image
)
async
{
var
output
=
await
Tflite
.
runModelOnImage
(
path:
image
.
path
,
numResults:
2
,
threshold:
0.5
,
imageMean:
127.5
,
imageStd:
127.5
,
);
setState
(()
{
_loading
=
false
;
_outputs
=
output
;
});
}
loadModel
()
async
{
await
Tflite
.
loadModel
(
model:
"assets/model_unquant.tflite"
,
labels:
"assets/labels.txt"
,
);
}
@override
void
dispose
()
{
Tflite
.
close
();
super
.
dispose
();
}
}
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