- On-Device Machine Learning In Android: Frameworks and Ecosystem
- Using C/C++ in Android: A Comprehensive Guide For Beginners
- Building A Cross-Platform TFIDF Text Summarizer In Rust
- Managing Deep Learning Models Easily With TOML Configurations
glove-android
: Using GloVe Word Embeddings for NLP In Android- Chaquopy: Using Python In Android Apps
- [Using Websockets To Run Termin
This file contains 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
private lateinit var activityMainBinding : ActivityMainBinding | |
private lateinit var progressDialog : ProgressDialog | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
activityMainBinding = ActivityMainBinding.inflate( layoutInflater ) | |
setContentView( activityMainBinding.root ) | |
progressDialog = ProgressDialog( this ) |
This file contains 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
from flask import Flask , jsonify , request | |
from PIL import Image | |
import tensorflow as tf | |
import numpy as np | |
import base64 | |
import io | |
# Loading the Keras model to perform inference | |
# Download the model from this release -> | |
# https://github.com/shubham0204/Age-Gender_Estimation_TF-Android/releases/tag/v1.0 |
This file contains 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 math | |
import matplotlib.pyplot as plt | |
def poisson( lambda_ , x ): | |
return ( (lambda_)**x * math.exp(-lambda_) ) / math.factorial(x) | |
x = [] | |
y = [] | |
for i in range( 100 ): | |
x.append( i ) |
This file contains 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
hidden_dims = 128 | |
token_mixing_mlp_dims = 64 | |
channel_mixing_mlp_dims = 128 | |
patch_size = 9 | |
num_classes = 10 | |
num_mixer_layers = 4 | |
input_image_shape = ( 32 , 32 , 3 ) | |
inputs = tf.keras.layers.Input( shape=input_image_shape ) |
This file contains 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
hidden_dims = 128 | |
token_mixing_mlp_dims = 64 | |
channel_mixing_mlp_dims = 128 | |
patch_size = 9 | |
num_classes = 10 | |
num_mixer_layers = 4 | |
reshape_image_dim = 72 | |
input_image_shape = ( 32 , 32 , 3 ) | |
inputs = tf.keras.layers.Input( shape=input_image_shape ) |
This file contains 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
# Mixer layer consisting of token mixing MLPs and channel mixing MLPs | |
# input shape -> ( batch_size , channels , num_patches ) | |
# output shape -> ( batch_size , channels , num_patches ) | |
def mixer( x , token_mixing_mlp_dims , channel_mixing_mlp_dims ): | |
# inputs x of are of shape ( batch_size , num_patches , channels ) | |
# Note: "channels" is used instead of "embedding_dims" | |
# Add token mixing MLPs | |
token_mixing_out = token_mixing( x , token_mixing_mlp_dims ) | |
# Shape of token_mixing_out -> ( batch_size , channels , num_patches ) |
This file contains 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
# Channel Mixing MLPs : Allow communication within channels ( features of embeddings ) | |
def channel_mixing( x , channel_mixing_mlp_dims ): | |
# x is a tensor of shape ( batch_size , num_patches , channels ) | |
x = tf.keras.layers.LayerNormalization( epsilon=1e-6 )( x ) | |
x = mlp( x , channel_mixing_mlp_dims ) | |
return x |
This file contains 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
# Token Mixing MLPs : Allow communication within patches. | |
def token_mixing( x , token_mixing_mlp_dims ): | |
# x is a tensor of shape ( batch_size , num_patches , channels ) | |
x = tf.keras.layers.LayerNormalization( epsilon=1e-6 )( x ) | |
x = tf.keras.layers.Permute( dims=[ 2 , 1 ] )( x ) | |
# After transposition, shape of x -> ( batch_size , channels , num_patches ) | |
x = mlp( x , token_mixing_mlp_dims ) | |
return x |
This file contains 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
# Multilayer Perceptron with GeLU ( Gaussian Linear Units ) activation | |
def mlp( x , hidden_dims ): | |
y = tf.keras.layers.Dense( hidden_dims )( x ) | |
y = tf.nn.gelu( y ) | |
y = tf.keras.layers.Dense( x.shape[ -1 ] )( y ) | |
y = tf.keras.layers.Dropout( 0.4 )( y ) | |
return y |