File size: 1,061 Bytes
696ce04 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import configparser
from image_classification_api import ImageClassifierVGG16
from PIL import Image
class ImageProcessor():
def __init__(self):
self.config = configparser.ConfigParser()
self.config.read('config.cfg')
self.hard_detection_threshold = float(self.config['CONFIG']['hard_detection_threshold'])
self.image_classifier = ImageClassifierVGG16()
self.device = self.image_classifier.get_device()
self.model = self.image_classifier.get_model(self.device)
def read_image(self, input_image_path):
input_image = Image.open(input_image_path)
return input_image
def process_image(self, input_image):
classification_summary = \
self.image_classifier.image_classification(self.model,
input_image,
self.device,
self.hard_detection_threshold)
return classification_summary
|