Skip to content

Instantly share code, notes, and snippets.

View miladfa7's full-sized avatar
🎯
Focusing

Milad Farzalizadeh miladfa7

🎯
Focusing
View GitHub Profile
@juliussin
juliussin / xyxy_xywh.py
Last active October 22, 2023 19:02
Convert XYXY format (x,y top left and x,y bottom right) to XYWH format (x,y center point and width, height) and vice versa.
import cv2
import numpy as np
def xyxy_to_xywh(xyxy):
"""
Convert XYXY format (x,y top left and x,y bottom right) to XYWH format (x,y center point and width, height).
:param xyxy: [X1, Y1, X2, Y2]
:return: [X, Y, W, H]
"""
if np.array(xyxy).ndim > 1 or len(xyxy) > 4:
@meyerjo
meyerjo / iou.py
Last active July 17, 2024 18:01
Python code to compute the intersection of two boundingboxes
def bb_intersection_over_union(boxA, boxB):
# determine the (x, y)-coordinates of the intersection rectangle
xA = max(boxA[0], boxB[0])
yA = max(boxA[1], boxB[1])
xB = min(boxA[2], boxB[2])
yB = min(boxA[3], boxB[3])
# compute the area of intersection rectangle
interArea = abs(max((xB - xA, 0)) * max((yB - yA), 0))
if interArea == 0:
@joannapurosto
joannapurosto / deep_fashion_to_tfrecord.py
Created June 8, 2018 10:52
deep_fashion_to_tfrecord.py
def create_tf_example(example, path_root):
# import image
f_image = Image.open(path_root + example["image_name"])
# get width and height of image
width, height = f_image.size
# crop image randomly around bouding box within a 0.15 * bbox extra range
if FLAGS.evaluation_status != "test":
@nlothian
nlothian / fasttext_to_tensorboard.py
Created November 23, 2017 23:28
Convert a FastText model to a form suitable for viewing in Tensorboard
from tensorflow.contrib.tensorboard.plugins import projector
import tensorflow as tf
import numpy as np
import os
meta_file = "g2x_metadata.tsv"
output_path = "./projections"
# read embedding file into list and get the size
with open('./ft_model.vec', 'r') as embedding_file:
@rohitrawat
rohitrawat / sources.list
Created June 12, 2017 18:17
Ubuntu 16.04 Xenial default /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted