Skip to content

Instantly share code, notes, and snippets.

View afrendeiro's full-sized avatar

André F. Rendeiro afrendeiro

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! python3.7
import argparse
import os
import numpy as np
import speech_recognition as sr
import whisper
import torch
from datetime import datetime, timedelta
@afrendeiro
afrendeiro / rendeiro_Nature_2021_covid19_paper.geomx_diff_expression.py
Last active March 19, 2024 10:02
Re-analyze GeoMx data from Rendeiro et al. 2021 doi:s41586-021-03475-6
"""
Re-analyze GeoMx data from Rendeiro et al. 2021 doi:s41586-021-03475-6
Requirements (Python 3.10+):
pip install \
"anndata" \
"matplotlib>=3.8.3" \
"numpy>=1.26.4" \
"pandas>=2.1.0" \
"scanpy" \
@afrendeiro
afrendeiro / gdrive_download.py
Last active February 20, 2024 09:45
Download file given Google Drive URL
"""
Download file from Google Drive URL
"""
import os
import time
import click
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options as FirefoxOptions
oil saturated polyunsaturated (omega 3 & 6) monounsaturated trans fat other fat omega 3 omega 6 yield, litres per hectare smoke point flavour cooking conditions
almond 0.08 0.17 0.7 0.0 0.05 0.0 0.17 1380 230 2 >230 °C (Deep-frying)
beef tallow 0.5 0.04 0.42 0.0 0.04 0.01 0.03 - 220 1 200-229 °C (Stir-frying)
flaxseed 0.09 0.66 0.2 0.0 0.05 0.59 0.13 506 107 2 <150 °C (Dressings)
apricot kernel 0.06 0.29 0.6 0.0 0.05 0.0 0.29 680 257 0 >230 °C (Deep-frying)
argan 0.18 0.37 0.43 0.0 0.02 0.02 0.35 0.06 218 2 200-229 °C (Stir-frying)
avocado 0.12 0.14 0.71 0.0 0.03 0.01 0.13 2638 269 1 >230 °C (Deep-frying)
brazil nut 0.25 0.36 0.39 0.0 0.0 0.0 0.36 2392 195 2 150-199 °C (Light saute)
butter 0.51 0.03 0.21 0.033 0.25 0.0 0.03 - 167 2 150-199 °C (Light saute)
butter, clarified (ghee) 0.65 0.03 0.32 0.0 0.0 0.0 0.03 - 235 2 >230 °C (Deep-frying)
@afrendeiro
afrendeiro / test_nuclei_dataloaders.py
Last active November 21, 2023 17:46
Use torch dataloaders with nuclei coordinates for training.
"""
Use dataloaders with nuclei coordinates for training.
"""
from functools import partial
import requests
import h5py
from tqdm import tqdm
import numpy as np
@afrendeiro
afrendeiro / rasterize_pdf.sh
Created October 30, 2023 08:37
Rasterize PDF files
#!/bin/bash
# Terminate on first error
set -e
# Check if input file is provided
if [ -z "$1" ]; then
echo "Usage: $0 <input_file.pdf>"
exit 1
fi
@afrendeiro
afrendeiro / test_gpus_accelerate.py
Created July 24, 2023 08:11
Multi-GPU training with hf-accelerate
#!/usr/bin/env python
"""
A simple example of how to use the Accelerator API
to train a vision model on a dummy dataset.
Accelerator enables training on a single or multiple GPUs.
Run once `accelerate config` to set up your configuration file.
@afrendeiro
afrendeiro / quantization_experiments.py
Last active March 9, 2023 15:36
Run experiments on different quantization settings and report speedup and error.
"""
Run the experiments for the quantization speedup and plot results.
"""
import subprocess
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
@afrendeiro
afrendeiro / fix_indica_tiff.py
Last active June 30, 2022 15:26
Read IndicaLabs TIFF files (exported from HALO) and write TIFF file.
"""
Convert a TIFF file generated by IndicaLabs (HALO) to a usable TIFF file.
"""
import typing as tp
from pathlib import Path
from xml.etree import ElementTree
import tifffile
from tifffile.tiffcomment import tiffcomment