Skip to content

Instantly share code, notes, and snippets.

View zabir-nabil's full-sized avatar
🎮
Focusing

Zabir Al Nazi Nabil zabir-nabil

🎮
Focusing
View GitHub Profile
# Speaker Experiments and MLflow
Speaker experiments take relatively long time to finish. For tracking the experiment progress, we can utilize MLflow.
### What is MLflow?
MLflow is a platform to streamline machine learning development, including tracking experiments, packaging code into reproducible runs, and sharing and deploying models. MLflow offers a set of lightweight APIs that can be used with any existing machine learning application or library (TensorFlow, PyTorch, XGBoost, etc), wherever you currently run ML code (e.g. in notebooks, standalone applications or the cloud). MLflow's current components are:
* MLflow Tracking: An API to log parameters, code, and results in machine learning experiments and compare them using an interactive UI.
* MLflow Projects: A code packaging format for reproducible runs using Conda and Docker, so you can share your ML code with others.
do-release-upgrade
# python triton client
import numpy as np
import sys
import tritonclient.grpc as grpcclient
try:
keepalive_options = grpcclient.KeepAliveOptions(
from model_ecapatdnn import ECAPAModel
import soundfile as sf
import torch
# load your pytorch model (+ weights) here
model_1 = ECAPAModel.ECAPAModel(lr = 0.001, lr_decay = 0.97, C = 1024, n_class = 18505, m = 0.2, s = 30, test_step = 3, gpu = -1)
model_1.load_parameters("/ecapatdnn/exps/finetuned/model/model_0028.model")
model = model_1.speaker_encoder # module with forward implemented
# if your forward function contains any arguments other than the input tensors, make sure to add default values
@zabir-nabil
zabir-nabil / location_country_code_lat_lon.csv
Created January 23, 2022 17:04
A list of places all around the world with location, country name, country code [alpha-2], latitude, longitude. The locations are compatible with OpenWeatherMap web APIs.
We can't make this file beautiful and searchable because it's too large.
Location,Country,Country_Code_Alpha_2,Lat,Long
A Cañiza,Spain,ES,42.216671,-8.26667
A Coruña,Spain,ES,43.371349,-8.396
A Coruña,Spain,ES,43.371262,-8.4188
A Dos Cunhados,Portugal,PT,39.156479,-9.32206
A Dos Francos,Portugal,PT,39.314468,-9.04547
A Estrada,Spain,ES,42.683331,-8.48333
A Guarda,Spain,ES,41.90131,-8.87423
A Guarda,Spain,ES,41.90403,-8.87225
A Mezquita,Spain,ES,42.013142,-7.04675
@zabir-nabil
zabir-nabil / cyberpanel-fastapi-ssl-subdomain
Created September 11, 2021 00:33
Deploying free email server, web hosting panel with CyberPanel on subdomain, FastAPI with SSL, mongoDB transfer
Deploying free email server, web hosting panel with CyberPanel on subdomain
Summary:
Let's say we have a domain "test.com". We want to install an email server for our domain, we want it free.
First make sure the droplet has no app running on port 80, 443 (or nginx, apache websites).
Install CyberPanel,
on DO, https://marketplace.digitalocean.com/apps/cyberpanel
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
@zabir-nabil
zabir-nabil / key_url.py
Created August 5, 2021 10:53
Find all the links from a list of websites and check if certain keywords are present in the homepage or not.
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome('/usr/bin/chromedriver', options=chrome_options)
ips = open("ip.txt", "r")
keywords = ["login", "denied", "username", "password", "Apache2"]
@zabir-nabil
zabir-nabil / silence_remove_segment.py
Created June 27, 2021 15:56
Silence removal from audio file (.sph to .wav conversion) and segment the file in equal duration
# author: github.com/zabir-nabil
import librosa
from pydub import AudioSegment
import pydub
import os
def segment_aud_eq(audio_segment, k):
# k denotes, seconds * 1000
a_segs = [audio_segment[i*k:min((i+1)*k, len(audio_segment)-1)] for i in range(len(audio_segment)//k)]
@zabir-nabil
zabir-nabil / opencv_bytes.py
Created February 14, 2021 12:37
OpenCV numpy image -> JPEG memory buffer -> bytes and back
import cv2
import numpy as np
import sys
img = cv2.imread('1.jpg')
print(sys.getsizeof(img))
img_encoded = cv2.imencode('.jpg', img)[1]
print(sys.getsizeof(img_encoded))
img_bytes = img_encoded.tobytes() # bytes class
# A procedure which decodes base64 image, runs some machine learning model/ operation(s) (in our case we'll just return the mean of the pixel value)
import numpy as np
import base64
import zlib
def predict(b64img_compressed, w, h):
b64decoded = base64.b64decode(b64img_compressed)
decompressed = b64decoded #zlib.decompress(b64decoded)