Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Purine model to predict
#! /usr/bin/env python
#################################################################################
# File Name : PlateModel.py
# Created By : Hao Li
# Creation Date : [2016-04-19 16:27]
# Last Modified : [2016-04-23 15:17]
# Description :
#################################################################################
from pymongo import MongoClient
import os
import sys
import numpy as np
import importlib
import ConfigParser
reload(sys) # 2
sys.setdefaultencoding('utf-8') # 3
class PurineModel:
def __init__(self):
sys.path.append('./libs')
self.net = importlib.import_module("purine.libautopurine")
self.cf = ConfigParser.ConfigParser()
self.cf.read('conf.ini')
self.gray_reg_net_idx = self.net.init_model(self.cf.get('plate_detection', 'purine_gray_reg_model'), 0)
def __del__(self):
self.net.delete_model(self.gray_reg_net_idx)
def getProb(self, imgpath):
jpeg_contents = [open(imgpath).read()]
prob = [[0 for i in range(73)]]
self.net.predict(self.gray_reg_net_idx, jpeg_contents, prob, {'data_type':1, 'multi_view':0})
return prob
def predict(self, segments):
probs = []
for s in segments:
probs.extend(self.getProb(s))
probs = np.array(probs)
return probs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.