This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import cv2 | |
import json | |
import string | |
import random | |
import numpy as np | |
def draw(img,poly,bbox): | |
cv2.polylines(img, [poly], True, (0,255,0), thickness=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#original: https://github.com/nmosto/kick-into-traction/blob/803bcfb96772d7d182622b98f9b1e7be3cc7435c/image-feature-engineering/dominant_color_clustering.py | |
import numpy as np | |
from PIL import Image as IMG | |
import cv2 | |
from skimage.io import imread, imshow | |
def dominant_color(img): | |
# img should be the img object or path to the image | |
# read in image using openCV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow import keras | |
model = keras.models.load_model('model') | |
tf.saved_model.save(model, "new_out") | |
converter = tf.lite.TFLiteConverter.from_keras_model(model) | |
converter.optimizations = [tf.lite.Optimize.DEFAULT] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in images/*.jpg; do _h=`identify -format '%h' $f`; if [[ $_h -gt 100 ]] cp "$f" 100/images/; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in this case, we save the frozen model to one single .pb model file | |
# and load it for forward inference | |
# for save model, first import meta graph and restore variables for checkpoint file | |
# and then send the GraphDef to graph_util.convert_variables_to_constants and get | |
# a new GraphDef object which is a simplified version of original one, | |
# and then serialize the GraphDef and write it to disk using tf.gfile | |
# | |
# for load model, first we read the .pb file from disk and deserialize it,as a return we | |
# get a GraphDef object, and then import it into the default graph use import_graph_def, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2020 Google. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#original: https://github.com/lizhaoliu-Lec/DENet/blob/master/dataset/coco.py | |
from PIL import Image | |
import torch | |
from pycocotools.coco import COCO | |
import os | |
from tqdm import tqdm | |
import numpy as np | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#original: https://github.com/hemanth346/EVA4_Phase2/blob/master/Session2/utils/get_stats.py | |
from torch.utils.data import Dataset, DataLoader | |
import os | |
import torch | |
import torch.utils.data | |
import torchvision | |
from PIL import Image | |
from skimage import io, transform | |
from pycocotools.coco import COCO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomPasswordField(StringField): | |
#admin can change the user password. do not change if the form contains the old password hash. | |
def populate_obj(self, obj, name): | |
if obj.password != self.data: | |
setattr(obj, name, hash_password(self.data)) | |
class UserView(AdminMixin, ModelView): | |
form_extra_fields = { | |
'password': CustomPasswordField('password', validators=[ | |
validators.Regexp('(?=^.{6,}$)(?=.*\d)(?![.\n])(?=.*[a-z]).*$', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
form_args = { | |
'username': { | |
'validators': [validators.Regexp('^(?=.{5,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$', message='نام کاربری حداقل به طول ۵')] | |
}, | |
'password': { | |
'validators': [validators.Regexp('(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$', message='پسورد حداقل به طول ۸ و شامل حروف کوچک و بزرگ و عدد و علائم خاص باشد')] | |
} | |
} |
NewerOlder