OS Platform and Distribution (e.g., Linux Ubuntu 16.04):ubuntu16.04
Ray installed from (source or binary): pip install
Ray version:0.7.5
Python version:3.6
Exact command to reproduce:
Describe the problem
I am trying to do reading a dictionary by a for loop
every loop will call a function which there are three functions to be run by ray
but I met the error
File "lp_analysis.py", line 267, in evaluation
eval_ids.append(eval_lpd(real_name_list, sorted_lpr_names, sorted_boxes, img_path).remote())
File "/usr/local/lib/python3.6/dist-packages/ray/remote_function.py", line 92, in __call__
self._function_name, self._function_name))
Exception: Remote functions cannot be called directly. Instead of running '__main__.eval_lpd()', try '__main__.eval_lpd.remote()'
Source code / logs
@ray.remote
def eval_lpd(lps_gt,lps_prd_sort, boxes, path):
global Result
flag = 0
for i in range(len(lps_prd_sort)):
if lps_prd_sort[i] == '' or i >= len(lps_gt):
Result['detection']['fp'] += 1
Result['detection']['fp path'].append(path)
Result['detection']['fp box'].append(boxes[i])
flag = 1
else:
Result['detection']['tp'] += 1
Result['detection']['total'] += 1
return flag
@ray.remote
def eval_lpr(lps_prd, lps_gt, boxes, path):
# print(lps_gt, lps_prd, boxes, path)
global Result
flag = 0 # if all license plates are correct flag = 0
for i in range(len(lps_gt)):
if lps_prd[i] != '':
flag2 = 0 # if one of license plate correct flag2 = 1
result = list(difflib.Differ().compare(lps_prd[i], lps_gt[i]))
for act in result:
# print(act)
if act[0] == '-':
Result['recognition']['fp'][CLASSES_RECOGNITION.index(act[2])] += 1
Result['recognition']['fp path'][CLASSES_RECOGNITION.index(act[2])].append(path)
Result['recognition']['fp box'][CLASSES_RECOGNITION.index(act[2])].append(boxes)
flag2 = 1
flag = 1
elif act[0] == '+':
Result['recognition']['fn'][CLASSES_RECOGNITION.index(act[2])] += 1
Result['recognition']['fn path'][CLASSES_RECOGNITION.index(act[2])].append(path)
Result['recognition']['fn box'][CLASSES_RECOGNITION.index(act[2])].append(boxes)
flag2 = 1
flag = 1
elif act[0] == ' ':
Result['recognition']['tp'][CLASSES_RECOGNITION.index(act[2])] += 1
else:
print("error:", act)
Result['recognition']['total'][CLASSES_RECOGNITION.index(act[2])] += 1
else :
flag2 = 1
flag = 1
if flag2 == 0:
Result['recognition']['correct'] += 1
return flag
@ray.remote
def eval_lpf(fmts, real_fmts, boxes, path):
global Result
flag = 0 # if all license plates are correct flag = 0
for i in range(len(real_fmts)):
# if one of license plate correct flag2 = 1
if fmts[i] == real_fmts[i]:
Result['classification']['tp'][fmts[i]] += 1
elif real_fmts[i] != 7:
flag = 1
Result['classification']['fp'][fmts[i]] += 1
Result['classification']['fp path'][fmts[i]].append(path)
Result['classification']['fp box'][fmts[i]].append(boxes)
Result['classification']['fn'][real_fmts[i]] += 1
Result['classification']['fn path'][real_fmts[i]].append(path)
Result['classification']['fn box'][real_fmts[i]].append(boxes)
if real_fmts[i] == 7 or fmts[i] == 7:
Result['broke'] += 1
Result['broke path'].append(path)
Result['broke loc'].append(i)
Result['classification']['total'][real_fmts[i]] += 1
return flag
def evaluation(lpr_names, fmts, img_path, boxes):
print ("eval input:", lpr_names, fmts, img_path, boxes)
#generate ground_truth
real_name_list, real_name_list_no_dash, real_fmts = get_real_names(img_path)
# print("real", real_name_list, real_name_list_no_dash, real_fmts)
#sort the results of lpr & lpf to compare with ground trouth
sorted_lpr_names, sorted_fmts, sorted_boxes = sort_lvst(real_name_list_no_dash, lpr_names, fmts, boxes)
# print("sort", sorted_lpr_names, sorted_fmts, sorted_boxes)
eval_ids =[]
#evaluation for lpd
eval_ids.append(eval_lpd(real_name_list, sorted_lpr_names, sorted_boxes, img_path).remote())
#evaluation for lpr
eval_ids.append(eval_lpr(sorted_lpr_names, real_name_list_no_dash, sorted_boxes, img_path).remote())
#evaluation for lpf
eval_ids.append(eval_lpf(sorted_fmts, real_fmts, sorted_boxes, img_path).remote())
evals = ray.get(eval_ids)
if (eval_ids[0] or eval_ids[1] or eval_ids[2]) == 1:
return 0
else:
return 1
for data in inference_result:
# lpd didn't find any license plate under the threshold
if not data['Boxes']:
Result['detection']['fn'] += 1
Result['detection']['fn path'].append(path)
continue
if evaluation(data['Names'], data['Fmts'], data['Image path'], data['Boxes']) == 1 :
Result['failed images'] += 1
Result['failed path'].append(img_path)
System information
Describe the problem
I am trying to do reading a dictionary by a for loop every loop will call a function which there are three functions to be run by ray but I met the error
Source code / logs