Skip to content

Instantly share code, notes, and snippets.

View sergiolucero's full-sized avatar
coding the days away

Sergio Lucero sergiolucero

coding the days away
View GitHub Profile
sergiolucero / failed_transformer
Created March 31, 2023 11:25
¿Por qué diantres no funciona esto?
from transformers import AutoTokenizer, AutoModelForQuestionAnswering, Trainer,
TrainingArguments, default_data_collator
import datasets
model_name = 'dccuchile/bert-base-spanish-wwm-cased'
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForQuestionAnswering.from_pretrained(model_name)
train_data = datasets.load_dataset('squad_es', 'v1.1.0', split='train[:80%]')
sergiolucero / dcm_plotter
Last active August 9, 2022 02:26
view dcm folder
import pydicom as dicom
import matplotlib.pylab as plt
import glob
for a, file in zip(range(rows*cols),glob.glob('*.dcm')):
axes.append( fig.add_subplot(rows, cols, a+1) )
sergiolucero /
Created July 24, 2022 22:31
concatenate and merge a list of PDF files
import glob
from PyPDF2 import PdfFileMerger
merger = PdfFileMerger()
for fn in glob.glob('*.pdf'):
import glob
import cv2
images = glob.glob('Plot*.png')
print('nImages:', len(images))
height, width, layers = cv2.imread(images[0]).shape
video = cv2.VideoWriter('video.avi', 0, 1, (width,height))
for image in images:
from diagrams import Diagram, Cluster
from import EC2
from import ELB
from import Route53
from diagrams.onprem.database import PostgreSQL # Would typically use RDS from aws.database
from diagrams.onprem.inmemory import Redis # Would typically use ElastiCache from aws.database
with Diagram("Simple Website Diagram", direction='LR') as diag: # It's LR by default, but you have a few options with the orientation
dns = Route53("dns")
load_balancer = ELB("Load Balancer")
sergiolucero /
Last active June 22, 2022 01:04
descarga revistas La Bicicleta
import wget, fitz, glob
import requests, time
from bs4 import BeautifulSoup
bs = BeautifulSoup(requests.get(url).text, 'lxml')
links = [link['href'] for link in bs.find_all('a')
if '.pdf' in link.get('href','')]
sergiolucero /
Created June 9, 2022 17:35
aire región Concón-Quintero-Puchuncaví
import openaq
import pandas as pd
api = openaq.OpenAQ() # fuente:
cdf = api.cities(country='CL', df=True)
cdf = cdf[['Quintero','Concón','Puchuncaví'])]
xdf = pd.concat([api.measurements(city=city, df=True, limit=1000)
for city in])
import geopandas as gp
import time
hdf=gp.read_file('Humedales', encoding='utf-8')
#hdf.set_crs(epsg=4326, inplace=True)
#hdf=hdf.to_crs(epsg=4326) # doesn not work for every region!
sergiolucero / pecos
Created May 1, 2022 11:04
idioma chileno según Pecos Paul Kele
import tts
imagen = read('github/pecos.png')
texto = tts(imagen)
sergiolucero /
Created April 6, 2022 21:29
make video from pictures
import cv2, glob
import numpy as np
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # choose codec according to needed format
video = cv2.VideoWriter('video.avi', fourcc, 1, (width, height))
for fn in glob.glob('*.png'):
img = cv2.imread(fn)