Skip to content

Instantly share code, notes, and snippets.

View victormurcia's full-sized avatar
😀
Playing with data :]

Victor Murcia victormurcia

😀
Playing with data :]
View GitHub Profile
@victormurcia
victormurcia / fetch_pubmed_data.py
Last active August 4, 2023 13:48
Get information for a given term using Pubmed
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:
@victormurcia
victormurcia / makePokemonFromPokedex.py
Created January 12, 2023 01:28
make Pokemon From Pokedex
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
@victormurcia
victormurcia / create_art_fromStableAI.py
Created January 12, 2023 01:24
create art using stable AI
remove_safety = False
num_images = 4
if remove_safety:
negative_prompt = None
else:
negative_prompt = "nude, naked"
images = pipe(
prompt,
@victormurcia
victormurcia / setup_StableDiffusionPipeline.py
Created January 12, 2023 01:22
code to setup Stable Diffusion pipeline
import mediapy as media
import torch
from diffusers import StableDiffusionPipeline
device = "cuda"
if model_id.startswith("stabilityai/"):
model_revision = "fp16"
else:
model_revision = None
@victormurcia
victormurcia / face_eye_detect.py
Created January 9, 2023 03:46
detect faces and eyes simultaneously with opencv
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
@victormurcia
victormurcia / face_detect.py
Created January 9, 2023 03:20
detect face using opencv with webcam
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
@victormurcia
victormurcia / get_blade_angle.py
Created October 30, 2022 00:29
get blade angle w.r.t. substrate
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)
@victormurcia
victormurcia / get_pixel_coords.py
Created October 29, 2022 23:26
get_pixel_coords for blade coater alignment
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
@victormurcia
victormurcia / load_bc_image.py
Created October 29, 2022 23:13
load bc image
#Get the image from the current working directory
img_name = glob.glob('*.jpg')[0]
#Load the image into my working environment
img = cv2.imread(img_name)
#Show the image
plt.imshow(img)
@victormurcia
victormurcia / color_clustering_GUI.py
Last active October 21, 2022 03:36
gui for viz of clustering results
#Make image bigger
def makeBigger(img):
dim = (300, 200) #(width, height)
# resize image
resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)
return resized
# empty function called when trackbar moves
def emptyFunction():