This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from imageai.Detection.Custom import CustomObjectDetection | |
detector = CustomObjectDetection() | |
detector.setModelTypeAsYOLOv3() | |
detector.setModelPath("hololens-ex-60--loss-2.76.h5") | |
detector.setJsonPath("detection_config.json") | |
detector.loadModel() | |
detections = detector.detectObjectsFromImage(input_image="holo3.jpg", output_image_path="holo3-detected.jpg") | |
for detection in detections: | |
print(detection["name"], " : ", detection["percentage_probability"], " : ", detection["box_points"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from imageai.Detection.Custom import DetectionModelTrainer | |
trainer = DetectionModelTrainer() | |
trainer.setModelTypeAsYOLOv3() | |
trainer.setDataDirectory(data_directory="hololens") | |
trainer.evaluateModel(model_path="hololens/models", json_path="hololens/json/detection_config.json", iou_threshold=0.5, object_threshold=0.3, nms_threshold=0.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from imageai.Detection.Custom import DetectionModelTrainer | |
trainer = DetectionModelTrainer() | |
trainer.setModelTypeAsYOLOv3() | |
trainer.setDataDirectory(data_directory="hololens") | |
trainer.setTrainConfig(object_names_array=["hololens"], batch_size=4, num_experiments=100, train_from_pretrained_model="pretrained-yolov3.h5") | |
trainer.trainModel() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<annotation> | |
<folder>images</folder> | |
<filename>image (49).jpg</filename> | |
<path>mypath\images\image (49).jpg</path> | |
<source> | |
<database>Unknown</database> | |
</source> | |
<size> | |
<width>310</width> | |
<height>162</height> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from imageai.Prediction.Custom import CustomImagePrediction | |
import os | |
predictor = CustomImagePrediction() | |
predictor.setModelPath(model_path="transfer_trained_fruits_model_ex-050_acc-0.862500.h5") | |
predictor.setJsonPath(model_json="model_class.json") | |
predictor.loadFullModel(num_objects=5) | |
prediction, probability = predictor.predictImage(image_input=os.path.join(os.getcwd(), "sample.jpg"), result_count=1) | |
print(prediction, " :", probability) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from imageai.Prediction.Custom import ModelTraining | |
trainer = ModelTraining() | |
trainer.setModelTypeAsResNet() | |
trainer.setDataDirectory("fruits") | |
trainer.trainModel(num_objects=5, num_experiments=50, enhance_data=True, save_full_model=True, batch_size=32, show_network_summary=True, transfer_from_model="resnet50_weights_tf_dim_ordering_tf_kernels.h5", initial_num_objects=1000, transfer_with_full_training=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'success': True, | |
'predictions': [{'y_min': 197, 'x_max': 396, 'x_min': 254, 'label': 'person', 'y_max': 394, 'confidence': 0.9963659}, | |
{'y_min': 253, 'x_max': 349, 'x_min': 47, 'label': 'person', 'y_max': 563, 'confidence': 0.9960499}, | |
{'y_min': 205, 'x_max': 764, 'x_min': 617, 'label': 'person', 'y_max': 381, 'confidence': 0.9950463}, | |
{'y_min': 269, 'x_max': 1001, 'x_min': 647, 'label': 'person', 'y_max': 559, 'confidence': 0.9885887}, | |
{'y_min': 233, 'x_max': 346, 'x_min': 184, 'label': 'person', 'y_max': 454, 'confidence': 0.97972304}, | |
{'y_min': 194, 'x_max': 1001, 'x_min': 894, 'label': 'person', 'y_max': 285, 'confidence': 0.9065306}, | |
{'y_min': 74, 'x_max': 278, 'x_min': 229, 'label': 'person', 'y_max': 243, 'confidence': 0.6799101}, | |
{'y_min': 224, 'x_max': 897, 'x_min': 636, 'label': 'person', 'y_max': 455, 'confidence': 0.5133961}, | |
{'y_min': 501, 'x_max': 353, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
namespace appone | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("request") | |
const fs = require("fs") | |
image_stream = fs.createReadStream("office.png") | |
var form = {"image":image_stream} | |
//REMEMBER TO REPLACE IP '165.22.72.67' below with the IP of your Ubuntu server | |
request.post({url:"http://165.22.72.67:80/v1/vision/detection", formData:form},function(err,res,body){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
image_data = open("office.png","rb").read() | |
#REMEMBER TO REPLACE IP '165.22.72.67' below with the IP of your Ubuntu server | |
response = requests.post("http://165.22.72.67:80/v1/vision/detection",files={"image":image_data}).json() | |
print(response) |