-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathModel.py
More file actions
23 lines (16 loc) · 710 Bytes
/
Copy pathModel.py
File metadata and controls
23 lines (16 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import tensorflow as tf
import tensorflow_hub as hub
from Dataset import Dataset
class Model:
def __init__(self, params):
self._prepare_graph(params)
def _prepare_graph(self, params):
tf.reset_default_graph()
self.dataset = Dataset(params)
self.class_entities, self.boxes = self._prepare_model(self.dataset.img_data)
def _prepare_model(self, images):
module = hub.Module('https://tfhub.dev/google/faster_rcnn/openimages_v4/inception_resnet_v2/1')
detector = module(dict(images=images), as_dict=True)
class_entities = detector['detection_class_entities']
boxes = detector['detection_boxes']
return class_entities, boxes