Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TMP-23-068
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
TMP-23-068
TMP-23-068
Commits
8e8bd06c
Commit
8e8bd06c
authored
Nov 01, 2023
by
Kishan Raj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding code to emotion
Updating Codes
parent
33c0cde8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
13 deletions
+73
-13
.gitignore
.gitignore
+4
-1
emotion/app.py
emotion/app.py
+34
-0
screens/CaptureImage.js
screens/CaptureImage.js
+18
-8
screens/CapturePrescription.js
screens/CapturePrescription.js
+15
-2
screens/Graph.js
screens/Graph.js
+1
-1
screens/USWelcome.js
screens/USWelcome.js
+1
-1
No files found.
.gitignore
View file @
8e8bd06c
...
...
@@ -23,4 +23,7 @@ Nutrition/Lib
Nutrition/Scripts
US/Lib
US/Scripts
\ No newline at end of file
US/Scripts
emotion/Lib
emotion/Scripts
\ No newline at end of file
emotion/app.py
0 → 100644
View file @
8e8bd06c
from
flask
import
Flask
,
request
,
jsonify
from
tensorflow.keras.models
import
load_model
import
cv2
import
tensorflow
as
tf
import
numpy
as
np
app
=
Flask
(
__name__
)
# Load the pre-trained emotion detection model
model
=
tf
.
keras
.
models
.
load_model
(
'optimize3_model.h5'
)
# Define a function to detect emotions from an image
def
detect_emotion
(
image_data
):
emotions
=
[
"surprise"
,
"fear"
,
"angry"
,
"neutral"
,
"sad"
,
"disgust"
,
"happy"
]
img
=
cv2
.
imdecode
(
np
.
frombuffer
(
image_data
,
np
.
uint8
),
-
1
)
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
img
=
cv2
.
resize
(
img
,
(
48
,
48
))
img
=
np
.
reshape
(
img
,
(
1
,
48
,
48
,
1
))
result
=
model
.
predict
(
img
)
print
(
result
)
emotion
=
emotions
[
np
.
argmax
(
result
)]
return
emotion
@
app
.
route
(
'/detect_emotion'
,
methods
=
[
'POST'
])
def
detect_emotion_endpoint
():
try
:
image_data
=
request
.
files
[
'photo'
]
.
read
()
detected_emotion
=
detect_emotion
(
image_data
)
return
jsonify
({
'emotion'
:
detected_emotion
})
except
Exception
as
e
:
return
jsonify
({
'error'
:
str
(
e
)})
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
)
screens/CaptureImage.js
View file @
8e8bd06c
...
...
@@ -52,7 +52,7 @@ export default function US() {
});
// Replace with your Flask API URL for image processing
const
imageProcessingAPIURL
=
'
http
://192.168.8.103:5002
/process_image
'
;
const
imageProcessingAPIURL
=
'
http
s://us-image-extractor-1001-86c5c2fe91b7.herokuapp.com
/process_image
'
;
const
imageProcessingResponse
=
await
axios
.
post
(
imageProcessingAPIURL
,
formData
,
{
headers
:
{
...
...
@@ -95,7 +95,7 @@ export default function US() {
const
biometricValue
=
parseFloat
(
biometrics
[
biometric
].
replace
(
'
mm
'
,
''
).
replace
(
'
,
'
,
'
.
'
));
// Define the API URL for the specific biometric
const
biometricAPIURL
=
`http
://192.168.8.103:5003
/
${
biometric
}
`
;
const
biometricAPIURL
=
`http
s://review-predictor-1002-0349032bf1bf.herokuapp.com
/
${
biometric
}
`
;
const
predictionResponse
=
await
axios
.
post
(
biometricAPIURL
,
{
GA
:
GA
,
...
...
@@ -157,8 +157,9 @@ export default function US() {
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
scrollContainer
}
>
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
title
}
>
Image
Picker
<
/Text
>
<
Button
title
=
"
Pick an image from the gallery
"
onPress
=
{
pickImage
}
/
>
<
Text
style
=
{
styles
.
title
}
>
Growth
Predictor
:
<
/Text
>
<
Text
style
=
{
styles
.
normaltext
}
>
Input
your
baby
'
s UltraSound(US) Image here:</Text>
<Button title="Pick an image" onPress={pickImage} />
{selectedImage && (
<View style={styles.imageContainer}>
<Image source={{ uri: selectedImage }} style={styles.image} />
...
...
@@ -189,8 +190,9 @@ export default function US() {
)}
<Button
title
=
"
G
o to Target Screen
"
title="G
raphs
"
onPress={navigateToScreen}
style={styles.button}
/>
</View>
</ScrollView>
...
...
@@ -205,7 +207,12 @@ const styles = StyleSheet.create({
},
title: {
fontSize: 24,
marginBottom
:
20
,
marginTop: 60,
marginBottom: 17,
},
normaltext: {
fontSize: 18,
marginBottom: 15,
},
imageContainer: {
marginVertical: 20,
...
...
@@ -221,7 +228,7 @@ const styles = StyleSheet.create({
marginBottom: 10,
},
extractedValuesContainer: {
marginTop
:
20
,
marginTop:
5
,
padding: 10,
borderWidth: 1,
borderColor:
'
#
ccc
'
,
...
...
@@ -234,7 +241,7 @@ const styles = StyleSheet.create({
marginBottom: 10,
},
responseContainer: {
marginTop
:
2
0
,
marginTop:
1
0,
padding: 10,
borderWidth: 1,
borderColor:
'
#
ccc
'
,
...
...
@@ -254,4 +261,7 @@ const styles = StyleSheet.create({
fontWeight:
'
bold
'
,
marginBottom: 10,
},
button: {
marginTop: 30,
},
});
screens/CapturePrescription.js
View file @
8e8bd06c
...
...
@@ -110,11 +110,13 @@ const Prescription = () => {
return
(
<
ScrollView
contentContainerStyle
=
{
styles
.
container
}
>
<
View
style
=
{
styles
.
imageContainer
}
>
<
Text
style
=
{
styles
.
title
}
>
Medicine
Effect
Predictor
<
/Text
>
<
Text
style
=
{
styles
.
normaltext
}
>
Upload
your
medical
prescriptions
here
<
/Text
>
{
image
&&
<
Image
source
=
{{
uri
:
image
}}
style
=
{
styles
.
image
}
/>
}
<
Button
title
=
"
Select Image
"
onPress
=
{
pickImage
}
/
>
<
Button
title
=
"
Pick Image
"
onPress
=
{
pickImage
}
style
=
{
styles
.
pickbutton
}
/
>
<
/View
>
<
Button
title
=
"
Extract Medicine Names,
Effects
"
title
=
"
Predict the
Effects
"
onPress
=
{
extractTextFromImage
}
disabled
=
{
!
image
||
loading
}
/
>
...
...
@@ -160,4 +162,15 @@ const styles = StyleSheet.create({
fontWeight
:
'
bold
'
,
marginBottom
:
8
,
},
title
:
{
fontSize
:
24
,
marginBottom
:
70
,
},
normaltext
:
{
fontSize
:
18
,
marginBottom
:
20
,
},
pickbutton
:
{
marginTop
:
20
,
},
})
screens/Graph.js
View file @
8e8bd06c
...
...
@@ -269,7 +269,7 @@ const LineChartComponent = () => {
{
x
:
'
Jun
'
,
y
:
35
},
];
const
chartWidth
=
50
*
lowerLimitData4
.
length
;
// Adjust the factor as needed
const
chartWidth
=
50
*
data5
.
length
;
// Adjust the factor as needed
const
chartHeight
=
200
;
// You can set this to any desired height
const
chartConfig
=
{
...
...
screens/USWelcome.js
View file @
8e8bd06c
...
...
@@ -8,7 +8,7 @@ export default function USWelcome () {
const
navigation
=
useNavigation
();
const
navigateToUS
=
()
=>
{
navigation
.
navigate
(
"
U
s
"
);
navigation
.
navigate
(
"
U
S
"
);
};
...
...
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