Skip to content

Instantly share code, notes, and snippets.

View lxg2015's full-sized avatar

lxg2015

  • Beijing
  • 14:54 (UTC +08:00)
View GitHub Profile
@lxg2015
lxg2015 / gradio.py
Created March 31, 2023 08:09
gradio
import os
os.environ['CUDA_VISIBLE_DEVICES']='7'
import sys
import time
import copy
import torch
import numpy as np
import gradio as gr
from PIL import Image
@lxg2015
lxg2015 / logger.py
Last active October 14, 2022 03:08
logger
import sys
import logging
# logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
log.addHandler(handler)
formatter = logging.Formatter(f'%(asctime)s %(levelname)s:%(name)s: %(message)s', datefmt='%m/%d/%Y %H:%M:%S')
handler.setFormatter(formatter)
@lxg2015
lxg2015 / main.cpp
Last active September 21, 2022 03:12
gpu_info
#include <cuda_runtime_api.h>
#include <cuda.h>
#include <stdio.h>
int main()
{
cudaDeviceProp prop;
int gpu_index = 0;
int i = 0;
cudaGetDeviceProperties(&prop, gpu_index);
@lxg2015
lxg2015 / image.py
Last active August 16, 2022 08:21
tfrecord_image
import tensorflow as tf
def map_func_single(example):
feature_dict = {
"url": tf.FixedLenFeature(1, tf.string),
"pic_data": tf.FixedLenFeature(1, tf.string),
"dt": tf.FixedLenFeature(1, tf.string),
"pic_size": tf.FixedLenFeature(1, tf.int64),
"origin_pic_width": tf.FixedLenFeature(1, tf.int64),
"origin_pic_height": tf.FixedLenFeature(1, tf.int64),
import cv2
import math
import numpy as np
def affine(path, theta, scalex):
img = cv2.imread(path)
h, w, c = img.shape
x0 = w // 2
y0 = h // 2
@lxg2015
lxg2015 / ellipse2rect.py
Last active March 25, 2023 02:08
ellipse2rect
def calc_bias(a, b, theta):
'''
Args:
a: (real), long axis in ellipse
b: (real), short axis in ellipse
theta: (real), line slope [0, pi), anticlockwise
Returns:
x,y: tangent line point in first quadrant
'''