コード例 #1
0
def main():
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--model',
                        help='File path of .tflite file.',
                        required=True)
    parser.add_argument('--labels',
                        help='File path of labels file.',
                        required=True)
    parser.add_argument('--threshold',
                        help='Score threshold for detected objects.',
                        required=False,
                        type=float,
                        default=0.4)
    args = parser.parse_args()

    labels = load_labels(args.labels)
    interpreter = Interpreter(args.model)
    interpreter.allocate_tensors()
    _, input_height, input_width, _ = interpreter.get_input_details(
    )[0]['shape']

    with picamera.PiCamera(
            # open PI camera
            resolution=(CAMERA_WIDTH, CAMERA_HEIGHT),
            framerate=30) as camera:
        camera.start_preview()
        try:
            # get real-time data
            stream = io.BytesIO()
            annotator = Annotator(camera)
            for _ in camera.capture_continuous(stream,
                                               format='jpeg',
                                               use_video_port=True):
                stream.seek(0)
                image = Image.open(stream).convert('RGB').resize(
                    (input_width, input_height), Image.ANTIALIAS)
                start_time = time.monotonic()
                results = detect_objects(interpreter, image, args.threshold)
                elapsed_ms = (time.monotonic() - start_time) * 1000

                annotator.clear()
                annotate_objects(annotator, results, labels)
                annotator.text([5, 0], '%.1fms' % (elapsed_ms))
                annotator.update()

                stream.seek(0)
                stream.truncate()

        finally:
            camera.stop_preview()
コード例 #2
0
    def __init__(self):
        self.jump_step = 20
        self.fig = plt.figure(1)
        self.ann = Annotator()
        self.xs = []
        self.ys = []
        self.ax = self.fig.add_subplot(111)
        self.ax.set_title('click to build box segments')
        self.show = None
        # box is  x1, x2, x3, x4
        self.all_box_in_one_image = []
        self.all_boxes_to_write = self.ann.boxes.copy()
        self.image = []
        self.stop = False

        # register event for mouse click and keyboard press
        self.cid_m_click = self.fig.canvas.mpl_connect('button_press_event',
                                                       self.mouse_click)
        self.cid_k_press = self.fig.canvas.mpl_connect('key_press_event',
                                                       self.on_key)

        self.reload_image()
コード例 #3
0
ファイル: test.py プロジェクト: cyclecycle/bio-annotate
from pprint import pprint
from annotate import Annotator

annotator = Annotator()

pmid = 29969095
pbt = annotator.pubtator_annotations(pmid)
pprint(pbt)

text = '''
Neurogenic decisions require a cell cycle independent function of the CDC25B phosphatase. A fundamental issue in developmental biology and in organ homeostasis is understanding the molecular mechanisms governing the balance between stem cell maintenance and differentiation into a specific lineage. Accumulating data suggest that cell cycle dynamics play a major role in the regulation of this balance. Here we show that the G2/M cell cycle regulator CDC25B phosphatase is required in mammals to finely tune neuronal production in the neural tube. We show that in chick neural progenitors, CDC25B activity favors fast nuclei departure from the apical surface in early G1, stimulates neurogenic divisions and promotes neuronal differentiation. We design a mathematical model showing that within a limited period of time, cell cycle length modifications cannot account for changes in the ratio of the mode of division. Using a CDC25B point mutation that cannot interact with CDK, we show that part of CDC25B activity is independent of its action on the cell cycle.
'''

dbp = annotator.dbpedia_annotations(text)
pprint(dbp)

df = pbt.join(dbp, how='outer')

terms = df.index
bio2rdf = annotator.bio2rdf_annotations(terms)
print(bio2rdf)

df = df.join(bio2rdf)