Skip to content

Instantly share code, notes, and snippets.

View comtom's full-sized avatar

Tomás Dowling comtom

View GitHub Profile
from PIL import Image
def resize_and_crop(img, size=(255, 255)):
img = Image.open(img)
img_ratio = img.size[0] / img.size[1]
ratio = size[0] / size[1]
if ratio > img_ratio:
img = img.resize((size[0], int(size[0] * img.size[1] / img.size[0])),
@comtom
comtom / predict.py
Last active February 29, 2020 22:36
import os
import cv2
import numpy as np
from tensorflow.python.keras.preprocessing.image import load_img, img_to_array
from tensorflow.python.keras.models import load_model
from resize import resize_and_crop
width, height = 224, 224
dimension = f'{ width }px'
@comtom
comtom / vote.py
Last active February 29, 2020 22:37
import sys
from predict import predict
def make_predictions(filename):
result = []
for i in range(3):
result.append(predict(filename, model=i))
# -*- coding: utf-8 -*-
"""Modelo_Acc+80.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1kLQn4QbQKLGSHXhAsmKrIMBcKLWHNWvg
"""
import matplotlib
<?php
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
 'dsn' => '',
 'hostname' => 'database.host.local',
 'username' => 'username',
 'password' => 'hackme',
 'database' => 'database_name',
 'dbdriver' => 'pdo',
func returnsError() error {
if bad() {
return ErrBad
}
return nil
}
func returnsError() error {
var p *MyError = nil
if bad() {
p = ErrBad
}
return p // Will always return a non-nil error.
}
package main
import "fmt"
func main() {
messages := make(chan string)
signals := make(chan bool)
select {
case msg := <-messages:
fmt.Println("received message", msg)
@comtom
comtom / pprof.bash
Last active September 27, 2018 19:44
1.sh
#!/bin/bash
go test -cpuprofile cpu.prof -memprofile mem.prof -bench .
pprof -http=:6060 -alloc_objects mem.prof
pprof -http=:6060 cpu.prof
@comtom
comtom / channels3.go
Last active September 27, 2018 19:31
import "golang.org/x/sync/errgroup"
...
g, ctx := errgroup.WithContext(ctx)
complete := make(chan []Store, len(locations))
for _, location := range locations {
g.Go(fetchStores(ctx, store.Id, complete))
}
if err := g.Wait(); err != nil {
log.Errorf("%s", err)