Skip to content

Instantly share code, notes, and snippets.

View Rishit-dagli's full-sized avatar
:octocat:
Making Machines Learn

Rishit Dagli Rishit-dagli

:octocat:
Making Machines Learn
View GitHub Profile
@Rishit-dagli
Rishit-dagli / caching.ipynb
Last active April 23, 2021 08:21
See how you can use .cache in TensorFlow to boost your performance
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Rishit-dagli
Rishit-dagli / prefetch.ipynb
Last active December 20, 2020 03:53
Understand how to use Prefetch and how you can optimize your input and training pipelines
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Rishit-dagli
Rishit-dagli / mlkit-inference.kt
Created December 11, 2020 03:32
An example showing inference with MLKit in Android
private val objectDetector = ObjectDetection.getClient(customObjectDetectorOptions) objectDetector.process(image)
.addOnFailureListener(Log.d(...))
.addOnSuccessListener{
graphicsOverlay.clear()
for (detectedObject in it){
graphicsOverlay.add(ObjectGraphic(graphicsOverlay, detectedObject))
}
graphicsOverlay.postInvalidate()}
@Rishit-dagli
Rishit-dagli / text-analytics-azure.ipynb
Last active December 2, 2020 01:32
This notebook shows how to begin analyzing language with the Text Analytics REST API and Python. This shows you how to detect language, analyze sentiment, extract key phrases, and identify linked entities.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Rishit-dagli
Rishit-dagli / full_optimization.py
Created October 16, 2020 08:12
Full integer quantization TFLite
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
converter.inference_input_type = tf.uint8
converter.inference_output_type = tf.uint8
tflite_model_quant = converter.convert()
tflite_model_quant_file = "model.tflite"
tflite_model_quant_file.write_bytes(tflite_model_quant)
@Rishit-dagli
Rishit-dagli / post_train_weight_opt.py
Created October 16, 2020 08:10
Post-training weight quantization, TFLite
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.experimental_new_converter = True
# Post training quantization
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
tflite_quant_model = converter.convert()
tflite_model_quant_file = "model.tflite"
tflite_model_quant_file.write_bytes(tflite_quant_model)
@Rishit-dagli
Rishit-dagli / pt_to_onnx_to_pb.py
Created October 16, 2020 04:14
Convert PyTorch model to ONNX to TF 2 SavedModel
# Use torch.onnx.export function
model_pytorch = SimpleModel(input_size=input_size, hidden_sizes=hidden_sizes, output_size=output_size)
model_pytorch.load_state_dict(torch.load('./models/model_simple.pt'))
sample_input = torch.from_numpy(X_test[0].reshape(1, -1)).float().to(device)
sample_output = model_pytorch(dummy_input)
# Export to ONNX format
torch.onnx.export(model_pytorch, sample_input, './models/model_simple.onnx', input_names=['test_input'], output_names=['test_output'])
@Rishit-dagli
Rishit-dagli / pt_to_onnx.py
Created October 16, 2020 04:11
Convert PyTorch .pt model to ONNX
# Use torch.onnx.export function
model_pytorch = SimpleModel(input_size=input_size, hidden_sizes=hidden_sizes, output_size=output_size)
model_pytorch.load_state_dict(torch.load('./models/model_simple.pt'))
sample_input = torch.from_numpy(X_test[0].reshape(1, -1)).float().to(device)
sample_output = model_pytorch(dummy_input)
# Export to ONNX format
torch.onnx.export(model_pytorch, sample_input, './models/model_simple.onnx', input_names=['test_input'], output_names=['test_output'])
@Rishit-dagli
Rishit-dagli / Python3-by-Practice-CLA.md
Created October 1, 2020 03:17
CLA for Python3-by-Practice

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”), and conveys certain license rights to Rishit Dagli for Your contributions to Rishit Dagli's open source projects. This Agreement is effective upon Your acknowledgment via the CLA Assistant tool. All prospective contributors to Rishit Dagli's open source projects must sign this Agreement (digitally or otherwise) before any changes will be merged.

1. Definitions.

“Code” means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to Rishit Dagli under this Agreement.

“Project” means any of the projects owned or managed by Rishit Dagli in which software is offered under a license approved by the Open Source Initiative (OSI) (www.opensource.org) and/or documentation offered under an OSI or a Creative Commons license (https://creativecommons.org/licenses).

“Submit” is the act of uploading, submitting, transmitting, or distribu

@Rishit-dagli
Rishit-dagli / ML-WIth-Android-11-CLA.md
Created September 23, 2020 01:01
CLA for ML With Android 11 repo

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”), and conveys certain license rights to Rishit Dagli for Your contributions to Rishit Dagli's open source projects. This Agreement is effective upon Your acknowledgment via the CLA Assistant tool. All prospective contributors to Rishit Dagli's open source projects must sign this Agreement (digitally or otherwise) before any changes will be merged.

1. Definitions.

“Code” means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to Rishit Dagli under this Agreement.

“Project” means any of the projects owned or managed by Rishit Dagli in which software is offered under a license approved by the Open Source Initiative (OSI) (www.opensource.org) and/or documentation offered under an OSI or a Creative Commons license (https://creativecommons.org/licenses).

“Submit” is the act of uploading, submitting, transmitting, or distribu