Skip to content

Instantly share code, notes, and snippets.

View ola0x's full-sized avatar
🏠
Working from home

Olanrewaju Ola ola0x

🏠
Working from home
View GitHub Profile
@ola0x
ola0x / boto.py
Created January 24, 2023 23:25
example of deploying a model to SageMaker using the Boto3 SDK for Python
#Prepare and upload your model artifacts to an Amazon S3 bucket. The bucket must be in the same region as the SageMaker endpoint you will create.
#Create an IAM role with the necessary permissions for SageMaker to access the S3 bucket and other AWS services on your behalf.
#Use the AWS SDK for Python (Boto3) to create a SageMaker model resource. The model resource describes the location of the model artifacts and the Docker image containing the inference code.
#Create an endpoint configuration, which defines the resources that SageMaker should use when hosting the endpoint. This includes the number and type of instances to use, and the configurations for the model and the data processing.
#Use the endpoint configuration to create an endpoint. This deploys the model and makes it available for inference.
@ola0x
ola0x / jupyter_notebook.sh
Last active October 27, 2022 06:22
Run Jupyter notebook on P3 ec2 machine
pip3 install --upgrade pip
pip3 install jupyter
jupyter notebook
goto http://127.0.0.1:8888
@ola0x
ola0x / hot.md
Last active June 7, 2022 18:42
How to install argo on windows
  • Go to this link https://github.com/argoproj/argo-workflows/releases and download argo-windows-amd64.exe.gz
  • unzip argo-windows-amd64.exe.gz
  • rename argo-windows-amd64.exe to argo.exe
  • add the folder path to system path
  • open a new terminal and type argo version
# Python program to rename all file
# names in your directory
import os
os.chdir(r'C:\Users\oolaonipekun\Desktop\Car_damage_detection\data\validation\whole')
print(os.getcwd())
COUNT = 1
# Function to increment count
# to make the files sorted.
import os
import glob
import json
import numpy as np
import pandas as pd
import xml.etree.ElementTree as ET
save_json_path = 'val_coco.json'
def xml_to_csv(path):
import os
import re
from PIL import Image
folder_holding_yolo_files = "C:\\Users\\oolaonipekun\\Desktop\\ActionRecognition\\actionnet_yolo\\actionnet_yolo\\validation"
yolo_class_list_file = "classes.txt"
# Get a list of all the classes used in the yolo format
with open(yolo_class_list_file) as f:
yolo_classes = f.readlines()
@ola0x
ola0x / move_pair_xml_jpg.py
Created March 24, 2022 23:27
copy xml file and image jpg with the same name
import os
import shutil
dir_path = "data"
files = os.listdir(dir_path)
path = os.getcwd()
olddir_path = os.path.join(path, dir_path)
newpath = os.path.join(path,"newdata")
print(newpath)
print(olddir_path)
import cv2
import sys
image = sys.argv[1]
image = cv2.imread(image)
gray_img = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
faces = faceCascade.detectMultiScale(
gray_img,
@ola0x
ola0x / create_pad_for_crop_img.py
Created March 24, 2022 21:56
this is to creata a pad around the image if the crop bbox is less than the origin or grater than the image width and height.
import cv2
def pad_img_to_fit_bbox(img, x1, x2, y1, y2):
img = cv2.copyMakeBorder(img, - min(0, y1), max(y2 - img.shape[0], 0),
-min(0, x1), max(x2 - img.shape[1], 0),cv2.BORDER_REPLICATE)
y2 += -min(0, y1)
y1 += -min(0, y1)
x2 += -min(0, x1)
x1 += -min(0, x1)
return img, x1, x2, y1, y2
from imutils import paths
import cv2
import numpy as np
import argparse
import imutils
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--images", type=str, required=True,
help="path to input directory of images to stitch")
ap.add_argument("-o", "--output", type=str, required=True,