Exemplo n.º 1
0
from imageai.Prediction import ImagePrediction
import os
execution_path = os.getcwd()

prediction = ImagePrediction()
prediction.setModelTypeAsMobileNetV2()
prediction.setModelPath(os.path.join(execution_path, "mobilenet_v2.h5"))
prediction.loadModel()

predictions, probabilities = prediction.classifyImage(os.path.join(
    execution_path, "house.jpg"),
                                                      result_count=5)
for eachPrediction, eachProbability in zip(predictions, probabilities):
    print(eachPrediction, " : ", eachProbability)
from imageai import Prediction
from imageai.Prediction import ImagePrediction
import os

execution_path = os.getcwd()
# print(execution_path)

prediction = ImagePrediction()
prediction.setModelTypeAsMobileNetV2()  # decide what model we're going to use
prediction.setModelPath(os.path.join(execution_path, "mobilenet_v2.h5"))
prediction.loadModel()

predictions, probabilities = prediction.classifyImage(os.path.join(
    execution_path, "house.jpg"),
                                                      result_count=5)
for eachPrediction, eachProbability in zip(predictions, probabilities):
    print(eachPrediction, " : ", eachProbability)
#Date: July 18, 2021
#Author: Terry Su
#Purpose: using the imageai library to initialize an image regocnition program in python

from imageai.Prediction import ImagePrediction
import os

execution_path = os.getcwd()  #current working directory

prediction = ImagePrediction()

prediction.setModelTypeAsMobileNetV2(
)  #we will be using he "Mobile Net V2" model
prediction.setModelPath(os.path.join(execution_path, 'mobilenet_v2.h5'))
prediction.loadModel()

predictions, probabilities = prediction.classifyImage(
    os.path.join(execution_path, 'house.jpg'),
    result_count=10)  #producing 10 predictions for house.jpg
for eachPrediction, eachProbability in zip(predictions, probabilities):
    print(eachPrediction, " : ", f'%{eachProbability}')
print()

predictions, probabilities = prediction.classifyImage(
    os.path.join(execution_path, 'godzilla.jpg'),
    result_count=10)  #producing 10 predictions for house.jpg
for eachPrediction, eachProbability in zip(predictions, probabilities):
    print(eachPrediction, " : ", f'%{eachProbability}')
print()

predictions, probabilities = prediction.classifyImage(