| 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 | |