Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit e40435d

Browse files
committed
last fixes to ensure running on new system
1 parent 305762c commit e40435d

12 files changed

Lines changed: 69 additions & 23 deletions

File tree

mac_requirements.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
numpy==1.16.2
2+
scipy==1.2.3
3+
sklearn
4+
5+
nltk==3.4
6+
fuzzywuzzy
7+
python-Levenshtein
8+
9+
rdflib
10+
iribaker
11+
SPARQLWrapper
12+
13+
PyObjC
14+
playsound
15+
webrtcvad
16+
17+
google-cloud-speech
18+
google-cloud-TextToSpeech
19+
google-cloud-translate
20+
21+
Pillow==5.4.1
22+
opencv-python
23+
24+
tornado==5.1.1
25+
typing
26+
pyaudio
27+
28+
pycountry
29+
reverse-geocoder

pepper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
# Global Logging Setup
22-
LOGGING_LEVEL = logging.DEBUG
22+
LOGGING_LEVEL = logging.INFO # INFO for cleaner experiments
2323
LOGGING_FILE = 'log.txt'
2424
LOGGING_FORMAT = '%(asctime)s %(levelname)-8s %(name)-35s %(message)s'
2525
LOGGING_DATE_FORMAT = '%x %X'

pepper/brain/LTM_statement_processing.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def _link_entity(self, entity, graph, namespace_mapping=None):
3535

3636

3737
def _create_detections(self, cntxt, context):
38+
"""
39+
40+
Parameters
41+
----------
42+
self : brain
43+
cntxt: Context
44+
context: Entity
45+
"""
3846
# Get ids of existing objects in this location
3947
memory = self.location_reasoner.get_location_memory(cntxt)
4048

@@ -63,7 +71,6 @@ def _create_detections(self, cntxt, context):
6371
# Create detection
6472
objct_detection = create_claim_graph(self, self.myself, prdt, objct, UtteranceType.EXPERIENCE)
6573
self.claim_graph.add((objct_detection.id, self.namespaces['EPS']['hasContext'], context.id))
66-
6774
observations.append(objct_detection)
6875

6976
# Open ended learning

pepper/brain/infrastructure/rdf_builder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ def _fix_nlp_types(self, types):
151151
# this was just a char
152152
fixed_types.append(types.split('.')[-1])
153153
break
154-
elif "article" in el or "prep" in el or "adj" in el:
154+
elif "article" in el or "prep" in el or "adj" in el or "verb" in el:
155+
pass
156+
elif "deictic" in el or "article:definite" in el:
157+
# need to corefer
155158
pass
156159
elif '.' in el:
157160
fixed_types.append(el.split('.')[-1])

pepper/brain/queries/content exploration/count_statements.rq

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
22
PREFIX grasp: <http://groundedannotationframework.org/grasp#>
33
PREFIX gaf: <http://groundedannotationframework.org/gaf#>
44

5-
select (COUNT(?stat) AS ?count) where {
5+
select (COUNT(distinct ?stat) AS ?count) where {
66
?stat rdf:type gaf:Assertion .
7+
?stat gaf:denotedBy ?m .
78
}

pepper/brain/queries/trust/count_statements_by.rq

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PREFIX gaf: <http://groundedannotationframework.org/gaf#>
44
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
55
PREFIX prov: <http://www.w3.org/ns/prov#>
66

7-
select (COUNT(?stat) AS ?num_stat) where {
7+
select (COUNT(distinct ?stat) AS ?num_stat) where {
88
?stat rdf:type gaf:Assertion .
99
?stat gaf:denotedBy ?m .
1010
?m grasp:wasAttributedTo ?author .

pepper/brain/reasoners/location_reasoner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def get_location_memory(self, cntxt):
8686
response = self._submit_query(query)
8787

8888
location_memory = {}
89-
if response[0]['type']['value'] != '':
89+
if response and response[0]['type']['value'] != '':
9090
for elem in response:
9191
categories, ids = self._fill_location_memory_(elem)
9292
# assign multiple categories (eg selene is person and agent)
@@ -97,7 +97,7 @@ def get_location_memory(self, cntxt):
9797
location_memory[casefold_text(category, format='triple')] = temp
9898

9999
# Local object memories
100-
for item in cntxt.objects: # Error, this skips the first element?
100+
for item in cntxt.objects: # Error, this skips the first element?
101101
if item.name.lower() != 'person':
102102
temp = location_memory.get(casefold_text(item.name, format='triple'),
103103
{'brain_ids': [], 'local_ids': []})

pepper/brain/reasoners/thought_generator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_statement_novelty(self, statement_uri):
7575
query = read_query('thoughts/statement_novelty') % statement_uri
7676
response = self._submit_query(query)
7777

78-
if response[0] != {}:
78+
if response and response[0] != {}:
7979
response = [self._fill_statement_novelty_(elem) for elem in response]
8080
else:
8181
response = []
@@ -193,11 +193,11 @@ def get_overlaps(self, utterance):
193193
"""
194194
# Role as subject
195195
query = read_query('thoughts/object_overlap') % (
196-
utterance.triple.predicate_name, utterance.triple.complement_name,
197-
utterance.triple.subject_name)
196+
utterance.triple.predicate_name, utterance.triple.complement_name,
197+
utterance.triple.subject_name)
198198
response = self._submit_query(query)
199199

200-
if response[0]['types']['value'] != '':
200+
if response and response[0]['types']['value'] != '':
201201
complement_overlap = [self._fill_overlap_(elem) for elem in response]
202202
else:
203203
complement_overlap = []
@@ -208,7 +208,7 @@ def get_overlaps(self, utterance):
208208
utterance.triple.complement_name)
209209
response = self._submit_query(query)
210210

211-
if response[0]['types']['value'] != '':
211+
if response and response[0]['types']['value'] != '':
212212
subject_overlap = [self._fill_overlap_(elem) for elem in response]
213213
else:
214214
subject_overlap = []
@@ -303,7 +303,7 @@ def get_complement_cardinality_conflicts(self, utterance):
303303
utterance.triple.complement_name)
304304

305305
response = self._submit_query(query)
306-
if response[0] != {}:
306+
if response and response[0] != {}:
307307
conflicts = [self._fill_cardinality_conflict_(elem) for elem in response]
308308
else:
309309
conflicts = []
@@ -327,7 +327,7 @@ def get_negation_conflicts(self, utterance):
327327
utterance.triple.complement_name)
328328

329329
response = self._submit_query(query)
330-
if response[0] != {}:
330+
if response and response[0] != {}:
331331
conflicts = [self._fill_negation_conflict_(elem) for elem in response]
332332
else:
333333
conflicts = []
@@ -350,7 +350,7 @@ def get_trust(self, speaker):
350350
# chat based feature
351351
num_chats = float(self.count_chat_with(speaker))
352352
friends = self.get_best_friends()
353-
best_friend_chats = float(friends[0][1])
353+
best_friend_chats = float(friends[0][1]) if friends else num_chats
354354
chat_feature = num_chats / best_friend_chats
355355

356356
# new content feature
@@ -361,7 +361,7 @@ def get_trust(self, speaker):
361361
# conflicts feature
362362
num_conflicts = float(len(self.get_conflicts_by(speaker)))
363363
all_conflicts = float(len(self.get_conflicts()))
364-
conflicts_feature = (num_conflicts / all_conflicts) - 1
364+
conflicts_feature = -(num_conflicts / all_conflicts) - 1 if all_conflicts != 0 else 1
365365

366366
# Aggregate
367367
# TODO scale

pepper/framework/backend/system/camera.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ def _run(self):
6464
t0 = time()
6565

6666
# Get frame from camera
67-
status, image = self._camera.read()
67+
# Sometimes the camera fails on the first image. We introduce a three trial policy to initialize the camera
68+
status = False
69+
image = None
70+
for chance in range(3):
71+
status, image = self._camera.read()
72+
if status:
73+
break
6874

6975
if status:
7076
if self._running:
71-
7277
# Resize Image and Convert to RGB
7378
image = cv2.resize(image, (self.width, self.height))
7479
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

pepper/framework/backend/system/text_to_speech.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def _play_sound(self, mp3):
7373
playsound(file_hash)
7474
finally:
7575
if os.path.exists(file_hash):
76+
# TODO: Sometimes we need to save all data from an experiment. Comment the line below and pass
7677
os.remove(file_hash)
7778

7879

0 commit comments

Comments
 (0)