text stringlengths 0 93.6k |
|---|
output_matrix = compute_output_matrix(gt, prediction, output_matrix) |
total_num += label.shape[0] |
if (step+1) % config['skip_step'] == 0: |
print '%s %s] %d. iou updating' \ |
% (str(datetime.datetime.now()), str(os.getpid()), total_num) |
print 'mIoU: ', compute_iou(output_matrix) |
step += 1 |
except tf.errors.OutOfRangeError: |
print 'mIoU: ', compute_iou(output_matrix), 'total_data: ', total_num |
break |
def main(): |
args = PARSER.parse_args() |
if args.config: |
file_address = open(args.config) |
config = yaml.load(file_address) |
else: |
print '--config config_file_address missing' |
test_func(config) |
if __name__ == '__main__': |
main() |
# <FILESEP> |
import cv2, numpy, random |
import os |
from PIL import Image, ImageDraw |
#Prepare the hats for use later |
hats = [] |
hats_portion = [] |
for i in range(1,8): |
hat = Image.open('./xmas/' + 'hat' + str(i) + '.png') |
hats.append(hat) |
hats_portion.append(hat.size[0]/hat.size[1]) |
#load photo frames |
frame_w = Image.open('./xmas/frame_w.png') |
frame_h = Image.open('./xmas/frame_h.png') |
frame_s = Image.open('./xmas/frame_s.png') |
ok_msg = '你的圣诞节靓照已经生成好啦,请访问以下链接查看,长按图片可保存: ' |
auto_reply = '嗨!欢迎来玩儿,活动正在进行中!你可以在这里向本公众号发送现场拍摄的照片,我们会自动为照片中的人物带上圣诞帽或鹿角,生成有浓浓圣诞节氛围的照片~「本消息为自动发送」' |
def gen_pic(MediaId): |
def get_hat(x,y,w,h): |
#set the probability of every hat |
num = random.randint(1,100) |
if num in range(1,17): |
#hat1 |
(hat_num, offset1, offset2, offset3) = (0, 1.2, .05, .67) |
elif num in range(17,33): |
#hat2 |
(hat_num, offset1, offset2, offset3) = (1, 1.3, -.4, .62) |
elif num in range(33,49): |
#hat3 |
(hat_num, offset1, offset2, offset3) = (2, .9, .05, .8) |
elif num in range(91,101): |
#green hat |
(hat_num, offset1, offset2, offset3) = (3, 1.2, .05, .67) |
elif num in range(49,65): |
#jiao1 |
(hat_num, offset1, offset2, offset3) = (4, 1.2, -.1, 1.2) |
elif num in range(65,81): |
#jiao2 |
(hat_num, offset1, offset2, offset3) = (5, 1, 0, 1.2) |
elif num in range(81,91): |
#tree |
(hat_num, offset1, offset2, offset3) = (6, .9, .05, 1) |
hat_portion = hats_portion[hat_num] |
(hat_w, hat_h) = (int(w*offset1), int(w*offset1/hat_portion)) |
print('hat size:',hat_w,hat_h) |
hatter = hats[hat_num].resize((hat_w, hat_h)) |
(hat_x, hat_y) = (int(x+w*offset2), int(y-hat_h*offset3)) |
hat_pos = (hat_x, hat_y) |
print('hat at:',hat_x,hat_y) |
return (hatter, hat_pos) |
def std_size(imagePath): |
pic = Image.open(imagePath) |
portion = pic.size[0]/pic.size[1] |
if portion < 1: |
#portrait |
if portion <= 0.75: |
pic_w = 960 |
pic_h = round(960/portion) |
box = (0,round((pic_h-1280)/2),960,round(pic_h/2+640)) |
if portion > 0.75: |
pic_h = 1280 |
pic_w = round(1280*portion) |
box = (round((pic_w-960)/2),0,round(pic_w/2+480),1280) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.