Skip to content

Instantly share code, notes, and snippets.

@alonlavian
alonlavian / alon-lavian.json
Created May 23, 2023 11:38
Jsoned linkedin profile
{
"public_identifier": "alon-lavian",
"profile_pic_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/alon-lavian/profile?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230523%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230523T111453Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=cf270c9149d667b4e1b2124e815f02e1380f03388632b834dfc9c83798e75eb6",
"background_cover_image_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/alon-lavian/cover?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230523%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230523T111453Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=4fd51e1f1feb5235fafad3a69fefb5c0f4a1b9008a0a036254cc0f7311f2e202",
"first_name": "Alon",
"last_name": "Lavian",
"full_name": "Alon Lavian",
"follower_count": null,
"occupation": "Director of Product Management at Orca Security",
"headline": "Director, Product Management
@alonlavian
alonlavian / vpc-inside.py
Created August 7, 2022 08:09
Describe resources inside an AWS VPC
import logging
import boto3
from argparse import ArgumentParser, HelpFormatter
from botocore.exceptions import ClientError, ProfileNotFound
# logger config
logger = logging.getLogger()
logging.basicConfig(level=logging.INFO,
format='%(message)s')
import logging
import boto3
from argparse import ArgumentParser, HelpFormatter
from botocore.exceptions import ClientError, ProfileNotFound
# from botocore.errorfactory import UnauthorizedException
# logger config
logger = logging.getLogger()
logging.basicConfig(level=logging.INFO,
architecting.with.gke.workloads.kubernetes.io/safe-to-evict": "true"
from tensorflow.keras.applications.vgg16 import VGG16
from tensorflow.keras import layers
from tensorflow.keras.models import Model
base_model = VGG16(weights='imagenet', #pre-trained weights
include_top=False, #remove original classifier
input_shape=(HEIGHT, WIDTH, 3))
#Freeze all layers
for layer in base_model.layers:
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(16, (3,3), activation='relu', input_shape=(HEIGHT, WIDTH, 3)),
tf.keras.layers.MaxPooling2D(2, 2),
tf.keras.layers.Conv2D(32, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1024, activation='relu'),
tf.keras.layers.Dropout(0.2),
@alonlavian
alonlavian / face_crop_library.py
Created April 28, 2019 19:32
crops all jpg in a folder and saves all cropped faces to the destination folder
original_images_dir = os.fsencode('/content/drive/My Drive/Google Photos/2019')
cropped_images_lib = '/content/drive/My Drive/CropMix/'
for path, dirs, files in os.walk(original_images_dir):
for file in files:
image_name = os.fsdecode(file)
if image_name.endswith(".jpg"):
image_path = os.path.join(path,file)
crop_faces(image_path,image_name,cropped_images_lib)
@alonlavian
alonlavian / face_crop.py
Last active April 28, 2019 19:25
Only the crop part
from PIL import Image
def crop_faces(image_path,image_name,cropped_images_lib):
with open(image_path, 'rb') as image:
faces = detect_face(image, 8)
im = Image.open(image_path)
for idx,face in enumerate(faces):
vects = face.fd_bounding_poly.vertices
@alonlavian
alonlavian / face_detect.py
Created April 24, 2019 17:40
face detection annotation with google vision
from google.cloud import vision
from google.cloud.vision import types
def detect_face(face_file, max_results=4):
client = vision.ImageAnnotatorClient()
content = face_file.read()
image = types.Image(content=content)
@alonlavian
alonlavian / credentials.py
Created April 22, 2019 12:34
Add vision credentials to env
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/content/drive/My Drive/ML/Misc/vision_service_account.json"