Created
April 26, 2020 16:48
-
-
Save erksch/a21a1197dfe7d9ee74c8e530e48f2b95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import json | |
from bottle import request, response, post, route, run | |
from waymo_open_dataset import dataset_pb2 as open_dataset | |
def main(): | |
@route('/<:re:.*>', method='OPTIONS') | |
def cors(): | |
response.headers['Access-Control-Allow-Origin'] = '*' | |
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, DELETE, PUT, OPTIONS' | |
response.headers['Access-Control-Allow-Headers'] = HEADERS | |
@post('/predict') | |
def predict(): | |
segment_path = request.json['recordPath'] | |
frame_index = request.json['frameIndex'] | |
dataset = tf.data.TFRecordDataset([segment_path]) | |
dataset = dataset.skip(frame_index) | |
dataset = dataset.take(1) | |
for data in dataset: | |
frame = open_dataset.Frame() | |
frame.ParseFromString(bytearray(data.numpy())) | |
break | |
# Your 3D Object Detection magic goes here. | |
# Boxes should be list of a list with the 7 parameters | |
# center_x, center_y, center_z, width, length, height, heading | |
boxes = ... | |
return json.dumps(boxes) | |
run(host='localhost', port=9000) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment