Skip to content

Instantly share code, notes, and snippets.

View ialhashim's full-sized avatar

Ibraheem Alhashim ialhashim

View GitHub Profile
@ialhashim
ialhashim / color_vibrance.py
Last active January 3, 2023 08:14
Apply color vibrance adjustments
# Copy from https://github.com/bbonik/image_enhancement/blob/f0c286a166443202d592b920b63ee6901a0ee727/source/image_enhancement.py#L1388
import numpy as np
from skimage import img_as_float
def change_color_saturation(
image_color,
image_ph_mask=None,
sat_degree=1.5,):
LOCAL_BOOST = 0.2
@ialhashim
ialhashim / split_predict_batches.py
Created January 15, 2023 07:30
Split images into square patches
def split_to_batches(img, trained_size=512):
img = skimage.img_as_float32(img)
direction = 'landscape'
if img.shape[0] > img.shape[1]: direction = 'portrait'
# resize into 512x[width|height]
width, height = img.shape[1], img.shape[0]
if direction == 'landscape':
new_height = trained_size
new_width = int(new_height * (width / height))
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba && mkdir -p ~/micromamba && mv bin/micromamba ~/micromamba/ && ~/micromamba/micromamba shell init -s bash -y && echo "alias conda='micromamba'" >> ~/.bashrc && source ~/.bashrc
@ialhashim
ialhashim / pt.sh
Created June 29, 2025 10:40
standard pytorch
conda create -n pt python=3.11 -y && conda activate pt && pip install tqdm codetiming glances[all] torch torchvision pillow