This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def estimate_n_speakers_nmf(features, max_speakers, min_speakers): | |
""" | |
Estimate number of speakers using NMF reconstruction error and stability analysis. | |
""" | |
reconstruction_errors = [] | |
stability_scores = [] | |
# Run NMF multiple times for each number of components | |
for n in range(min_speakers, max_speakers + 1): | |
errors = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def diarize_audio(audio_path, method='nmf', min_segment_duration=1.0, max_speakers=8, min_speakers=1): | |
""" | |
Diarization workflow with automatic speaker count estimation. | |
Parameters: | |
----------- | |
audio_path : str | |
Path to the audio file | |
method : str | |
Diarization method ('nmf' or 'ica') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Bio import Entrez | |
from Bio.Medline import parse | |
from io import StringIO | |
import pandas as pd | |
def fetch_pubmed_data(search_term, email, retmax=100): | |
""" | |
Fetches data from PubMed related to a specific search term. | |
Parameters: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def makePokemonFromPokedex(ver,nPokemon): | |
#Loop over nPokemons to get the descritptions and generate images for each | |
#poke_id = 1 | |
for poke_id in range(1, nPokemon+1, 1): | |
#print(poke_id) | |
#Specify which Pokemon we want to query using its ID number | |
pokemon = pypokedex.get(dex=poke_id) | |
#print(pokemon) | |
#This is the name of the Pokemon we are querying |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remove_safety = False | |
num_images = 4 | |
if remove_safety: | |
negative_prompt = None | |
else: | |
negative_prompt = "nude, naked" | |
images = pipe( | |
prompt, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mediapy as media | |
import torch | |
from diffusers import StableDiffusionPipeline | |
device = "cuda" | |
if model_id.startswith("stabilityai/"): | |
model_revision = "fp16" | |
else: | |
model_revision = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def objectTracker2(facePath, eyePath): | |
faceCascade = cv2.CascadeClassifier(facePath) | |
eyeCascade = cv2.CascadeClassifier(eyePath) | |
cv2.namedWindow("preview") | |
vc = cv2.VideoCapture(0) | |
while True: # try to get the first frame | |
rval, frame = vc.read() | |
# Capture frame-by-frame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def objectTracker1(cascPath): | |
faceCascade = cv2.CascadeClassifier(cascPath) | |
cv2.namedWindow("preview") | |
vc = cv2.VideoCapture(0) | |
while True: # try to get the first frame | |
rval, frame = vc.read() | |
# Capture frame-by-frame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_angle(): | |
#Get line coordinates | |
x1 = cs.points[0][0];y1 = cs.points[0][1] | |
x2 = cs.points[1][0];y2 = cs.points[1][1] | |
x3 = cs.points[2][0];y3 = cs.points[2][1] | |
x4 = cs.points[3][0];y4 = cs.points[3][1] | |
#Use coordinates to get components of vectors | |
vx1 = (x1-x2);vy1 = (y1-y2) | |
vx2 = (x4-x3);vy2 = (y4-y3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StoreCoordinates: | |
def __init__(self): | |
self.points = [] | |
def select_point(self,event,x,y,flags,param): | |
if event == cv2.EVENT_LBUTTONDOWN: | |
# Display the clicked coordinates on shell | |
print(x, ' ', y) | |
# displaying the coordinates on the image window |
NewerOlder