Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3
"""
DOES NOT WORK because requests (and requests_cache) are blocking, if you have some ideas..
https://stackoverflow.com/questions/52246796/await-a-method-and-assign-a-variable-to-the-returned-value-with-asyncio
"""
import asyncio
import re
#!/usr/bin/python3
import argparse
from PIL import Image, ExifTags
# Given the training index file and a maximum size (used as width and height)
# Resize anything larger than these and rewrite their scaled bbox information
# ALSO - always rotates the image if there is EXIF data!
import glob
import sys

Some machine learning image cleanup tricks

Print files larger than some size

identify -format '%f|%w|%h\n' *|awk -F\| ' $3> 512 || $3 > 512'

856x642-manual-0fc7abf38681f7195e0588643037a7a7.jpg|856|642
856x642-manual-4bcae3ee8401e05c1da869e2ce0f154f.jpg|856|642
856x642-manual-5b9e571e0a4638cee70a92865d97bedd.jpg|856|642
@dgtlmoon
dgtlmoon / script.sh
Last active June 29, 2020 19:31
deepdetect vgg16 finetune (before simsearch with finetuned weights)
#!/bin/bash
#change base_lr
curl -X DELETE "http://localhost:8080/services/tag_detect_vgg16?clear=all"
sleep 1
docker stop dd_tags
docker rm dd_tags
chmod -R 777 models
nvidia-docker run --name dd_tags -d -p 8080:8080 -v "`pwd`":/tags_dataset jolibrain/deepdetect_gpu
#!/bin/bash
curl -X PUT "http://localhost:8080/services/artwork_detect_vgg16" -d '{
"mllib": "caffe",
"description": "detector vgg16",
"type": "supervised",
"parameters": {
"input": {
"connector": "image",
"db": true,
#!/bin/bash
#change base_lr
#note nclasses bases+count
curl -X DELETE "http://localhost:8080/services/tag_detect?clear=all"
sleep 1
docker stop dd_tags
docker rm dd_tags
@dgtlmoon
dgtlmoon / example.py
Created March 16, 2020 09:49
Snippet convert JPEG/etc to WEBP
#!/usr/bin/python3
def image_to_webp(src, dest):
import webp
import io
from PIL import Image
# @todo Maybe there's a better way to load this as a stream instead of into RAM, tho my images are all small.
with open(src, "rb") as r:
rb = r.read()
server {
server_name example.com;
root /var/www/drupal8; ## <-- Your only path reference.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
#!/bin/bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update && apt-get remove docker docker-engine docker.io -y
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title>Gallery</title>
<link rel="stylesheet" href="css/blueimp-gallery.css">
<link rel="stylesheet" href="css/blueimp-gallery-indicator.css">