Skip to content

Instantly share code, notes, and snippets.

Avatar
Electrifying my brain

Patrice Ferlet metal3d

Electrifying my brain
View GitHub Profile
@metal3d
metal3d / manual-classification.py
Created Jun 28, 2021
Manual classification to a target directory to "good" and "bad" images
View manual-classification.py
""" UI to manually class bad/good images """
import os
import sys
from glob import glob
import cv2 as cv
directory = sys.argv[1]
if not directory:
sys.exit(1)
@metal3d
metal3d / train.py
Created Jun 28, 2021
Script to train a binary model to help on creating dataset
View train.py
""" Train model and find bad image from a directory """
import argparse
import os
import time
from glob import glob
from typing import Any
import numpy as np
from tensorflow.python.keras.layers.pooling import MaxPool2D
@metal3d
metal3d / Info
Created Jun 16, 2021
Countries coordinates with longitude and latitude
View Info
Based on https://gist.github.com/tadast/8827699:
- remove duplicates
- striped and no unecessary double quotes
- floating point values instead of strings
View make editable vars in html.html
<html>
<meta charset="utf-8" />
<body>
<pre>
<code>
# All you have to do is to prefix variables with "_change_"
# and let the script to manage the editable values
FOO="_change_thisvariable"
this is a command with _change_argument here
@metal3d
metal3d / sun_set.py
Last active Oct 14, 2020
Align Sky textyure with the sun lamp in Blender
View sun_set.py
import bpy
import mathutils
# Author: Patrice Ferlet <metal3d@gmail.com>
# License: GPL
# Works with Blender 2.80-2.90
# To use this script:
# - paste this script in a "text editor" *inside* blender
# - name it "sun_set.py"
@metal3d
metal3d / videoframegenerator.py
Last active Mar 18, 2021
A video frame generator respecting Keras.Sequence class with data augmentation capacities
View videoframegenerator.py
# DEPRECATED - please go to my complete package:
# pipy package https://pypi.org/project/keras-video-generators/
# github sources https://github.com/metal3d/keras-video-generators
import keras
import cv2 as cv
import glob
import numpy as np
import os
import random
@metal3d
metal3d / videoframegenerator.py
Created Apr 2, 2019
A video frame generator respecting Keras.Sequence class with data augmentation capacities
View videoframegenerator.py
import keras
import cv2 as cv
import glob
import numpy as np
import os
import random
import keras_preprocessing
# author: Patrice Ferlet <patrice.ferlet@smile.fr>
# licence: MIT
View TF - graph exemple.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View tfboardviewer.py
import tensorflow as tf
import numpy as np
from IPython.display import clear_output, Image, display, HTML
def strip_consts(graph_def, max_const_size=32):
"""Strip large constant values from graph_def."""
strip_def = tf.GraphDef()
for n0 in graph_def.node:
n = strip_def.node.add()
n.MergeFrom(n0)
@metal3d
metal3d / generator.py
Last active Oct 26, 2020
Keras generator to create sequence image batches
View generator.py
import cv2 as cv
import os
import glob
import numpy as np
import random
from tensorflow import keras
import keras.preprocessing.image
from tensorflow.python.keras.utils.data_utils import Sequence
class VideoFrameGenerator(Sequence):