RuntimeWarning: переполнение, обнаруженное в exp (imageai) - PullRequest
0 голосов
/ 20 октября 2019

Я изучаю / работаю с обнаружением изображений.

Я следую этому учебнику

Я изменил код обнаружения для поддержки ввода нескольких изображений:

from imageai.Detection.Custom import CustomObjectDetection
import os

detector = CustomObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath("PhoHast.h5") 
detector.setJsonPath("detection_config.json")
detector.loadModel()
diretorio = "hololens/validation/images/"
directory = os.fsencode(diretorio)
for file in os.listdir(directory):
    filename = os.fsdecode(file)
    detections = detector.detectObjectsFromImage(input_image=diretorio+filename, output_image_path=diretorio+filename+"-detected.jpg")
    for detection in detections:
        print(detection["name"], " : ", detection["percentage_probability"], " : ", detection["box_points"])

Итак, когда я запускаю код, я получаю этот вывод в терминале:

hololens  :  70.00470757484436  :  [122, 37, 179, 64]
hololens  :  61.76692247390747  :  [164, 26, 283, 100]
hololens  :  58.87643098831177  :  [8, 39, 263, 167]
hololens  :  53.12047004699707  :  [15, 31, 68, 56]
hololens  :  65.72685837745667  :  [177, 23, 258, 52]
hololens  :  55.395132303237915  :  [83, 29, 143, 50]
hololens  :  58.40786099433899  :  [128, 19, 176, 52]
/home/username/.virtualenvs/test1/lib/python3.6/site-packages/imageai/Detection/Custom/__init__.py:1234: RuntimeWarning: overflow encountered in exp
  return 1. / (1. + np.exp(-x))
hololens  :  64.8678719997406  :  [110, 16, 236, 93]
hololens  :  52.41330862045288  :  [31, 58, 213, 135]
hololens  :  61.7838978767395  :  [240, 11, 304, 38]
hololens  :  57.54014849662781  :  [202, 36, 240, 60]
hololens  :  50.5328893661499  :  [124, 21, 190, 51]
hololens  :  62.890440225601196  :  [64, 28, 179, 135]
hololens  :  68.86326670646667  :  [21, 46, 127, 142]
hololens  :  62.89368271827698  :  [165, 8, 235, 39]
hololens  :  58.59404802322388  :  [110, 31, 158, 58]
hololens  :  51.92608833312988  :  [205, 0, 283, 119]

Итак, на выходе я получаю это предупреждение:

/home/username/.virtualenvs/test1/lib/python3.6/site-packages/imageai/Detection/Custom/__init__.py:1234: RuntimeWarning: overflow encountered in exp
  return 1. / (1. + np.exp(-x))

Объяснение этому:

К сожалению, Numpy имеет некоторые ограничения при расчете значения exp выше 709 (709.7827) или меньше -745 (-745.133), а с набором данных Iполучил значения около 881,52149758 и -804,364266793 для взвешенной суммы. Numpy выдает это предупреждение - RuntimeWarning: переполнение, встречающееся в exp - и, очевидно, это ограничение в Python. Попробуйте вычислить exp для 710 или -746, используя Numpy или просто Python.

В по этой ссылке у автора есть решение для его кода.

Какя могу реализовать решение для моего кода?

...