Skip to content

Instantly share code, notes, and snippets.

View CleanPegasus's full-sized avatar
🐍
Focusing

Arun CleanPegasus

🐍
Focusing
View GitHub Profile
@CleanPegasus
CleanPegasus / credit_proof.circom
Last active September 17, 2023 21:00
zk-snark for credit proof
pragma circom 2.0.0;
include "../node_modules/circomlib/circuits/poseidon.circom";
include "../node_modules/circomlib/circuits/comparators.circom";
include "../node_modules/circomlib/circuits/gates.circom";
template CreditProof() {
signal input creditScore;
signal input minCreditScore;
signal input maxCreditScore;
@CleanPegasus
CleanPegasus / age_proof.circom
Last active September 17, 2023 21:04
ZK-SNARK for age proof
pragma circom 2.0.0;
include "../node_modules/circomlib/circuits/poseidon.circom";
include "../node_modules/circomlib/circuits/comparators.circom";
template AgeProof() {
signal input doBTimestamp; // Timestamp of the DoB in seconds
signal input address; // Address of the user
signal input currentTimestamp; // Current time in seconds
@CleanPegasus
CleanPegasus / DIdentity.sol
Last active September 17, 2023 21:08
Soul Bond Token for Decentralised Identity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
contract DIdentity is Ownable {
struct Identity {
bytes32 UID;
bytes32 nameHash; // keccak256 hash of name
from tensordash.tensordash import Customdash
histories = Customdash(
ModelName = '<YOUR_MODEL_NAME>',
email = '<YOUR_EMAIL_ID>',
password = '<YOUR PASSWORD>')
try:
for epoch in range(num_epochs):
from tensordash.fastdash import Fastdash
my_cb = Tensordash(
ModelName = '<YOUR_MODEL_NAME>',
email = '<YOUR_EMAIL_ID>',
password = '<YOUR PASSWORD>')
try:
learn.fit(epochs, learning_rate, callbacks = my_cb)
except:
from tensordash.torchdash import Torchdash
histories = Torchdash(
ModelName = '<YOUR_MODEL_NAME>',
email = '<YOUR_EMAIL_ID>',
password = '<YOUR PASSWORD>')
try:
for epoch in range(epochs):
losses = []
from tensordash.tensordash import Tensordash
histories = Tensordash(
ModelName = '<YOUR_MODEL_NAME>',
email = '<YOUR_EMAIL_ID>',
password = '<YOUR PASSWORD>')
try:
model.fit(
X_train,
import tensorflow as tf
def sample(x, y, z):
return tf.reduce_sum(x + y * z)
@CleanPegasus
CleanPegasus / predict_server.py
Created September 28, 2020 07:57
Get the prediction from the served model
import requests
import json
EMOTIONS = ["angry", "disgust", "scared", "happy", "sad", "surprised", "neutral"] # Emotions corresponding to the output
data = json.dumps({"signature_name": "serving_default", "instances": img.tolist()}) # making the input in the format required for serving
headers = {"content-type": "application/json"} # specifying that the input will be in json format
json_response = requests.post('http://localhost:8501/v1/models/emotion_model:predict', data=data, headers=headers) # post request to the served model
predictions = json.loads(json_response.text)['predictions'] # getting the predictions
@CleanPegasus
CleanPegasus / emotion_img_preprocess.py
Created September 28, 2020 07:53
Preprocessing the image before predicting
img = cv2.imread('img.jpg') # reading the image
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # converting the image to grayscale
img = cv2.resize(img, (48, 48)) # resizing the image
img = img/255 # normalizing the image
img = np.reshape(img, [-1, 48, 48, 1]) # reshaping the image to be suitable for serving