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
inflect | |
librosa==0.9.2 | |
matplotlib | |
numpy | |
Pillow | |
PyQt5 | |
scikit-learn | |
scipy | |
sounddevice | |
SoundFile==0.10.3.post1 |
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 Crypto.Cipher import AES | |
from Crypto.Random import get_random_bytes | |
import base64 | |
def encrypt_aes_gcm(plaintext, key): | |
cipher = AES.new(key, AES.MODE_GCM) | |
ciphertext, tag = cipher.encrypt_and_digest(plaintext) | |
return ciphertext, cipher.nonce, tag | |
# Example usage |
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
//Function to get to convert to bytes the base64 values from python | |
function base64ToUint8Array(base64) { | |
var binaryString = atob(base64); | |
var len = binaryString.length; | |
var bytes = new Uint8Array(len); | |
for (var i = 0; i < len; i++) { | |
bytes[i] = binaryString.charCodeAt(i); | |
} | |
return bytes; |
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
with torch.no_grad(): | |
for idx, (image, _) in enumerate( | |
tqdm(loader, desc="Create embeddings matrix", total=len(loader)), | |
): | |
embeddings = np.empty([1,512]) | |
embeddings[int(0) :] = F.normalize(backbone(image.to(device))).cpu() | |
image = image[0].permute(1,2,0) | |
imgarr = image.cpu().detach().numpy() | |
print(imgarr.dtype) | |
opencvImage = cv2.cvtColor(imgarr, cv2.COLOR_RGB2BGR) |
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
# get embedding for each face | |
embeddings = np.zeros([len(loader.dataset), embedding_size]) | |
with torch.no_grad(): | |
for idx, (image, _) in enumerate( | |
tqdm(loader, desc="Create embeddings matrix", total=len(loader)), | |
): | |
print(idx) | |
embeddings[idx, :] = F.normalize(backbone(image.to(device))).cpu() | |
tensor_to_pil = transforms.ToPILImage()(image.squeeze_(0)).convert('RGB') | |
tensor_to_pil.show() |
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
tensor_to_pil = transforms.ToPILImage()(tensor) | |
tensor_to_pil.show() |
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
#Base Image | |
print("Image Dtype:", np.array(image).dtype) | |
print("Image shape:", np.array(image).shape) | |
print('***********') | |
#Tensor image | |
print("Tensor Dtype:", tensor.dtype) | |
print("Tensor shape:", tensor.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
import torch | |
import numpy as np | |
import cv2 | |
import torchvision.transforms as transforms | |
from PIL import Image | |
# Read the image with openCV | |
# image = cv2.imread('sachadee.jpg') | |
# Convert BGR image to RGB image |
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 base64 | |
from Crypto.Cipher import AES | |
from Crypto.Util.Padding import pad,unpad | |
from Crypto.Random import get_random_bytes | |
#CBC mode with random IV | |
data = 'I love Medium' | |
key = 'AAAAAAAAAAAAAAAA' #16 char for AES128 |
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 base64 | |
from Crypto.Cipher import AES | |
from Crypto.Util.Padding import pad,unpad | |
#CBC with Fix IV | |
data = 'I love Medium' | |
key = 'AAAAAAAAAAAAAAAA' #16 char for AES128 | |
#FIX IV |
NewerOlder