This repository was archived by the owner on May 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Implementing DetectionPolicy with existing Inceptionv3 model #41
Open
henrypinkard
wants to merge
20
commits into
fuego-dev:detection_policy
Choose a base branch
from
henrypinkard:master
base: detection_policy
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1a3e277
re merge everything on new branch
henrypinkard 5ab1ab2
1 more small cahnge with remerge
henrypinkard 8396723
Merge branch 'master' of https://github.com/fuego-dev/firecam
henrypinkard a6a68a5
Got docker python running to launch inference image from pyhton
henrypinkard b46ae2f
update VM build script with new packages
henrypinkard 1a858f1
restore original version of rect_to_squares since cropping for servin…
henrypinkard 0f5aa05
added function for training inceptionv3 with keras
henrypinkard f28188a
added args and early stopping and model export
henrypinkard 15d11b5
Merge branch 'master' of https://github.com/henrypinkard/firecam
henrypinkard 5d1b3c2
Merge branch 'master' of https://github.com/fuego-dev/firecam
henrypinkard b9293d8
classifier training changes
invalid-email-address eb855ee
patched up around some bugs in tf2.0 for training
invalid-email-address daa82cf
removed tmp files
henrypinkard c140717
training tweaks
invalid-email-address f3a3a82
Merge branch 'master' of https://github.com/henrypinkard/firecam
invalid-email-address ce30ee3
added script for packaging trained model into docker file
henrypinkard 0aeadfd
added script for packaging trained model into docker file
henrypinkard b6ba479
remove some notes
henrypinkard ea78e60
revert to old version
henrypinkard dae03b2
revert to previous version
henrypinkard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,5 @@ credentials.json | |
| token.json | ||
| local.db | ||
| node_modules | ||
| #pycharm files | ||
| */.idea/ | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Copyright 2018 The Fuego Authors. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ============================================================================== | ||
| """ | ||
| Helper functions for Google Cloud Platform | ||
| """ | ||
|
|
||
| import grpc | ||
| import tensorflow as tf | ||
| import time | ||
|
|
||
| from tensorflow_serving.apis import predict_pb2 | ||
| from tensorflow_serving.apis import prediction_service_pb2_grpc | ||
| from tensorflow.python.framework import tensor_util | ||
|
|
||
| def connect_to_prediction_service(server_ip_and_port): | ||
| """ | ||
| Connect to a an inference server at given ip address and port. Server could be | ||
| a single machine or a Kubernetes cluster | ||
| :param server_ip_and_port: string with ip address followed by port (e.g. '34.82.71.243:8500') | ||
| :return: PredicitonServiceStub object | ||
| """ | ||
| # tf.app.flags.DEFINE_string('server', server_ip_and_port, 'PredictionService host:port') | ||
| # channel = grpc.insecure_channel(tf.app.flags.FLAGS.server) | ||
|
Comment on lines
+36
to
+37
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these two lines be deleted? If not, please describe when/how they are needed/useful. |
||
| channel = grpc.insecure_channel(server_ip_and_port) | ||
| # grpc.secure_channel() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. secure_channel definitely sounds better than insecure_channel. Please document what's preventing using secure version. |
||
| return prediction_service_pb2_grpc.PredictionServiceStub(channel) | ||
|
|
||
| def predict_batch(prediction_service, crops, timing=False): | ||
| """ | ||
| Run inference on a batch of predicitons | ||
| :param crops: N x H x W x 3 uint8 numpy array (e.g. set of crops for a single camera) | ||
| :return: N x 2 numpy array of smoke/nonsmoke probabilities | ||
| """ | ||
|
|
||
| # Send request | ||
| # See prediction_service.proto for gRPC request/response details. | ||
| request = predict_pb2.PredictRequest() | ||
| request.model_spec.name = 'inception' | ||
| request.model_spec.signature_name = 'serving_default' | ||
| request.inputs['image_batch:0'].CopyFrom(tf.contrib.util.make_tensor_proto(crops, shape=crops.shape)) | ||
|
|
||
| start = time.time() | ||
| result = prediction_service.Predict(request, 1000.0) # 1000 secs timeout | ||
| if timing: | ||
| print('Inference time {}'.format(time.time() - start)) | ||
| #convert to numpy | ||
| numpy_result = tensor_util.MakeNdarray(result.outputs["import_1/import/InceptionV3/Predictions/Reshape_1"]) | ||
| return numpy_result | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,8 @@ | |
| downloadDir = 'XXX/orig' | ||
| archive_storage_bucket = "fuego-firecam-a" | ||
|
|
||
| server_ip_and_port = 'localhost:8500' #depends on the specific inference server running on GCP | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "localhost" means do inference locally on same machine. Can also be an IP address to an inference server |
||
|
|
||
| teamDriveID = '0ADX9uPkOmsDJUk9PVA' # Fuego Smoke | ||
| allPictures = '1SCXFLE25EbQUQMvTcWfeHFU29qxN8WMM' # Pictures - Samples and Full Sets | ||
| # smokePictures = '1jq9p2A5BVLh1oWKktpV1oaWTVUU9KmNJ' # Smoke | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the standard license and copyright header at the top of the file. Also, please add one or few lines comment describing the main purpose of this file.