Version:0.9 StartHTML:0000000105 EndHTML:0000009944 StartFragment:0000001234 EndFragment:0000009928 mXScriptasHTML
# ImageAI is a Python library built to empower Computer Vision
from imageai.Detection import ObjectDetection
#Using TensorFlow backend.

detector = ObjectDetection()

model_path = "./models/yolo-tiny.h5"
input_path = "./input/teaching.jpg"
output_path = "./output/teachwseenewimage2345.jpg"

#using the pre-trained TinyYOLOv3 model, 
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path)

#loads model from path specified above using the setModelPath() class method.
detector.loadModel()

#detection = detector.detectObjectsFromImage(input_image=input_path, \
#                                            output_image_path=output_path)
                                            
custom= detector.CustomObjects(person=True,boat=True, laptop=True,bottle=True)
detections = detector.detectCustomObjectsFromImage(custom_objects=custom, \
                  input_image=input_path, output_image_path=output_path,\
                                          minimum_percentage_probability=10)
                                            
for eachItem in detections:
    print(eachItem["name"] , " : ", eachItem["percentage_probability"])

print('image detector compute ends...')



#//----app_template_loaded_code----
#//----File newtemplate.txt not exists - now saved!----
#https://stackabuse.com/object-detection-with-imageai-in-python/
# https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo-tiny.h5
#https://imageai.readthedocs.io/en/latest/detection/index.html

"""
There are 80 possible objects that you can detect with the
ObjectDetection class, and they are as seen below.

    person,   bicycle,   car,   motorcycle,   airplane,
    bus,   train,   truck,   boat,   traffic light,   fire hydrant,   stop_sign,
    parking meter,   bench,   bird,   cat,   dog,   horse,   sheep,   cow,   elephant,   bear,   zebra,    giraffe,   backpack,   umbrella,   handbag,   tie,   suitcase,   frisbee,   skis,   snowboard,    sports ball,   kite,   baseball bat,   baseball glove,   skateboard,   surfboard,   tennis racket,    bottle,   wine glass,   cup,   fork,   knife,   spoon,   bowl,   banana,   apple,   sandwich,   orange,
    broccoli,   carrot,   hot dog,   pizza,   donot,   cake,   chair,   couch,   potted plant,   bed,    dining table,   toilet,   tv,   laptop,   mouse,   remote,   keyboard,   cell phone,   microwave,    oven,   toaster,   sink,   refrigerator,   book,   clock,   vase,   scissors,   teddy bear,   hair dryer, toothbrush.

To detect only some of the objects above, you will need to call the CustomObjects function and set the name of the
object(s) yiu want to detect to through. The rest are False by default. In below example, we detected only chose detect only person and dog.

custom = detector.CustomObjects(person=True, dog=True)

>>> console output:
car  :  54.72719669342041
car  :  58.94591808319092
car  :  62.593865394592285
car  :  74.07450675964355
car  :  91.105055809021
car  :  97.26507663726807
car  :  97.5576639175415
person  :  53.6459743976593
person  :  56.598347425460815
person  :  72.28184938430786

laptop  :  57.53162503242493
bottle  :  10.687477886676788
bottle  :  11.373373866081238
person  :  11.838557571172714
person  :  12.098842114210129
person  :  15.951324999332428
person  :  31.1357319355011
person  :  98.0242371559143
image detector compute ends...
image detector compute ends...
"""