Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Sokolkov r7vme

View GitHub Profile
View l2_norm.py
with ops.name_scope(name, "l2_normalize", [x]) as name:
x = ops.convert_to_tensor(x, name="x")
square_sum = math_ops.reduce_sum(math_ops.square(x), axis, keepdims=True)
x_inv_norm = math_ops.rsqrt(math_ops.maximum(square_sum, epsilon))
return math_ops.multiply(x, x_inv_norm, name=name)
View gist:e518ac5575cbce2430b54c8f68cb2be1
for node in nodes:
if "LeakyRelu" in node:
ns[node]=gs.create_plugin_node(name=node,op="LReLU_TRT", negSlope=0.1)
if "orientation/l2_normalize" in node:
dynamic_graph.remove(node)
dynamic_graph.collapse_namespaces(ns)
@r7vme
r7vme / convert_3dbox_to_trt.py
Created Jul 8, 2019
convert 3dbox network to tensorrt
View convert_3dbox_to_trt.py
#!/usr/bin/env python3
import graphsurgeon as gs
import tensorflow as tf
import tensorrt as trt
import uff
if __name__ == "__main__":
### USER DEFINED VARIABLES ###
data_type = trt.DataType.HALF
#data_type = trt.DataType.FLOAT
@r7vme
r7vme / gist:7276929c7ddcce41eb0872d389634e4d
Created Jul 8, 2019
jetson xavier cuda info (deviceQuery)
View gist:7276929c7ddcce41eb0872d389634e4d
Device 0: "Xavier"
CUDA Driver Version / Runtime Version 10.0 / 10.0
CUDA Capability Major/Minor version number: 7.2
Total amount of global memory: 15700 MBytes (16462909440 bytes)
( 8) Multiprocessors, ( 64) CUDA Cores/MP: 512 CUDA Cores
GPU Max Clock rate: 1500 MHz (1.50 GHz)
Memory Clock rate: 1377 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
@r7vme
r7vme / gist:d9a3f29771c3c69fc5702fd90ca7739a
Created Jul 8, 2019
jetson tx2 cuda info (deviceQuery)
View gist:d9a3f29771c3c69fc5702fd90ca7739a
Device 0: "NVIDIA Tegra X2" [2/141]
CUDA Driver Version / Runtime Version 10.0 / 10.0
CUDA Capability Major/Minor version number: 6.2
Total amount of global memory: 7852 MBytes (8233566208 bytes)
( 2) Multiprocessors, (128) CUDA Cores/MP: 256 CUDA Cores
GPU Max Clock rate: 1020 MHz (1.02 GHz)
Memory Clock rate: 1300 Mhz
Memory Bus Width: 128-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
View patch1.txt
diff --git a/net/bbox_3D_net.py b/net/bbox_3D_net.py
index 6daafdd..8146caa 100644
--- a/net/bbox_3D_net.py
+++ b/net/bbox_3D_net.py
@@ -18,7 +18,7 @@ def bbox_3D_net(input_shape=(224, 224, 3), vgg_weights=None, freeze_vgg=False, b
for layer in vgg16_model.layers:
layer.trainable = False
- x = Flatten()(vgg16_model.output)
+ x = Reshape((25088,))(vgg16_model.output)
@r7vme
r7vme / add_tf_operation_to_graph.py
Created Jun 23, 2019
Add new TensorFlow opeation to existing (freezed) graph
View add_tf_operation_to_graph.py
import tensorflow as tf
def get_graph_def_from_file(graph_filepath):
with tf.Graph().as_default():
with tf.gfile.GFile(graph_filepath, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
return graph_def
# inputs
@r7vme
r7vme / convert_bonnet_to_tensorrt.py
Last active Jul 4, 2019
convert_bonnet_to_tensorrt.py
View convert_bonnet_to_tensorrt.py
#!/usr/bin/env python3
import graphsurgeon as gs
import tensorflow as tf
import tensorrt as trt
import uff
if __name__ == "__main__":
data_type = trt.DataType.HALF
#data_type = trt.DataType.FLOAT
output_node = "test_model/model/logits/linear/BiasAdd"
@r7vme
r7vme / camera_intrinsics_from_FOV.py
Last active Jun 18, 2019
Find camera intrinsics matrix from FOV and resolution
View camera_intrinsics_from_FOV.py
#!/usr/bin/env python3
import math
# input
VFOV=60
H=480
W=856
aspRatio=W/H
VFOV_rad=VFOV*math.pi/180.
HFOV_rad= 2 * math.atan( math.tan(VFOV_rad/2) * aspRatio )
View gist:ee90289a593a856303b3718d42686936
python3 scripts/convert_plan.py box3d.pb box3d.plan input 224 224 dimension/LeakyRelu 1 0 float
/usr/lib/python3/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
WARNING:tensorflow:From /usr/lib/python3.6/dist-packages/uff/converters/tensorflow/conversion_helpers.py:185: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.
UFF Version 0.5.5
=== Automatically deduced input nodes ===
[name: "input_1"
op: "Placeholder"
You can’t perform that action at this time.