img_Mask

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="gb2312">
<title>jQuery鼠标悬浮遮罩显示分享按钮</title>

<style>
.pinit {
	position:relative;
	display:inline-block;
}
.pinit .pinit-overlay {
	position:absolute;
	top:0;
	left:0;
	width:100%;
	height:100%;
	z-index:200;
	display:none;
	background:transparent url('img/img2.png') repeat 0 0;
	text-align:center;
}
.pinit .pinit-overlay a {
	position:relative;
	top:5%;
	left:100%;
	margin:-10px 0 0 -21px;
	display:block;
	width:43px;
	height:20px;
	background:transparent url('img/img1.png')no-repeat 0 0;
	text-indent:-9999em;
}
.pinit .pinit-overlay a:hover {
	background-positon: 0 -21px;
}
.pinit .pinit-overlay a:active {
	background-position: 0 -42px;
}
</style>
</head>
<body>
<div class="container" style="text-align:center; font-family:arial">
	<h2>jQuery鼠标悬浮遮罩显示分享按钮</h2>
	<img src="img/project_pic1.jpg"  width="300"/>
	<img src="img/project_pic2.jpg"  width="300" /><br/>
	<img src="img/project_pic3.jpg"  width="300" />
	<img src="img/project_pic4.jpg"  width="300" />	
</div>
<script src="js/jquery-2.1.1.js" type="text/javascript"></script>
<script type="text/javascript">
(function($){
 $.fn.extend({
     pinit: function(options) {
var defaults = {
	wrap: '<span class="pinit"/>',
	pageURL: document.URL
};
	var options = $.extend(defaults, options);
var o = options;
         return this.each(function() {
          	var e = $(this),
          		pi_media = e.data('media') ? e.data('media') : e[0].src,
          		pi_url = o.pageURL,
          		pi_desc = e.attr('title') ? e.attr('title') : e.attr('alt'),
          		pi_isvideo = 'false';
          		bookmark = 'http://pinterest.com/pin/create/bookmarklet/?media=' + encodeURI(pi_media) + '&url=' + encodeURI(pi_url) + '&is_video=' + encodeURI(pi_isvideo) + '&description=' + encodeURI(pi_desc);
	var eHeight = e.outerHeight();
          		e.wrap(o.wrap);
          		e.after('<span class="pinit-overlay" style="height: ' + eHeight + 'px"><a href="' + bookmark + '" class="pinit-button">Pin It</a></span>');
	$('.pinit .pinit-button').on('click', function () {
		window.open($(this).attr('href'), 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
		return false;
	});
	$('.pinit').mouseenter(function () {
		$(this).children('.pinit-overlay').fadeIn(200);
	}).mouseleave(function () {
		$(this).children('.pinit-overlay').fadeOut(200);
	});
         });
     }
 });
})(jQuery);
</script>	
<script type="text/javascript">
$(function () {
	$('img').pinit();
});
</script>	
<div style="text-align:center;clear:both"></div>
</body>
</html>


import os import random import numpy as np import cv2 import keras from create_unet import create_model img_path = 'data_enh/img' mask_path = 'data_enh/mask' # 训练集与测试集的切分 img_files = np.array(os.listdir(img_path)) data_num = len(img_files) train_num = int(data_num * 0.8) train_ind = random.sample(range(data_num), train_num) test_ind = list(set(range(data_num)) - set(train_ind)) train_ind = np.array(train_ind) test_ind = np.array(test_ind) train_img = img_files[train_ind] # 训练的数据 test_img = img_files[test_ind] # 测试的数据 def get_mask_name(img_name): mask = [] for i in img_name: mask_name = i.replace('.jpg', '.png') mask.append(mask_name) return np.array(mask) train_mask = get_mask_name(train_img) test_msak = get_mask_name(test_img) def generator(img, mask, batch_size): num = len(img) while True: IMG = [] MASK = [] for i in range(batch_size): index = np.random.choice(num) img_name = img[index] mask_name = mask[index] img_temp = os.path.join(img_path, img_name) mask_temp = os.path.join(mask_path, mask_name) temp_img = cv2.imread(img_temp) temp_mask = cv2.imread(mask_temp, 0)/255 temp_mask = np.reshape(temp_mask, [256, 256, 1]) IMG.append(temp_img) MASK.append(temp_mask) IMG = np.array(IMG) MASK = np.array(MASK) yield IMG, MASK # train_data = generator(train_img, train_mask, 32) # temp_data = train_data.__next__() # 计算dice系数 def dice_coef(y_true, y_pred): y_true_f = keras.backend.flatten(y_true) y_pred_f = keras.backend.flatten(y_pred) intersection = keras.backend.sum(y_true_f * y_pred_f) area_true = keras.backend.sum(y_true_f * y_true_f) area_pred = keras.backend.sum(y_pred_f * y_pred_f) dice = (2 * intersection + 1)/(area_true + area_pred + 1) return dice # 自定义损失函数,dice_loss def dice_coef_loss(y_true, y_pred): return 1 - dice_coef(y_true, y_pred) # 模型的创建 model = create_model() # 模型的编译 model.compile(optimizer='Adam', loss=dice_coef_loss, metrics=[dice_coef]) # 模型的训练 history = model.fit_generator(generator(train_img, train_mask, 4), steps_per_epoch=100, epochs=10, validation_data=generator(test_img, test_msak, 4), validation_steps=4 ) # 模型的保存 model.save('unet_model.h5') # 模型的读取 model = keras.models.load_model('unet_model.h5', custom_objects={'dice_coef_loss': dice_coef_loss, 'dice_coef': dice_coef}) # 获取测试数据 test_generator = generator(test_img, test_msak, 32) img, mask = test_generator.__next__() # 模型的测试 model.evaluate(img, mask) # [0.11458712816238403, 0.885412871837616] 94%
02-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值