Skip to content

Instantly share code, notes, and snippets.

View aryan-f's full-sized avatar
✈️
Hopeful

Aryan Farahmand aryan-f

✈️
Hopeful
View GitHub Profile
@aryan-f
aryan-f / mediapipe-cuda-python-manjaro.md
Last active October 17, 2021 17:43
How to Build MediaPipe Python Package for CUDA on Manjaro

Step 0: Install Bazel 3.7.2: You could build from source. But there was an issue with openjdk that I just didn't bother to look into.

pamac install bazel3-bin

Step 1: Install CUDA and cuDNN. You can find the exact versions TensorFlow supports here here. As of the time of writing this report, if you've installed proprietary drivers when installing the OS, you'll have to run the following commands in Manjaro:

@aryan-f
aryan-f / trigger.py
Created January 26, 2021 08:21
Python AsyncIO Synchronization Primitive, similar to Event, but one call to set() lets the task waiting on it to run only once. I implemented this for my own program to trigger several tasks from a common dependency.
import asyncio
import collections
class Trigger:
"""Asynchronous synchronization primitive for triggering groups of tasks.
The class borrows much of its implementation from `asyncio.Event`. However, it gets rid of the internal flag, so
that whenever another coroutine waits on it, it can only be awakened with an explicit "new" call to `set()`. If
another waits on the task in a loop, one call to `set()` let's it run for a single iteration.
@aryan-f
aryan-f / pytorch041_cuda92_colab.sh
Last active July 2, 2020 16:40 — forked from Con-Mi/pytorch041_cuda92_colab.sh
Shell Script for Installing PyTorch 0.4.1, Compatible Torch Vision (0.2.1), and CUDA 9.2 on Google Colab.
#!/bin/bash
TEXT_RESET='\e[0m'
TEXT_YELLOW='\e[1;33m'
wget https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64
echo -e $TEXT_YELLOW
echo 'WEBGET finished..'
echo -e $TEXT_RESET
@aryan-f
aryan-f / scaler.py
Last active January 11, 2024 11:43
Standard Scaler for PyTorch Tensors
import torch
class StandardScaler:
def __init__(self, mean=None, std=None, epsilon=1e-7):
"""Standard Scaler.
The class can be used to normalize PyTorch Tensors using native functions. The module does not expect the
tensors to be of any specific shape; as long as the features are the last dimension in the tensor, the module
@aryan-f
aryan-f / distribution-histogram.py
Created August 2, 2019 18:47
A little code to plot a histogram of some data in order to investigate its distribution.
import numpy as np
import matplotlib.pyplot as plt
# Store your values inside the 'values' variable as a iteratable (i.e. list)
# I'll just use some random numbers instead
values = np.random.normal(size=10000)
# The line below renders the chart and saves it to memory
# 50 is the number of bins, density scales the chart so the area under the graph would be 1, the other two are just some appearance controls
n, bins, patches = plt.hist(values, 50, density=True, facecolor='g', alpha=0.75)