Skip to content

Instantly share code, notes, and snippets.

View andreped's full-sized avatar
🐛
busy making bugs to stay employed

André Pedersen andreped

🐛
busy making bugs to stay employed
View GitHub Profile
@gmyrianthous
gmyrianthous / real_time_speech_to_text.py
Last active April 22, 2022 23:47
Real-time Speech-To-Text Tutorial - Full Code
import json
import base64
import asyncio
import pyaudio
import websockets
SAMPLE_RATE=16000
FRAMES_PER_BUFFER = 3200
API_KEY = '<your AssemblyAI Key goes here>'
@petebankhead
petebankhead / QuPath-Apply global threshold.groovy
Created November 20, 2021 17:01
QuPath script to apply a global threshold to an image channel, without relying on a saved PixelClassifier
/**
* QuPath script to threshold a single channel of an image.
* This can also be useful to convert a binary image into QuPath annotations.
*
* First written for https://forum.image.sc/t/rendering-wsi-as-overlay-on-top-of-another-wsi/52629/24?u=petebankhead
*
* @author Pete Bankhead
*/
int channel = 0 // 0-based index for the channel to threshold
from nonconformist.cp import IcpRegressor
from nonconformist.cp import IcpClassifier
from nonconformist.nc import NcFactory
import lightgbm as lgbm
# Create the underlying model
model = lgbm.LGBMRegressor()
# Default nonconformity measure
nc = NcFactory.create_nc(model)
# Inductive conformal regressor
icp = IcpRegressor(nc)
@rodydavis
rodydavis / flutter_github_ci.yml
Last active October 22, 2024 09:09
Flutter Github Actions Build and Deploy Web to Firebase Hosting, iOS to Testflight, Android to Google Play (fastlane)
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_web:
@SuperShinyEyes
SuperShinyEyes / f1_score.py
Created October 15, 2019 10:16
F1 score in PyTorch
def f1_loss(y_true:torch.Tensor, y_pred:torch.Tensor, is_training=False) -> torch.Tensor:
'''Calculate F1 score. Can work with gpu tensors
The original implmentation is written by Michal Haltuf on Kaggle.
Returns
-------
torch.Tensor
`ndim` == 1. 0 <= val <= 1
@you359
you359 / GuidedBackpropagation.py
Created August 22, 2018 04:59
Guided-Backpropagation
import keras
from keras.applications.vgg16 import VGG16
from keras.applications.vgg16 import preprocess_input, decode_predictions
from keras.preprocessing import image
import keras.backend as K
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
@didacroyo
didacroyo / ftInceptionV3.py
Last active April 21, 2024 11:44
InceptionV3 Fine Tuning with Keras
# from the guide https://blog.keras.io/building-powerful-image-classification-models-using-very-little-data.html
# and from other resources found, trying to achieve a good classifier based on Inveption V3 pre-trained netfork
from keras.applications.inception_v3 import InceptionV3
from keras.preprocessing import image
from keras.models import Model
from keras.layers import Dense, GlobalAveragePooling2D
from keras.preprocessing.image import ImageDataGenerator
from keras import backend as K
from keras.callbacks import ModelCheckpoint
Scripts mostly taken from Pete, and also from the forums. For easy access and reference.
TOC
Alignment: Several scripts to assist in alignment as of M9. Store scripts make files using the Affine transformation while
TransferObjects uses the stored file in the Affine folder with the current image name to move objects into it.
The final result is that one set of files can be generated for the transforms, and those transforms can be accessed to move objects
back and forth between the images.
Change annotations into Cell objects.groovy - Converts annotations into PathCellObjects, which allows certian functions to work within
@Svidro
Svidro / !Selecting Objects in QuPath
Last active October 15, 2024 06:06
Selecting things in QuPath
Scripts mostly taken from Pete, and also from the forums. For easy access and reference.
Covers both Selecting, which is necessary to run most commands like cell detection, and collecting objects into a variable
for processing. The latter is more efficient when you do not need to run a command like cell detection.
TOC
A Selection guide.groovy - not actually a script, just a collection of useful tips.
Access top level objects.groovy - Creates a list of all objects at the "top" of the hierarchy. This list is dynamic.
@Svidro
Svidro / !Creating Objects in QuPath
Last active October 15, 2024 06:03
Creating objects in QuPath
Collections of scripts harvested mainly from Pete, but also picked up from the forums
TOC
Annotation subtraction example.groovy - An example of creating and subtracing ROIs through scripting
Create annotation of fixed size.groovy - see https://petebankhead.github.io/qupath/scripting/2018/03/09/script-create-fixed-size-region.html
Create object based on Viewer position.groovy - Creates an object at the Viewer position. In this case a rectangle. Useful if you want
to create the exact same size object multiple times and then move it to an area of interest for subsampling.