<jupyter_start><jupyter_text><jupyter_code>!pip install tensorflow==1.13.1
!pip install tensorflow-gpu==1.13.1
!pip install opencv-python
!pip install keras==2.2.4
!pip install numpy==1.16.1
!pip install imageai --upgrade
!wget https://github.com/OlafenwaMoses/ImageAI/releases/download/essential-v4/pretrained-yolov3.h5
get_ipython().system_raw('dataset.rar')
from imageai.Detection.Custom import DetectionModelTrainer

trainer = DetectionModelTrainer()
trainer.setModelTypeAsYOLOv3()
trainer.setDataDirectory(data_directory="/content/dataset2")
trainer.setTrainConfig(object_names_array=["no"], batch_size=4, num_experiments=50, train_from_pretrained_model="/content/pretrained-yolov3.h5")
trainer.trainModel()
from imageai.Detection.Custom import DetectionModelTrainer

trainer = DetectionModelTrainer()
trainer.setModelTypeAsYOLOv3()
trainer.setDataDirectory(data_directory="/content/dataset2")
trainer.evaluateModel(model_path="/content/dataset2/models", json_path="/content/dataset2/json/detection_config.json", iou_threshold=0.5, object_threshold=0.3, nms_threshold=0.5)
from imageai.Detection.Custom import CustomObjectDetection

detector = CustomObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath("/content/dataset2/models/detection_model-ex-037--loss-0005.129.h5") 
detector.setJsonPath("/content/dataset2/json/detection_config.json")
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image="/content/dataset2/validation/images/1011.jpg", output_image_path="madeiraNo4.jpg")
for detection in detections:
    print(detection["name"], " : ", detection["percentage_probability"], " : ", detection["box_points"])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13010053222945003, 'fraction_numerical': 0.03252513305736251, 'mean_word_length': 8.837209302325581, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '524697', 'license': 'MIT', 'n_tokens_mistral': 596, 'n_tokens_neox': 557, 'n_words': 68, 'path': 'MokutonAI.ipynb', 'repo_name': 'tuliofalmeida/deeplabgod', 'size': '1691'}