Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TDDE19-group-5-pepper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TDDE19-2021-5
TDDE19-group-5-pepper
Commits
8021c91f
Commit
8021c91f
authored
3 years ago
by
Oscar Linnarsson
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/text-2-emotion-2' into 'master'
fix: text_2_emotion_2 See merge request
!6
parents
938df285
5a2c737a
No related branches found
No related tags found
1 merge request
!6
fix: text_2_emotion_2
Pipeline
#56596
passed
3 years ago
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lhw_nlp/Dockerfile
+5
-5
5 additions, 5 deletions
src/lhw_nlp/Dockerfile
src/lhw_nlp/lhw_nlp/text_2_emotion_2.py
+6
-18
6 additions, 18 deletions
src/lhw_nlp/lhw_nlp/text_2_emotion_2.py
with
11 additions
and
23 deletions
src/lhw_nlp/Dockerfile
+
5
−
5
View file @
8021c91f
...
...
@@ -11,11 +11,11 @@ RUN if [ "$NO_GPU" = 0 ]; then \
RUN
pip3
install
transformers
RUN
pip3
install
dialogflow
RUN
pip3
install
pygame
# ADD THESE LATER :)
RUN
pip3
install
text
2
emotion
#
RUN pip3 install te
nsorflow
#
RUN pip3 install
pickle
#
RUN pip3 install scipy
# For
text
_2_
emotion
nodes
RUN
pip3
install
te
xt2emotion
RUN
pip3
install
tensorflow
RUN
pip3
install
scipy
# Install dependencies
COPY
src/lhw_interfaces src/lhw_interfaces
...
...
This diff is collapsed.
Click to expand it.
src/lhw_nlp/lhw_nlp/text_2_emotion_2.py
+
6
−
18
View file @
8021c91f
...
...
@@ -21,6 +21,7 @@ import time
import
pickle
import
numpy
as
np
import
os
class
NodeText2Emotion
(
Node
):
def
__init__
(
self
,
model
,
tokenizer
):
...
...
@@ -68,36 +69,23 @@ class NodeText2Emotion(Node):
def
text_cb
(
self
,
text_msg
):
"""
text_cb.data has the text data
"""
self
.
get_logger
().
info
(
'
text callback!
'
)
if
text_msg
.
recognized_text
!=
"
"
:
self
.
log
.
info
(
"
Response:
"
+
text_msg
.
recognized_text
)
#--------------CHECK THE CODE BELOW WITH EXPORT SIMON T-----------------------------
print
(
str
(
text_msg
.
recognized_text
))
#
print(str(text_msg.recognized_text))
emotion_arr
=
self
.
analyse_text
(
str
(
text_msg
.
recognized_text
))
msg_emotion
=
self
.
generateEventT2E
(
source_id
=
Response
.
TEXT_2_EMOTION_2
,
speaker_id
=
''
,
emotion_
dict
=
emotion_arr
emotion_
arr
=
emotion_arr
[
0
]
# SAMI HAVE A LOOK AT THIS /OSCAR :)
)
self
.
broadcast_emotion
.
publish
(
msg_emotion
)
#print('Predicted emotion is: {} and prediction took ({:.2f} seconds)'.format(emotion, pred_time))
# resp_msg = 'Predicted emotion is: {} and prediction took ({:.2f} seconds)'.format(emotion, pred_time)
# msg.recognized_text = resp_msg
# animated_msg.data = "I sense {} in you".format(emotion)
# self.response_pub.publish(msg)
# self.animated_pub.publish(animated_msg)
# msg.response = "TODO: THIS SHOULD BE THE PREDICTED EMOTION"
# self.get_logger().info('publishing: "%s"' % msg.response)
def
main
(
args
=
None
):
model
=
keras
.
models
.
load_model
(
"
nlp
"
)
with
open
(
'
tokenizer.pickle
'
,
'
rb
'
)
as
handle
:
path_to_here
=
os
.
getcwd
()
+
'
/src/lhw_nlp/lhw_nlp/
'
model
=
keras
.
models
.
load_model
(
path_to_here
+
'
nlp
'
)
with
open
(
path_to_here
+
'
tokenizer.pickle
'
,
'
rb
'
)
as
handle
:
tokenizer
=
pickle
.
load
(
handle
)
rclpy
.
init
(
args
=
args
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment