Skip to content

Instantly share code, notes, and snippets.

View starkfire's full-sized avatar

Pocholo Pantoja starkfire

View GitHub Profile
@starkfire
starkfire / scale-and-crop.py
Created August 15, 2023 11:47
Scale image to 1:1 ratio and crop from the center (to 256x256 for compatibility with EfficientDet)
import cv2
import argparse
from pathlib import Path
import os
def crop(img, height, width):
img_h, img_w = img.shape[0], img.shape[1]
crop_h = height if height < img_h else img_h
crop_w = width if width < img_w else img_w
@starkfire
starkfire / augment.py
Created August 15, 2023 11:25
Image Augmentation: flip images (vertically and horizontally) while preserving bounding boxes (PASCAL VOC)
import albumentations as A
import cv2
from pathlib import Path
import argparse
import xml.etree.ElementTree as ET
import shutil
import os
def augment(image, xml_file):
bboxes, labels = get_bounding_boxes_and_labels(xml_file)
"""
Make sure you have already created a .tar file for the files you want to export from Colab.
!tar -czvf /content/name_of_tarfile.tar.gz <files_or_directories>
"""
from google.colab import files
files.download("/content/name_of_tarfile.tar.gz")
@starkfire
starkfire / TrendAnalysis.vue
Created October 29, 2020 11:33
A snippet on how to use vuetrend
<template>
<div class="container">
<!-- just add the component -->
<trend
:data="[1,3,3,4,3,5]"
:gradient="['#6fa8dc', '#42b983', '#2c3e50']"
auto-draw
smooth
></trend>
</div>
import matplotlib.pyplot as plt
import os, json
from glob import glob
import tensorflow.keras
import tensorflow as tf
from tensorflow.keras.applications import inception_v3, vgg16
from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import Model
#include <iostream>
#include <string>
#include <regex>
using namespace std;
bool email_regex(const string& email){
const regex pattern ("(\\w+)(\\.|_|-)?(\\w*)@(\\w+)(\\.(\\w+))+");
return regex_match(email, pattern);
}
<?php
function esc_url($url){
if ('' == $url) {
return $url;
}
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
$strip = array('%0D', '%0A', '%0d', '%0a');
$url = (string) $url;
$count = 1;
int data = 0;
void setup(){
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
Serial.println("Initializing...");
}
void loop(){
while(Serial.available()){
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
int count = '0';