“监管条件xA:ax²+ax+1>0的解集为R”“监管条件xB:0<a<4”,A是B的什么监管条件x?

问题补充&&
本页链接:
y=-4a=-2,a=1/2抛物线y=0.5x²-1.5x-22)直线x=m与BC交点E(m,0;=(m-0)&#178.5x-2直线BC为y=(1&#47答:1)点C(0;——两点间距离公式,-2),0,OC=2tan∠ABC=OC/OB=2/-1.5m-2+2)²2)(x-4);+(0;OB=1/2解得:OB=4;+(0;-1.5m-2)CF²-1.5m)&#178,点B(4,0)抛物线为y=a(x+1)(x-4)点C代入得.5m&#178,y=0.5m&#178.5m-2)直线x=m与抛物线交点F(m.5m²=m&#178..
yuyou403 &
•••••
uame_gtagames&
猜你感兴趣“条件A:ax²+ax+1&0的解集为R”“条件B:0&a&4”,A是B的什么条件?_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
“条件A:ax²+ax+1&0的解集为R”“条件B:0&a&4”,A是B的什么条件?
我有更好的答案
今天,你休息?
你们真幸福,周末不要补课!
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包&figure&&img src=&/v2-da6e908fbff06e8e14c60d86d776d225_b.jpg& data-rawwidth=&768& data-rawheight=&576& class=&origin_image zh-lightbox-thumb& width=&768& data-original=&/v2-da6e908fbff06e8e14c60d86d776d225_r.jpg&&&/figure&&figure&&img src=&/v2-abd42bbb61ee_b.jpg& data-rawwidth=&558& data-rawheight=&315& class=&origin_image zh-lightbox-thumb& width=&558& data-original=&/v2-abd42bbb61ee_r.jpg&&&/figure&&p&作为一名久经片场的老司机,早就想写一些探讨驾驶技术的文章。这篇就介绍利用生成式对抗网络(GAN)的两个基本驾驶技能:&br&&/p&&p&1) 去除(爱情)动作片中的马赛克&/p&&p&2) 给(爱情)动作片中的女孩穿(tuo)衣服&/p&&br&&h2&生成式模型&/h2&&p&上一篇《&a href=&/p/& class=&internal&&用GAN生成二维样本的小例子&/a&》中已经简单介绍了GAN,这篇再简要回顾一下生成式模型,算是补全一个来龙去脉。&/p&&p&生成模型就是能够产生指定分布数据的模型,常见的生成式模型一般都会有一个用于产生样本的简单分布。例如一个均匀分布,根据要生成分布的概率密度函数,进行建模,让均匀分布中的样本经过变换得到指定分布的样本,这就可以算是最简单的生成式模型。比如下面例子:&/p&&figure&&img src=&/v2-d11b5fb26d3cc8e942f841bafe010cd8_b.jpg& data-rawwidth=&1021& data-rawheight=&443& class=&origin_image zh-lightbox-thumb& width=&1021& data-original=&/v2-d11b5fb26d3cc8e942f841bafe010cd8_r.jpg&&&/figure&&p&图中左边是一个自定义的概率密度函数,右边是相应的1w个样本的直方图,自定义分布和生成这些样本的代码如下:&br&&/p&&div class=&highlight&&&pre&&code class=&language-python&&&span&&/span&&span class=&kn&&from&/span& &span class=&nn&&functools&/span& &span class=&kn&&import&/span& &span class=&n&&partial&/span&
&span class=&kn&&import&/span& &span class=&nn&&numpy&/span&
&span class=&kn&&from&/span& &span class=&nn&&matplotlib&/span& &span class=&kn&&import&/span& &span class=&n&&pyplot&/span&
&span class=&c1&&# Define a PDF&/span&
&span class=&n&&x_samples&/span& &span class=&o&&=&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&arange&/span&&span class=&p&&(&/span&&span class=&o&&-&/span&&span class=&mi&&3&/span&&span class=&p&&,&/span& &span class=&mf&&3.01&/span&&span class=&p&&,&/span& &span class=&mf&&0.01&/span&&span class=&p&&)&/span&
&span class=&n&&PDF&/span& &span class=&o&&=&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&empty&/span&&span class=&p&&(&/span&&span class=&n&&x_samples&/span&&span class=&o&&.&/span&&span class=&n&&shape&/span&&span class=&p&&)&/span&
&span class=&n&&PDF&/span&&span class=&p&&[&/span&&span class=&n&&x_samples&/span& &span class=&o&&&&/span& &span class=&mi&&0&/span&&span class=&p&&]&/span& &span class=&o&&=&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&round&/span&&span class=&p&&(&/span&&span class=&n&&x_samples&/span&&span class=&p&&[&/span&&span class=&n&&x_samples&/span& &span class=&o&&&&/span& &span class=&mi&&0&/span&&span class=&p&&]&/span& &span class=&o&&+&/span& &span class=&mf&&3.5&/span&&span class=&p&&)&/span& &span class=&o&&/&/span& &span class=&mi&&3&/span&
&span class=&n&&PDF&/span&&span class=&p&&[&/span&&span class=&n&&x_samples&/span& &span class=&o&&&=&/span& &span class=&mi&&0&/span&&span class=&p&&]&/span& &span class=&o&&=&/span& &span class=&mf&&0.5&/span& &span class=&o&&*&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&cos&/span&&span class=&p&&(&/span&&span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&pi&/span& &span class=&o&&*&/span& &span class=&n&&x_samples&/span&&span class=&p&&[&/span&&span class=&n&&x_samples&/span& &span class=&o&&&=&/span& &span class=&mi&&0&/span&&span class=&p&&])&/span& &span class=&o&&+&/span& &span class=&mf&&0.5&/span&
&span class=&n&&PDF&/span& &span class=&o&&/=&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&sum&/span&&span class=&p&&(&/span&&span class=&n&&PDF&/span&&span class=&p&&)&/span&
&span class=&c1&&# Calculate approximated CDF&/span&
&span class=&n&&CDF&/span& &span class=&o&&=&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&empty&/span&&span class=&p&&(&/span&&span class=&n&&PDF&/span&&span class=&o&&.&/span&&span class=&n&&shape&/span&&span class=&p&&)&/span&
&span class=&n&&cumulated&/span& &span class=&o&&=&/span& &span class=&mi&&0&/span&
&span class=&k&&for&/span& &span class=&n&&i&/span& &span class=&ow&&in&/span& &span class=&nb&&range&/span&&span class=&p&&(&/span&&span class=&n&&CDF&/span&&span class=&o&&.&/span&&span class=&n&&shape&/span&&span class=&p&&[&/span&&span class=&mi&&0&/span&&span class=&p&&]):&/span&
&span class=&n&&cumulated&/span& &span class=&o&&+=&/span& &span class=&n&&PDF&/span&&span class=&p&&[&/span&&span class=&n&&i&/span&&span class=&p&&]&/span&
&span class=&n&&CDF&/span&&span class=&p&&[&/span&&span class=&n&&i&/span&&span class=&p&&]&/span& &span class=&o&&=&/span& &span class=&n&&cumulated&/span&
&span class=&c1&&# Generate samples&/span&
&span class=&n&&generate&/span& &span class=&o&&=&/span& &span class=&n&&partial&/span&&span class=&p&&(&/span&&span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&interp&/span&&span class=&p&&,&/span& &span class=&n&&xp&/span&&span class=&o&&=&/span&&span class=&n&&CDF&/span&&span class=&p&&,&/span& &span class=&n&&fp&/span&&span class=&o&&=&/span&&span class=&n&&x_samples&/span&&span class=&p&&)&/span&
&span class=&n&&u_rv&/span& &span class=&o&&=&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&random&/span&&span class=&o&&.&/span&&span class=&n&&random&/span&&span class=&p&&(&/span&&span class=&mi&&10000&/span&&span class=&p&&)&/span&
&span class=&n&&x&/span& &span class=&o&&=&/span& &span class=&n&&generate&/span&&span class=&p&&(&/span&&span class=&n&&u_rv&/span&&span class=&p&&)&/span&
&span class=&c1&&# Visualization&/span&
&span class=&n&&fig&/span&&span class=&p&&,&/span& &span class=&p&&(&/span&&span class=&n&&ax0&/span&&span class=&p&&,&/span& &span class=&n&&ax1&/span&&span class=&p&&)&/span& &span class=&o&&=&/span& &span class=&n&&pyplot&/span&&span class=&o&&.&/span&&span class=&n&&subplots&/span&&span class=&p&&(&/span&&span class=&n&&ncols&/span&&span class=&o&&=&/span&&span class=&mi&&2&/span&&span class=&p&&,&/span& &span class=&n&&figsize&/span&&span class=&o&&=&/span&&span class=&p&&(&/span&&span class=&mi&&9&/span&&span class=&p&&,&/span& &span class=&mi&&4&/span&&span class=&p&&))&/span&
&span class=&n&&ax0&/span&&span class=&o&&.&/span&&span class=&n&&plot&/span&&span class=&p&&(&/span&&span class=&n&&x_samples&/span&&span class=&p&&,&/span& &span class=&n&&PDF&/span&&span class=&p&&)&/span&
&span class=&n&&ax0&/span&&span class=&o&&.&/span&&span class=&n&&axis&/span&&span class=&p&&([&/span&&span class=&o&&-&/span&&span class=&mf&&3.5&/span&&span class=&p&&,&/span& &span class=&mf&&3.5&/span&&span class=&p&&,&/span& &span class=&mi&&0&/span&&span class=&p&&,&/span& &span class=&n&&numpy&/span&&span class=&o&&.&/span&&span class=&n&&max&/span&&span class=&p&&(&/span&&span class=&n&&PDF&/span&&span class=&p&&)&/span&&span class=&o&&*&/span&&span class=&mf&&1.1&/span&&span class=&p&&])&/span&
&span class=&n&&ax1&/span&&span class=&o&&.&/span&&span class=&n&&hist&/span&&span class=&p&&(&/span&&span class=&n&&x&/span&&span class=&p&&,&/span& &span class=&mi&&100&/span&&span class=&p&&)&/span&
&span class=&n&&pyplot&/span&&span class=&o&&.&/span&&span class=&n&&show&/span&&span class=&p&&()&/span&
&/code&&/pre&&/div&&p&对于一些简单的情况,我们会假设已知有模型可以很好的对分布进行建模,缺少的只是合适的参数。这时候很自然只要根据观测到的样本,学习参数让当前观测到的样本下的似然函数最大,这就是最大似然估计(&b&M&/b&aximum &b&L&/b&ikelihood &b&E&/b&stimation):&br&&/p&&img src=&/equation?tex=%5Chat%7B%5Ctheta%7D%3D%5Coperatorname%2A%7Bargmax%7D_%7B%5Ctheta%7D+P%28%5Cbm%7Bx%7D%7C%5Ctheta%29%0A+%3D+%5Coperatorname%2A%7Bargmax%7D_%7B%5Ctheta%7D+%5Cprod_%7Bi%3D1%7D%5E%7Bn%7DP%28x_i%7C%5Ctheta%29+& alt=&\hat{\theta}=\operatorname*{argmax}_{\theta} P(\bm{x}|\theta)
= \operatorname*{argmax}_{\theta} \prod_{i=1}^{n}P(x_i|\theta) & eeimg=&1&&&br&&p&MLE是一个最基本的思路,实践中用得很多的还有KL散度(Kullback–Leibler divergence),假设真实分布是P,采样分布是Q,则KL散度为:&/p&&img src=&/equation?tex=D_%7BKL%7D%28P%7C%7CQ%29%3D%5Csum_%7Bx+%5Cin+%5COmega%7DP%28%7Bx%7D%29%5Clog%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D++& alt=&D_{KL}(P||Q)=\sum_{x \in \Omega}P({x})\log\frac{P(x)}{Q(x)}
& eeimg=&1&&&br&&p&从公式也能看出来,KL散度描述的是两个分布的差异程度。换个角度来看,让产生的样本和原始分布接近,也就是要让这俩的差异减小,所以最小化KL散度就等同于MLE。从公式上来看的话,我们考虑把公式具体展开一下:&/p&&br&&img src=&/equation?tex=%5Cbegin%7Balign%7D%0AD_%7BKL%7D%28P%7C%7CQ%29+%26%3D%5Csum_%7Bx+%5Cin+%5COmega%7DP%28%7Bx%7D%29%5Clog%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D++++%5C%5C%0A%26+%3D-%5Csum_%7Bx%5Cin%5COmega%7DP%28%7Bx%7D%29%5Clog%7BQ%28x%29%7D+%2B%5Csum_%7Bx%5Cin%5COmega%7DP%28%7Bx%7D%29%5Clog%7BP%28x%29%7D+%5C%5C%0A%26+%3D-%5Csum_%7Bx%5Cin%5COmega%7DP%28%7Bx%7D%29%5Clog%7BQ%28x%29%7D+%2BH%28P%29%0A%5Cend%7Balign%7D& alt=&\begin{align}
D_{KL}(P||Q) &=\sum_{x \in \Omega}P({x})\log\frac{P(x)}{Q(x)}
& =-\sum_{x\in\Omega}P({x})\log{Q(x)} +\sum_{x\in\Omega}P({x})\log{P(x)} \\
& =-\sum_{x\in\Omega}P({x})\log{Q(x)} +H(P)
\end{align}& eeimg=&1&&&br&&p&公式的第二项就是熵,先不管这项,用H(P)表示。接下来考虑一个小trick:从Q中抽样n个样本&img src=&/equation?tex=%7Bx_1%2Cx_2%2C...%2Cx_n%7D& alt=&{x_1,x_2,...,x_n}& eeimg=&1&&,来估算P(x)的经验值(empirical density function):&br&&/p&&img src=&/equation?tex=%5Chat%7BP%7D%28x%29%3D%5Cfrac+1+n+%5Csum_%7Bi%3D1%7D%5En+%5Cdelta%28x_i-x%29& alt=&\hat{P}(x)=\frac 1 n \sum_{i=1}^n \delta(x_i-x)& eeimg=&1&&&br&&p&其中&img src=&/equation?tex=%5Cdelta%28%5Ccdot%29& alt=&\delta(\cdot)& eeimg=&1&&是狄拉克&img src=&/equation?tex=%5Cdelta& alt=&\delta& eeimg=&1&&函数,把这项替换到上面公式的P(x):&/p&&br&&img src=&/equation?tex=%5Cbegin%7Balign%7D%0AD_%7BKL%7D%28P%7C%7CQ%29+%26%3D-%5Csum_%7Bx%5Cin%5COmega%7D%5Cfrac+1+n+%5Csum_%7Bi%3D1%7D%5En+%5Cdelta%28x_i-x%29%5Clog%7BQ%28x%29%7D+%2BH%28P%29+%5C%5C%0A%26+%3D-%5Cfrac+1+n+%5Csum_%7Bi%3D1%7D%5En+%5Csum_%7Bx%5Cin%5COmega%7D++%5Cdelta%28x_i-x%29%5Clog%7BQ%28x%29%7D+%2BH%28P%29%0A%5Cend%7Balign%7D& alt=&\begin{align}
D_{KL}(P||Q) &=-\sum_{x\in\Omega}\frac 1 n \sum_{i=1}^n \delta(x_i-x)\log{Q(x)} +H(P) \\
& =-\frac 1 n \sum_{i=1}^n \sum_{x\in\Omega}
\delta(x_i-x)\log{Q(x)} +H(P)
\end{align}& eeimg=&1&&&br&&p&因为是离散的采样值,所以&img src=&/equation?tex=%5Csum_%7Bx%5Cin%5COmega%7D+%5Cdelta%28x_i-x%29& alt=&\sum_{x\in\Omega} \delta(x_i-x)& eeimg=&1&&中只有&img src=&/equation?tex=x%3Dx_i& alt=&x=x_i& eeimg=&1&&的时候狄拉克&img src=&/equation?tex=%5Cdelta& alt=&\delta& eeimg=&1&&函数才为1,所以考虑&img src=&/equation?tex=x%3Dx_i& alt=&x=x_i& eeimg=&1&&时这项直接化为1:&/p&&br&&img src=&/equation?tex=D_%7BKL%7D%28P%7C%7CQ%29+%3D-%5Cfrac+1+n%5Csum_%7Bi%3D1%7D%5En+%5Clog%7BQ%28x_i%29%7D+%2BH%28P%29& alt=&D_{KL}(P||Q) =-\frac 1 n\sum_{i=1}^n \log{Q(x_i)} +H(P)& eeimg=&1&&&br&&p&第一项正是似然的负对数形式。&/p&&p&说了些公式似乎跑得有点远了,其实要表达还是那个简单的意思:通过减小两个分布的差异可以让一个分布逼近另一个分布。仔细想想,这正是GAN里面adversarial loss的做法。&/p&&p&很多情况下我们面临的是更为复杂的分布,比如&a href=&/p/& class=&internal&&上篇文章&/a&中的例子,又或是实际场景中更复杂的情况,比如生成不同人脸的图像。这时候,作为具有universal approximation性质的神经网络是一个看上去不错的选择[1]:&br&&/p&&figure&&img src=&/v2-6fee20494f50baae2c1dc5fc_b.jpg& data-rawwidth=&1561& data-rawheight=&549& class=&origin_image zh-lightbox-thumb& width=&1561& data-original=&/v2-6fee20494f50baae2c1dc5fc_r.jpg&&&/figure&&p&所以虽然GAN里面同时包含了生成网络和判别网络,但本质来说GAN的目的还是生成模型。从生成式模型的角度,Ian Goodfellow总结过一个和神经网络相关生成式方法的“家谱”[1]:&/p&&figure&&img src=&/v2-8c6f1d8ee39dfbb4fcfb2_b.jpg& data-rawwidth=&771& data-rawheight=&498& class=&origin_image zh-lightbox-thumb& width=&771& data-original=&/v2-8c6f1d8ee39dfbb4fcfb2_r.jpg&&&/figure&&p&在这其中,当下最流行的就是GAN和&b&V&/b&ariational &b&A&/b&uto&b&E&/b&ncoder(VAE),两种方法的一个简明示意如下[3]:&/p&&figure&&img src=&/v2-380cde71a2f6ece28b4a97_b.jpg& data-rawwidth=&568& data-rawheight=&274& class=&origin_image zh-lightbox-thumb& width=&568& data-original=&/v2-380cde71a2f6ece28b4a97_r.jpg&&&/figure&&p&本篇不打算展开讲什么是VAE,不过通过这个图,和名字中的autoencoder也大概能知道,VAE中生成的loss是基于重建误差的。而只基于重建误差的图像生成,都或多或少会有图像模糊的缺点,因为误差通常都是针对全局。比如基于MSE(Mean Squared Error)的方法用来生成超分辨率图像,容易出现下面的情况[4]:&/p&&br&&p&&figure&&img src=&/v2-78f53b142fab51b0c09a1_b.jpg& data-rawwidth=&892& data-rawheight=&598& class=&origin_image zh-lightbox-thumb& width=&892& data-original=&/v2-78f53b142fab51b0c09a1_r.jpg&&&/figure&在这个二维示意中,真实数据分布在一个U形的流形上,而MSE系的方法因为loss的形式往往会得到一个接近平均值所在的位置(蓝色框)。&/p&&p&GAN在这方面则完爆其他方法,因为目标分布在流形上。所以只要大概收敛了,就算生成的图像都看不出是个啥,清晰度常常是有保证的,而这正是去除女优身上马赛克的理想特性!&/p&&br&&h2&马赛克-&清晰画面:超分辨率(Super Resolution)问题&/h2&&p&说了好些铺垫,终于要进入正题了。首先明确,去马赛克其实是个图像超分辨率问题,也就是如何在低分辨率图像基础上得到更高分辨率的图像:&/p&&figure&&img src=&/v2-31c84b42ad_b.jpg& data-rawwidth=&784& data-rawheight=&324& class=&origin_image zh-lightbox-thumb& width=&784& data-original=&/v2-31c84b42ad_r.jpg&&&/figure&&p&视频中超分辨率实现的一个套路是通过不同帧的低分辨率画面猜测超分辨率的画面,有兴趣了解这个思想的朋友可以参考我之前的一个答案:&a href=&/question//answer/& class=&internal&&如何通过多帧影像进行超分辨率重构? &/a&&br&&/p&&p&不过基于多帧影像的方法对于女优身上的马赛克并不是很适用,所以这篇要讲的是基于单帧图像的超分辨率方法。&/p&&h2&SRGAN&/h2&&p&说到基于GAN的超分辨率的方法,就不能不提到SRGAN[4]:《Photo-Realistic Single Image &b&S&/b&uper-&b&R&/b&esolution Using a &b&G&/b&enerative &b&A&/b&dversarial
&b&N&/b&etwork》。这个工作的思路是:基于像素的MSE loss往往会得到大体正确,但是高频成分模糊的结果。所以只要重建低频成分的图像内容,然后靠GAN来补全高频的细节内容,就可以了:&/p&&figure&&img src=&/v2-128029dfc7c470b07a4a1_b.jpg& data-rawwidth=&446& data-rawheight=&131& class=&origin_image zh-lightbox-thumb& width=&446& data-original=&/v2-128029dfc7c470b07a4a1_r.jpg&&&/figure&这个思路其实和最早基于深度网络的风格迁移的思路很像(有兴趣的读者可以参考我之前文章&a href=&/p/& class=&internal&&瞎谈CNN:通过优化求解输入图像&/a&的最后一部分),其中重建内容的content loss是原始图像和低分辨率图像在VGG网络中的各个ReLU层的激活值的差异:&p&&figure&&img src=&/v2-331e02e394cfd04e7114a_b.jpg& data-rawwidth=&529& data-rawheight=&150& class=&origin_image zh-lightbox-thumb& width=&529& data-original=&/v2-331e02e394cfd04e7114a_r.jpg&&&/figure&生成细节adversarial loss就是GAN用来判别是原始图还是生成图的loss:&/p&&figure&&img src=&/v2-fa5af2a10fe9a4dadfb04_b.jpg& data-rawwidth=&394& data-rawheight=&89& class=&content_image& width=&394&&&/figure&&p&把这两种loss放一起,取个名叫perceptual loss。训练的网络结构如下:&/p&&figure&&img src=&/v2-17861edeb4bcfae4e9f369_b.jpg& data-rawwidth=&780& data-rawheight=&400& class=&origin_image zh-lightbox-thumb& width=&780& data-original=&/v2-17861edeb4bcfae4e9f369_r.jpg&&&/figure&&p&正是上篇文章中讲过的C-GAN,条件C就是低分辨率的图片。SRGAN生成的超分辨率图像虽然PSNR等和原图直接比较的传统量化指标并不是最好,但就视觉效果,尤其是细节上,胜过其他方法很多。比如下面是作者对比bicubic插值和基于ResNet特征重建的超分辨率的结果:&/p&&figure&&img src=&/v2-f3b4376938ffcbd23c42d_b.jpg& data-rawwidth=&981& data-rawheight=&392& class=&origin_image zh-lightbox-thumb& width=&981& data-original=&/v2-f3b4376938ffcbd23c42d_r.jpg&&&/figure&&p&可以看到虽然很多细节都和原始图片不一样,不过看上去很和谐,并且细节的丰富程度远胜于SRResNet。这些栩栩如生的细节,可以看作是GAN根据学习到的分布信息“联想”出来的。&/p&&p&对于更看重“看上去好看”的超分辨率应用,SRGAN显然是很合适的。当然对于一些更看重重建指标的应用,比如超分辨率恢复嫌疑犯面部细节,SRGAN就不可以了。&/p&&h2&pix2pix&/h2&&p&虽然专门用了一节讲SRGAN,但本文用的方法其实是pix2pix[5]。这项工作刚在arxiv上发布就引起了不小的关注,它巧妙的利用GAN的框架解决了通用的Image-to-Image translation的问题。举例来说,在不改变分辨率的情况下:把照片变成油画风格;把白天的照片变成晚上;用色块对图片进行分割或者倒过来;为黑白照片上色;…每个任务都有专门针对性的方法和相关研究,但其实总体来看,都是像素到像素的一种映射啊,其实可以看作是一个问题。这篇文章的巧妙,就在于提出了pix2pix的方法,一个框架,解决所有这些问题。方法的示意图如下:&/p&&p&&figure&&img src=&/v2-e2ea753b7b0d7f18abee3_b.jpg& data-rawwidth=&485& data-rawheight=&437& class=&origin_image zh-lightbox-thumb& width=&485& data-original=&/v2-e2ea753b7b0d7f18abee3_r.jpg&&&/figure&就是一个Conditional GAN,条件C是输入的图片。除了直接用C-GAN,这项工作还有两个改进:&/p&&p&1)&b&利用U-Net结构生成细节更好的图片&/b&[6]&/p&&figure&&img src=&/v2-beb074bebbfa0db_b.jpg& data-rawwidth=&907& data-rawheight=&612& class=&origin_image zh-lightbox-thumb& width=&907& data-original=&/v2-beb074bebbfa0db_r.jpg&&&/figure&&p&U-Net是德国Freiburg大学模式识别和图像处理组提出的一种全卷积结构。和常见的先降采样到低维度,再升采样到原始分辨率的编解码(Encoder-Decoder)结构的网络相比,U-Net的区别是加入skip-connection,对应的feature maps和decode之后的同样大小的feature maps按通道拼(concatenate)一起,用来保留不同分辨率下像素级的细节信息。U-Net对提升细节的效果非常明显,下面是pix2pix文中给出的一个效果对比:&/p&&p&&figure&&img src=&/v2-2fb4ddb2fdc24eea31eea_b.jpg& data-rawwidth=&563& data-rawheight=&307& class=&origin_image zh-lightbox-thumb& width=&563& data-original=&/v2-2fb4ddb2fdc24eea31eea_r.jpg&&&/figure&可以看到,各种不同尺度的信息都得到了很大程度的保留。&/p&&p&2)&b&利用马尔科夫性的判别器(PatchGAN)&br&&/b&&/p&&p&pix2pix和SRGAN的一个异曲同工的地方是都有用重建解决低频成分,用GAN解决高频成分的想法。在pix2pix中,这个思想主要体现在两个地方。一个是loss函数,加入了L1 loss用来让生成的图片和训练的目标图片尽量相似,而图像中高频的细节部分则交由GAN来处理:&/p&&figure&&img src=&/v2-cb180ad03d8a72e7883285b_b.jpg& data-rawwidth=&447& data-rawheight=&51& class=&origin_image zh-lightbox-thumb& width=&447& data-original=&/v2-cb180ad03d8a72e7883285b_r.jpg&&&/figure&&p&还有一个就是&b&PatchGAN&/b&,也就是具体的GAN中用来判别是否生成图的方法。PatchGAN的思想是,既然GAN只负责处理低频成分,那么判别器就没必要以一整张图作为输入,只需要对NxN的一个图像patch去进行判别就可以了。这也是为什么叫Markovian discriminator,因为在patch以外的部分认为和本patch互相独立。&/p&&p&具体实现的时候,作者使用的是一个NxN输入的全卷积小网络,最后一层每个像素过sigmoid输出为真的概率,然后用BCEloss计算得到最终loss。这样做的好处是因为输入的维度大大降低,所以参数量少,运算速度也比直接输入一张快,并且可以计算任意大小的图。作者对比了不同大小patch的结果,对于256x256的输入,patch大小在70x70的时候,从视觉上看结果就和直接把整张图片作为判别器输入没什么区别了:&/p&&figure&&img src=&/v2-5172ca51efb4ee3e453b15_b.jpg& data-rawwidth=&842& data-rawheight=&107& class=&origin_image zh-lightbox-thumb& width=&842& data-original=&/v2-5172ca51efb4ee3e453b15_r.jpg&&&/figure&&h2&生成带局部马赛克的训练数据&/h2&&p&利用pix2pix,只要准备好无码和相应的有码图片就可以训练去马赛克的模型了,就是这么简单。那么问题是,如何生成有马赛克的图片?&/p&&p&有毅力的话,可以手动加马赛克,这样最为精准。这节介绍一个不那么准,但是比随机强的方法:利用分类模型的激活区域进行自动马赛克标注。&/p&&p&基本思想是利用一个可以识别需要打码图像的分类模型,提取出这个模型中对应类的CAM(&b&C&/b&lass &b&A&/b&ctivation &b&M&/b&ap)[7],然后用马赛克遮住响应最高的区域即可。这里简单说一下什么是CAM,对于最后一层是全局池化(平均或最大都可以)的CNN结构,池化后的feature map相当于是做了个加权相加来计算最终的每个类别进入softmax之前的激活值。CAM的思路是,把这个权重在池化前的feature map上按像素加权相加,最后得到的单张的激活图就可以携带激活当前类别的一些位置信息,这相当于一种弱监督(classification--&localization):&/p&&p&&figure&&img src=&/v2-fd28f0b871bd_b.jpg& data-rawwidth=&660& data-rawheight=&314& class=&origin_image zh-lightbox-thumb& width=&660& data-original=&/v2-fd28f0b871bd_r.jpg&&&/figure&上图是一个CAM的示意,用澳洲梗类别的CAM,放大到原图大小,可以看到小狗所在的区域大致是激活响应最高的区域。&/p&&p&那么就缺一个可以识别XXX图片的模型了,网上还恰好就有个现成的,yahoo于2016年发布的开源色情图片识别模型Open NSFW(&b&N&/b&ot &b&S&/b&afe &b&F&/b&or &b&W&/b&ork):&/p&&a href=&/?target=https%3A///yahoo/open_nsfw& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&yahoo/open_nsfw&i class=&icon-external&&&/i&&/a&&p&CAM的实现并不难,结合Open NSFW自动打码的代码和使用放在了这里:&/p&&a href=&/?target=https%3A///frombeijingwithlove/dlcv_for_beginners/tree/master/random_bonus/generate_mosaic_for_porno_images& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&给XX图片生成马赛克&i class=&icon-external&&&/i&&/a&&br&&br&(成功打码的)效果差不多是下面这样子:&figure&&img src=&/v2-cbefa39dc983f2645dd8_b.jpg& data-rawwidth=&768& data-rawheight=&256& class=&origin_image zh-lightbox-thumb& width=&768& data-original=&/v2-cbefa39dc983f2645dd8_r.jpg&&&/figure&&h2&去除(爱情)动作片中的马赛克&/h2&&p&这没什么好说的了,一行代码都不用改,只需要按照前面的步骤把数据准备好,然后按照pix2pix官方的使用方法训练就可以了:&/p&&p&Torch版pix2pix:&a href=&/?target=https%3A///phillipi/pix2pix& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&phillipi/pix2pix&i class=&icon-external&&&/i&&/a&&/p&&p&pyTorch版pix2pix(Cycle-GAN二合一版):&a href=&/?target=https%3A///junyanz/pytorch-CycleGAN-and-pix2pix& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&junyanz/pytorch-CycleGAN-and-pix2pix&i class=&icon-external&&&/i&&/a&&/p&&p&从D盘里随随便便找了几千张图片,用来执行了一下自动打码和pix2pix训练(默认参数),效果是下面这样:&/p&&br&&figure&&img src=&/v2-9f52b17c0e1296767cbfbfafc290a5bd_b.jpg& data-rawwidth=&814& data-rawheight=&691& class=&origin_image zh-lightbox-thumb& width=&814& data-original=&/v2-9f52b17c0e1296767cbfbfafc290a5bd_r.jpg&&&/figure&&p&什么?你问说好给女优去马赛克呢?女优照片呢?&/p&&figure&&img src=&/v2-480fb8a4dcfc7a4f92ec_b.jpg& data-rawwidth=&75& data-rawheight=&60& class=&content_image& width=&75&&&/figure&&p&还是要说一下,在真人照片上的效果比蘑菇和花强。&/p&&h2&对偶学习(Dual Learning)&/h2&&p&去马赛克已经讲完了,接下来就是给女孩穿(tuo)衣服了,动手之前,还是先讲一下铺垫:&b&对偶学习&/b&和&b&Cycle-GAN&/b&。&/p&&p&对偶学习是MSRA于2016年提出的一种用于机器翻译的增强学习方法[8],目的是解决海量数据配对标注的难题,个人觉得算是一种弱监督方法(不过看到大多数文献算作无监督)。以机器翻译为例,对偶学习基本思想如下图[9]:&/p&&figure&&img src=&/v2-c4b1eeda364fb6c9bada02f3_b.jpg& data-rawwidth=&866& data-rawheight=&399& class=&origin_image zh-lightbox-thumb& width=&866& data-original=&/v2-c4b1eeda364fb6c9bada02f3_r.jpg&&&/figure&左边的灰衣男只懂英语,右边的黑衣女只懂中文,现在的任务就是,要学习如何翻译英语到中文。对偶学习解决这个问题的思路是:给定一个模型&img src=&/equation?tex=f%3Ax%5Crightarrow+y& alt=&f:x\rightarrow y& eeimg=&1&&一上来无法知道f翻译得是否正确,但是如果考虑上&img src=&/equation?tex=f& alt=&f& eeimg=&1&&的对偶问题&img src=&/equation?tex=g%3Ay%5Crightarrow+x& alt=&g:y\rightarrow x& eeimg=&1&&,那么我可以尝试翻译一个英文句子到中文,再翻译回来。这种转了一圈的结果&img src=&/equation?tex=x%27%3Dg%28f%28x%29%29& alt=&x'=g(f(x))& eeimg=&1&&,灰衣男是可以用一个标准(BLEU)判断x'和x是否一个意思,并且把结果的一致性反馈给这两个模型进行改进。同样的,从中文取个句子,这样循环翻译一遍,两个模型又能从黑衣女那里获取反馈并改进模型。其实这就是强化学习的过程,每次翻译就是一个action,每个action会从环境(灰衣男或黑衣女)中获取reward,对模型进行改进,直至收敛。&p&也许有的人看到这里会觉得和上世纪提出的Co-training很像,这个在知乎上也有讨论:&/p&&a href=&/question/& class=&internal&&如何理解刘铁岩老师团队在NIPS 2016上提出的对偶学习(Dual Learning)?&/a&&p&个人觉得还是不一样的,Co-Training是一种multi-view方法,比如一个输入x,如果看作是两个拼一起的特征&img src=&/equation?tex=x%3D%28x_1%2Cx_2%29& alt=&x=(x_1,x_2)& eeimg=&1&&,并且假设&img src=&/equation?tex=x_1& alt=&x_1& eeimg=&1&&和&img src=&/equation?tex=x_2& alt=&x_2& eeimg=&1&&互相独立,那么这时候训练两个分类器&img src=&/equation?tex=f_1%28%5Ccdot%29& alt=&f_1(\cdot)& eeimg=&1&&和&img src=&/equation?tex=f_2%28%5Ccdot%29& alt=&f_2(\cdot)& eeimg=&1&&对于任意样本x应该有&img src=&/equation?tex=f_1%28x_1%29%3Df_2%28x_2%29& alt=&f_1(x_1)=f_2(x_2)& eeimg=&1&&。这对没有标注的样本是很有用的,相当于利用了同一个样本分类结果就应该一样的隐含约束。所以Co-Training的典型场景是少量标注+大量未标注的半监督场景。并且&img src=&/equation?tex=f_1& alt=&f_1& eeimg=&1&&和&img src=&/equation?tex=f_2& alt=&f_2& eeimg=&1&&其实是两个不同,但是domain指向相同的任务。而Dual Learning中&img src=&/equation?tex=f& alt=&f& eeimg=&1&&和&img src=&/equation?tex=g& alt=&g& eeimg=&1&&是对偶任务,利用的隐含约束是&img src=&/equation?tex=x%5Crightarrow+y%5Crightarrow+x& alt=&x\rightarrow y\rightarrow x& eeimg=&1&&的cycle consistency。对输入的特征也没有像Co-Training有那么明确的假设,学习方法上也不一样,Dual Learning算是强化学习。&/p&&h2&CycleGAN和未配对图像翻译(Unpaired Image-to-Image Translation)&/h2&&p&CycleGAN,翻译过来就是:轮着干,是结合了对偶学习和GAN一个很直接而巧妙的想法[10],示意图如下:&/p&&figure&&img src=&/v2-9e7396ebccb7c42302fc97_b.jpg& data-rawwidth=&838& data-rawheight=&216& class=&origin_image zh-lightbox-thumb& width=&838& data-original=&/v2-9e7396ebccb7c42302fc97_r.jpg&&&/figure&&p&X和Y分别是两种不同类型图的集合,比如穿衣服的女优和没穿衣服的女优。所以给定一张穿了衣服的女优,要变成没穿衣服的样子,就是个图片翻译问题。CycleGAN示意图中(b)和(c)就是Dual Learning:&/p&&figure&&img src=&/v2-de51cac58b_b.jpg& data-rawwidth=&347& data-rawheight=&62& class=&content_image& width=&347&&&/figure&&p&在Dual Learning基础上,又加入了两个判别器&img src=&/equation?tex=D_X& alt=&D_X& eeimg=&1&&和&img src=&/equation?tex=D_Y& alt=&D_Y& eeimg=&1&&用来进行对抗训练,让翻译过来的图片尽量逼近当前集合中的图片:&/p&&p&&figure&&img src=&/v2-e0ea7a6b38bf2a20cea4ea6f741a4c67_b.jpg& data-rawwidth=&442& data-rawheight=&59& class=&origin_image zh-lightbox-thumb& width=&442& data-original=&/v2-e0ea7a6b38bf2a20cea4ea6f741a4c67_r.jpg&&&/figure&全考虑一起,最终的loss是:&/p&&p&&figure&&img src=&/v2-e6d99e7edea969da3dad_b.jpg& data-rawwidth=&357& data-rawheight=&87& class=&content_image& width=&357&&&/figure&也许有人会问,那不加cycle-consistency,直接用GAN学习一个&img src=&/equation?tex=X%5Crightarrow+Y& alt=&X\rightarrow Y& eeimg=&1&&的映射,让生成的Y的样本尽量毕竟Y里本身的样本可不可以呢?这个作者在文中也讨论了,会产生GAN训练中容易发生的mode collapse问题。mode collapse问题的一个简单示意如下[1]:&/p&&p&&figure&&img src=&/v2-309fce6329592babb784ed_b.jpg& data-rawwidth=&842& data-rawheight=&262& class=&origin_image zh-lightbox-thumb& width=&842& data-original=&/v2-309fce6329592babb784ed_r.jpg&&&/figure&上边的是真实分布,下边的是学习到的分布,可以看到学习到的分布只是完整分布的一部分,这个叫做partial mode collapse,是训练不收敛情况中常见的一种。如果是完全的mode collapse,就是说生成模型得到的都是几乎一样的输出。而加入Cycle-consistency会让一个domain里不同的样本都尽量映射到另一个domain里不同的地方,理想情况就是双射(bijection)。直观来理解,如果通过&img src=&/equation?tex=X%5Crightarrow+Y& alt=&X\rightarrow Y& eeimg=&1&&都映射在Y中同一个点,那么这个点y通过&img src=&/equation?tex=Y%5Crightarrow+X& alt=&Y\rightarrow X& eeimg=&1&&映射回来显然不可能是多个不同的x,所以加入cycle-consistency就帮助避免了mode collapse。这个问题在另一篇和CycleGAN其实本质上没什么不同的方法DiscoGAN中有更详细的讨论[11],有兴趣的话可以参考。&/p&&br&&p&有一点值得注意的是,虽然名字叫CycleGAN,并且套路也和C-GAN很像,但是其实只有adversarial,并没有generative。因为严格来说只是学习了&img src=&/equation?tex=X%5Crightarrow+Y& alt=&X\rightarrow Y& eeimg=&1&&和&img src=&/equation?tex=Y%5Crightarrow+X& alt=&Y\rightarrow X& eeimg=&1&&的mapping,所谓的generative network里并没有随机性。有一个和CycleGAN以及DiscoGAN其实本质上也没什么不同的方法叫DualGAN[12],倒是通过dropout把随机性加上了。不过所有加了随机性产生的样本和原始样本间的cycle-consistency用的还是l1 loss,总觉得这样不是很对劲。当然现在GAN这么热门,其实只要是用了adversarial loss的基本都会取个名字叫XXGAN,也许是可以增加投稿命中率。&/p&&p&另外上节中提到了Co-Training,感觉这里也应该提一下CoGAN[13],因为名字有些相似,并且也可以用于未配对的图像翻译。CoGAN的大体思想是:如果两个Domain之间可以互相映射,那么一定有一些特征是共有的。比如男人和女人,虽然普遍可以从长相区分,但不变的是都有两个眼睛一个鼻子一张嘴等等。所以可以在生成的时候,把生成共有特征和各自特征的部分分开,示意图如下:&br&&/p&&p&&figure&&img src=&/v2-57eaadc8cec5190bfd30_b.jpg& data-rawwidth=&758& data-rawheight=&207& class=&origin_image zh-lightbox-thumb& width=&758& data-original=&/v2-57eaadc8cec5190bfd30_r.jpg&&&/figure&其实就是两个GAN结构,其中生成网络和判别网络中比较高层的部分都采用了权值共享(虚线相连的部分),没有全职共享的部分分别处理不同的domain。这样每次就可以根据训练的domain生成一个样本在两个domain中不同的对应,比如戴眼镜和没戴眼镜:&/p&&p&&figure&&img src=&/v2-356a6118ccf3e8e3bf1c7_b.jpg& data-rawwidth=&791& data-rawheight=&267& class=&origin_image zh-lightbox-thumb& width=&791& data-original=&/v2-356a6118ccf3e8e3bf1c7_r.jpg&&&/figure&分别有了共有特征和各自domain特征,那么做mapping的思路也就很直接了[14]:&/p&&p&&figure&&img src=&/v2-8ac50600e40feaac345e09bd7e05a83d_b.jpg& data-rawwidth=&771& data-rawheight=&210& class=&origin_image zh-lightbox-thumb& width=&771& data-original=&/v2-8ac50600e40feaac345e09bd7e05a83d_r.jpg&&&/figure&在GAN前边加了个domain encoder,然后对每个domain能得到三种样本给判别器区分:直接采样,重建采样,从另一个domain中transfer后的重建采样。训练好之后,用一个domain的encoder+另一个domain的generator就很自然的实现了不同domain的转换。用在图像翻译上的效果如下:&/p&&p&&figure&&img src=&/v2-612e9cf5e125fd626be7db_b.jpg& data-rawwidth=&444& data-rawheight=&544& class=&origin_image zh-lightbox-thumb& width=&444& data-original=&/v2-612e9cf5e125fd626be7db_r.jpg&&&/figure&还有个巧妙的思路,是把CoGAN拆开,不同domain作为C-GAN条件的更加显式的做法[15]:&/p&&br&&p&&figure&&img src=&/v2-ddec16d502c94f91ea35_b.jpg& data-rawwidth=&883& data-rawheight=&398& class=&origin_image zh-lightbox-thumb& width=&883& data-original=&/v2-ddec16d502c94f91ea35_r.jpg&&&/figure&第一步用噪声Z作为和domain无关的共享表征对应的latent noise,domain信息作为条件C训练一个C-GAN。第二步,训练一个encoder,利用和常见的encode-decode结构相反的decode(generate)-encode结构。学习好的encoder可以结合domain信息,把输入图像中和domain无关的共享特征提取出来。第三步,把前两步训练好的encoder和decoder(generator)连一起,就可以根据domain进行图像翻译了。&/p&&p&CoGAN一系的方法虽然结构看起来更复杂,但个人感觉理解起来要比dual系的方法更直接,并且有latent space,可解释性和属性对应也好一些。&/p&&p&又扯远了,还是回到正题:&/p&&br&&h2&给女优穿上衣服&/h2&&p&其实同样没什么好说的,Cycle-GAN和pix2pix的作者是一拨人,文档都写得非常棒,准备好数据,分成穿衣服的和没穿衣服的两组,按照文档的步骤训练就可以:&/p&&p&Torch版Cycle-GAN:&a href=&/?target=https%3A///junyanz/CycleGAN& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&junyanz/CycleGAN&i class=&icon-external&&&/i&&/a&&/p&&p&pyTorch版Cycle-GAN(pix2pix二合一版):&a href=&/?target=https%3A///junyanz/pytorch-CycleGAN-and-pix2pix& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&junyanz/pytorch-CycleGAN-and-pix2pix&i class=&icon-external&&&/i&&/a&&/p&&p&Cycle-GAN收敛不易,我用了128x128分辨率训练了穿衣服和没穿衣服的女优各一千多张,同样是默认参数训练了120个epoch,最后小部分成功“穿衣服”的结果如下:&/p&&figure&&img src=&/v2-fee34d66c386e0e01e5804_b.jpg& data-rawwidth=&1117& data-rawheight=&192& class=&origin_image zh-lightbox-thumb& width=&1117& data-original=&/v2-fee34d66c386e0e01e5804_r.jpg&&&/figure&&figure&&img src=&/v2-de57c5ebefa4251ee3caa1_b.jpg& data-rawwidth=&1117& data-rawheight=&192& class=&origin_image zh-lightbox-thumb& width=&1117& data-original=&/v2-de57c5ebefa4251ee3caa1_r.jpg&&&/figure&&p&虽然都有些突兀,但好歹是穿上衣服了。注意马赛克不是图片里就有的,是我后来加上去的。&/p&&p&那么,脱衣服的例子在哪里?&/p&&figure&&img src=&/v2-480fb8a4dcfc7a4f92ec_b.jpg& data-rawwidth=&75& data-rawheight=&60& class=&content_image& width=&75&&&/figure&&h2&参考文献&/h2&&p&[1] I. Goodfellow. Nips 2016 tutorial: Generative adversarial networks. arXiv preprint arXiv:, 2016.&/p&&p&[2] A. B. L. Larsen, S. K. S?nderby, Generating Faces with Torch. &a href=&/?target=http%3A//torch.ch/blog//gan.html& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Torch | Generating Faces with Torch&i class=&icon-external&&&/i&&/a&&/p&&p&[3] A. B. L. Larsen, S. K. S?nderby, H. Larochelle, and O. Winther. Autoencoding beyond pixels using a
learned similarity metric. In ICML, pages , 2016.
&/p&&p&[4] C. Ledig, L. Theis, F. Huszar, J. Caballero, A. Aitken, A. Tejani, J. Totz, Z. Wang, and W. Shi. Photo-realistic single image super-resolution using a generative adversarial network. arXiv:, 2016.&/p&&p&[5] P. Isola, J.-Y. Zhu, T. Zhou, and A. A. Efros. Image-to-image translation with conditional adversarial networks. arxiv, 2016. &/p&&p&[6] O. Ronneberger, P. Fischer, and T. Brox. U-net: Convolutional networks for biomedical image segmentation. In MICCAI, pages 234–241. Springer, 2015.&/p&&p&[7] B. Zhou, A. Khosla, A. Lapedriza, A. Oliva, and A. Torralba. Learning deep features for discriminative localization. arXiv preprint arXiv:, 2015.&/p&&p&[8] He, D., Xia, Y., Qin, T., Wang, L., Yu, N., Liu, T.-Y., and Ma, W.-Y. (2016a). Dual learning for machine translation. In the Annual Conference on Neural Information Processing Systems (NIPS), 2016.&/p&&br&&p&[9] &a href=&/?target=http%3A//www.dsrg.stuorg.iastate.edu/wp-content/uploads/2017/02/dual-learning_-pushing-the-new-frontier-of-artificial-intelligence-tieyan-liu.pdf& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&& Tie-Yan Liu, Dual Learning: Pushing the New Frontier of Artificial Intelligence, MIFS 2016&i class=&icon-external&&&/i&&/a&&br&&/p&&p&[10] J.-Y. Zhu, T. Park, P. Isola, and A. A. Efros. Unpaired image-to-image translation using cycle-consistent adversarial networkss. arXiv preprint arXiv:, 2017.&/p&&p&[11] T. Kim, M. Cha, H. Kim, J. Lee, and J. Kim. Learning to Discover Cross-Domain Relations with Generative Adversarial Networks. ArXiv e-prints, Mar. 2017.&/p&&br&&p&[12] Z. Yi, H. Zhang, P. T. Gong, et al. DualGAN: Unsupervised dual learning for image-to-image translation. arXiv preprint arXiv:, 2017.&/p&&br&&p&[13] M.-Y. Liu and O. Tuzel. Coupled generative adversarial networks. In Advances in Neural Information Processing Systems (NIPS), 2016.&/p&&p&[14] M.-Y. Liu, T. Breuel, and J. Kautz. Unsupervised image-to-image translation networks. arXiv preprint arXiv:, 2017.&/p&&p&[15] Dong, H., Neekhara, P., Wu, C., Guo, Y.: Unsupervised image-to-image translation with generative adversarial networks. arXiv preprint arXiv:, 2017.&/p&&p&=========== 分割线: ===========&/p&&p&上周日发的时候也想到了可能会有许多人对这个话题感兴趣,但没想到超过了1.5W赞这么多,大概看了看评论,做一些补充:&/p&&p&&b&1) &/b&马赛克训练数据:对于一般的机器学习问题,都是分布越简单越容易,遵循这个原则,我用的约束是单人照片,具体方法是:先找一个Pascal VOC训练好的SSD代码,然后SSD筛选了一批每张图里只能检测到一个人的。&/p&&p&最后在真人照片上的效果看上去还是不错的,我没有做过量化评估,大体来说看上去挺像的要超过一半,非常逼真的可能有5%~10%。两人以上战斗的动作画面我没有评估过。&/p&&p&&b&2)&/b&穿(tuo)衣训练数据:因为收敛很难,所以数据的加了更多约束:只用女性单人正面照片。同样通过SSD检测出单人照片,同时考虑person框的宽高比小于1的且框内能检测到人脸的(OpenCV的人脸检测)。这样尽量筛选出一批面向镜头,身体占画面比接近的照片。&/p&&p&最后的效果我在原文中也提到过,只有小部分能成功穿上(tuo)衣服,具体我也没有量化统计过,大概100张里两三张吧,大部分都是身上出现了看上去有点像衣服的线条或是另一个人的胸部。考虑到我最后筛选出的图片人物占画面比仍然有很大的变化,很可能我的模型就是遇到了文中提到的partial mode collapse的问题。&/p&&p&如果有更好的办法筛选出人物大小差不多的照片,效果应该能提升不少。比如我在用SSD筛选的时候如果考虑宽高比更小一些,筛选出的照片看上去会更加一致,不过我资源不太够,这样做后训练集就只有不到300张,资源够的老司机们有兴趣可以试试。&/p&&br&&p&&b&3)&/b&预训练模型有没有?有,但是我研读了中华人民共和国刑法第三百六十三、三百六十四和三百六十六条,完全读不懂,所以还是不提供。再说就算我提供了,根据1)和2),看到你想看的内容也是需要运气的。&/p&&p&另外特别感谢赞赏的知友们,这篇文章是想说&b&书中自有颜如玉&/b&,而知友们的赞赏让我知道&b&书中真有黄金屋&/b&,古人诚不我欺…&/p&
作为一名久经片场的老司机,早就想写一些探讨驾驶技术的文章。这篇就介绍利用生成式对抗网络(GAN)的两个基本驾驶技能: 1) 去除(爱情)动作片中的马赛克2) 给(爱情)动作片中的女孩穿(tuo)衣服 生成式模型上一篇《》中已经简单介…
&figure&&img src=&/v2-49bdcfdffddd_b.jpg& data-rawwidth=&959& data-rawheight=&310& class=&origin_image zh-lightbox-thumb& width=&959& data-original=&/v2-49bdcfdffddd_r.jpg&&&/figure&&p&&b&00x0&/b&&/p&&p&好久都没玩过靶场了,尤其是像这样的纯粹的练习靶场。最近一直有点小沉沦,好似有点忘了最初的目标,不知所措。今天正巧也是我的生日,所以,打打靶场吧,算是休闲一下,正所谓 勿忘初心 。&br&&/p&&p&btslab 原版靶场源码地址:&/p&&div class=&highlight&&&pre&&code class=&language-python&&&span&&/span&&span class=&n&&https&/span&&span class=&p&&:&/span&&span class=&o&&//&/span&&span class=&n&&github&/span&&span class=&o&&.&/span&&span class=&n&&com&/span&&span class=&o&&/&/span&&span class=&n&&CSPF&/span&&span class=&o&&-&/span&&span class=&n&&Founder&/span&&span class=&o&&/&/span&&span class=&n&&btslab&/span&
&span class=&err&&链接&/span&&span class=&p&&:&/span& &span class=&n&&http&/span&&span class=&p&&:&/span&&span class=&o&&//&/span&&span class=&n&&pan&/span&&span class=&o&&.&/span&&span class=&n&&baidu&/span&&span class=&o&&.&/span&&span class=&n&&com&/span&&span class=&o&&/&/span&&span class=&n&&s&/span&&span class=&o&&/&/span&&span class=&mi&&1&/span&&span class=&n&&bQKKai&/span& &span class=&err&&密码&/span&&span class=&p&&:&/span& &span class=&n&&p3rr&/span&
&/code&&/pre&&/div&&p&btslab 汉化版靶场源码地址:&br&&/p&&div class=&highlight&&&pre&&code class=&language-python&&&span&&/span&&span class=&err&&链接&/span&&span class=&p&&:&/span& &span class=&n&&http&/span&&span class=&p&&:&/span&&span class=&o&&//&/span&&span class=&n&&pan&/span&&span class=&o&&.&/span&&span class=&n&&baidu&/span&&span class=&o&&.&/span&&span class=&n&&com&/span&&span class=&o&&/&/span&&span class=&n&&s&/span&&span class=&o&&/&/span&&span class=&mi&&1&/span&&span class=&n&&dE0Woxj&/span& &span class=&err&&密码&/span&&span class=&p&&:&/span& &span class=&mi&&54&/span&&span class=&n&&wu&/span&
&/code&&/pre&&/div&&p&百度网盘里存的,我自己写了一个简易的搭建方法,在源码里放着了。&/p&&p&&b&00x1&/b&&br&&/p&&p&为什么记录 XSS?因为,以前玩那个 Sqli labs ,把 SQL 快玩吐了。。。。&br&&/p&&p&反射型第一关,&/p&&p&&figure&&img src=&/v2-0bd5febd90d_b.jpg& data-rawwidth=&976& data-rawheight=&281& class=&origin_image zh-lightbox-thumb& width=&976& data-original=&/v2-0bd5febd90d_r.jpg&&&/figure&进入第一关,看到是一个搜索框,一下子思路就来了,这TM不就直接输入弹出来了啊!&br&&/p&&p&&figure&&img src=&/v2-6e659e50e10f4f8e444ad27133dbaa67_b.jpg& data-rawwidth=&1366& data-rawheight=&730& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-6e659e50e10f4f8e444ad27133dbaa67_r.jpg&&&/figure&啥都不说,只截上 XSS 代码! &script&alert('shiyan')&/script&&br&&/p&&p&&figure&&img src=&/v2-711d7aa3eec_b.jpg& data-rawwidth=&1366& data-rawheight=&730& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-711d7aa3eec_r.jpg&&&/figure&反射型第二关,&/p&&p&&figure&&img src=&/v2-ce7a8d86f_b.jpg& data-rawwidth=&991& data-rawheight=&325& class=&origin_image zh-lightbox-thumb& width=&991& data-original=&/v2-ce7a8d86f_r.jpg&&&/figure&打开界面,感觉有点难度了。。。&/p&&p&&figure&&img src=&/v2-c601f0cfa1bba3afe85748_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-c601f0cfa1bba3afe85748_r.jpg&&&/figure&它是切换背景颜色,可操作的地方,只有上面的 URL 处,那就继续复制上面的代码,试试看被。 &script&alert('shiyan')&/script&&/p&&p&&figure&&img src=&/v2-ac6eedb048d80844cae79ab_b.jpg& data-rawwidth=&1366& data-rawheight=&730& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-ac6eedb048d80844cae79ab_r.jpg&&&/figure&看到这个区别了,我构思了下,闭合下,不就完事了?这一看就是能输出,只是没闭合嘛,构思一下代码,&&&script&alert('shiyan')&/script&&br&&/p&&p&&figure&&img src=&/v2-dcb707e3cf0dbd8ecdf1a8e_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-dcb707e3cf0dbd8ecdf1a8e_r.jpg&&&/figure&不行了,室友刚刚说,社会王又更新了,我果断的又看了一集,快笑死我了,我果断再分享一下吧,微博酷酷的滕。&/p&&p&第一集:&a href=&/?target=http%3A///tv/v/EEbq3riOc%3Ffid%3Db63cb978d6dbef78f623c9df3318ba9& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Sina Visitor System&i class=&icon-external&&&/i&&/a&&/p&&p&好几集了,网速不好,就不贴了。&br&&/p&&p&反射型第三关,&/p&&p&&figure&&img src=&/v2-6a93fe73dac924bef3d3a4c_b.jpg& data-rawwidth=&945& data-rawheight=&325& class=&origin_image zh-lightbox-thumb& width=&945& data-original=&/v2-6a93fe73dac924bef3d3a4c_r.jpg&&&/figure&额,界面好像和第一关的一样,不过按照惯例,肯定难度加大了,先常规的测试一下。&/p&&p&&figure&&img src=&/v2-3ea2d1a3a6e9b49e26dd9d_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-3ea2d1a3a6e9b49e26dd9d_r.jpg&&&/figure&果然,不用说,难度加大了,那就看下网页源代码吧,看看问题出在哪里。&br&&/p&&p&&figure&&img src=&/v2-ab3af17edf1a399b1e53_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-ab3af17edf1a399b1e53_r.jpg&&&/figure&转实体符了,,,,看来这个输入口不好搞,,,不过我发了一个这个。&br&&/p&&p&&figure&&img src=&/v2-ded79771d5acfcf2eb0dce_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-ded79771d5acfcf2eb0dce_r.jpg&&&/figure&那就构造一下,看看。&br&&/p&&p&&figure&&img src=&/v2-d12d006a09a86962bed8dbb6c0524c05_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-d12d006a09a86962bed8dbb6c0524c05_r.jpg&&&/figure&没有弹?不该啊,看下网页源代码。&br&&/p&&p&&figure&&img src=&/v2-415c559d75da2443ccbc73fe3caf3c64_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-415c559d75da2443ccbc73fe3caf3c64_r.jpg&&&/figure&这个啊,简单啊,一个闭合就完事了。&&&script&alert('shiyan')&/script&&br&&/p&&p&&figure&&img src=&/v2-88bfdcf9d4f187c_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-88bfdcf9d4f187c_r.jpg&&&/figure&反射型第四关,&/p&&p&&figure&&img src=&/v2-241ae2db62a365ff70969b_b.jpg& data-rawwidth=&984& data-rawheight=&325& class=&origin_image zh-lightbox-thumb& width=&984& data-original=&/v2-241ae2db62a365ff70969b_r.jpg&&&/figure&感觉到,这一关估计很难的赶脚。。。&br&&/p&&p&&figure&&img src=&/v2-f3fc8cb001a060a8363c8c_b.jpg& data-rawwidth=&1366& data-rawheight=&726& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-f3fc8cb001a060a8363c8c_r.jpg&&&/figure&先常规的走一波,看看情况。。。&script&alert('shiyan')&/script&&br&&/p&&p&&figure&&img src=&/v2-bfc367c409b289ee733ce69cbf091e5d_b.jpg& data-rawwidth=&1366& data-rawheight=&725& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-bfc367c409b289ee733ce69cbf091e5d_r.jpg&&&/figure&确实没有弹,那看下网页源代码分析一下。&/p&&p&&figure&&img src=&/v2-11a40f3d371dc9e78eeb_b.jpg& data-rawwidth=&1366& data-rawheight=&725& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-11a40f3d371dc9e78eeb_r.jpg&&&/figure&发生事故中。。。。。。。&/p&&p&参考国光大神的XSS中:&a href=&/?target=http%3A///2017/pentester.html& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Pentester中的XSS详解 | 国光&i class=&icon-external&&&/i&&/a&&br&&/p&&p&事故发生半个小时。。。。&br&&/p&&p&求助亲友团中。。。。
loid' onclick=alert(0)
&/p&&p&&figure&&img src=&/v2-d5e1dbe1e7465faa16ee0_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-d5e1dbe1e7465faa16ee0_r.jpg&&&/figure&感觉可能原因是因为我丑吧。。。。。&br&&/p&&p&&figure&&img src=&/v2-b0f611fe530279dabc24cf_b.jpg& data-rawwidth=&876& data-rawheight=&365& class=&origin_image zh-lightbox-thumb& width=&876& data-original=&/v2-b0f611fe530279dabc24cf_r.jpg&&&/figure&&b&00x2&/b&&br&&/p&&p&基于 POST 的 XSS 关,&br&&/p&&p&&figure&&img src=&/v2-7cf8e53eee4e0e3b004ec_b.jpg& data-rawwidth=&916& data-rawheight=&323& class=&origin_image zh-lightbox-thumb& width=&916& data-original=&/v2-7cf8e53eee4e0e3b004ec_r.jpg&&&/figure&额,这个关卡,看着有点简单啊。。。。&br&&/p&&p&&figure&&img src=&/v2-f7f80fbd3dc1_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-f7f80fbd3dc1_r.jpg&&&/figure&那就随便过了。。。&script&alert('shiyan')&/script&&br&&/p&&p&&figure&&img src=&/v2-c0e762debe1c_b.jpg& data-rawwidth=&1366& data-rawheight=&726& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-c0e762debe1c_r.jpg&&&/figure&&b&00x3&/b&&/p&&p& 基于DOM型的XSS,&br&&/p&&figure&&img src=&/v2-e21b4c0dd29c4f63d3bbdd4_b.jpg& data-rawwidth=&931& data-rawheight=&337& class=&origin_image zh-lightbox-thumb& width=&931& data-original=&/v2-e21b4c0dd29c4f63d3bbdd4_r.jpg&&&/figure&&p&一到这一关,我瞬间怂了,,,因为我没玩过DOM型的,不过对DOM还是有一点的了解的,先看网页源代码先。&br&&/p&&p&&figure&&img src=&/v2-cc234d35f_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-cc234d35f_r.jpg&&&/figure&把容易出XSS点的代码复制下, 分析一波。&br&&/p&&div class=&highlight&&&pre&&code class=&language-html&&&span&&/span&&span class=&p&&&&/span&&span class=&nt&&script&/span&&span class=&p&&&&/span&
&span class=&kd&&var&/span& &span class=&nx&&loc&/span&&span class=&o&&=&/span&&span class=&nx&&location&/span&&span class=&p&&.&/span&&span class=&nx&&hash&/span&&span class=&p&&.&/span&&span class=&nx&&slice&/span&&span class=&p&&(&/span&&span class=&mi&&1&/span&&span class=&p&&);&/span&
&span class=&nb&&eval&/span&&span class=&p&&(&/span&&span class=&nx&&loc&/span&&span class=&p&&);&/span&
&span class=&p&&&/&/span&&span class=&nt&&script&/span&&span class=&p&&&&/span&
&/code&&/pre&&/div&&p&大致意思就是把 URL 里面带 # 号后面的代码传给 loc ,然后 eval 再执行下,那不就是直接构造个就弹啊?&br&&/p&&p&&figure&&img src=&/v2-ab40e62b162f1e1c093f34c0bdd211f9_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-ab40e62b162f1e1c093f34c0bdd211f9_r.jpg&&&/figure&这里有一个囧事,我一直在摁回车,还想着为啥不弹,,,最后最后刷新了一下,就弹了。。。加载后才弹啊 ,一时没想开。。。&br&&/p&&p&&b&00x4&/b&&/p&&p&HTTP引用,&/p&&p&&figure&&img src=&/v2-f4fa5a6c009ce0b4b25cdd5abc661302_b.jpg& data-rawwidth=&991& data-rawheight=&374& class=&origin_image zh-lightbox-thumb& width=&991& data-original=&/v2-f4fa5a6c009ce0b4b25cdd5abc661302_r.jpg&&&/figure&第一关,&br&&/p&&p&&figure&&img src=&/v2-a657bf6b4af6f80539f50_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-a657bf6b4af6f80539f50_r.jpg&&&/figure&一看到界面,我就知道简单了,他是在http请求头部,直接输入代码不就弹了。&br&&/p&&p&打开 burp 直接抓包。&br&&/p&&p&&figure&&img src=&/v2-3fece8ecd213d9b32c5dc0_b.jpg& data-rawwidth=&1366& data-rawheight=&723& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-3fece8ecd213d9b32c5dc0_r.jpg&&&/figure&然后输入代码。&script&alert('shiyan')&/script&&br&&/p&&p&&figure&&img src=&/v2-78fd81dcb1bd5d94cbc4e9_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-78fd81dcb1bd5d94cbc4e9_r.jpg&&&/figure&放包,嘿嘿,第一次发现还有这样的自 wei XSS。#(斜眼笑....)&br&&/p&&p&&figure&&img src=&/v2-edddd58dcf84ae_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-edddd58dcf84ae_r.jpg&&&/figure&第二关,&/p&&p&它这里有个小问题,就是第一关和第二关都一样,我也是一脸楞逼啊,然后看了下目录,他估计是没有设置好,那就手动切换下吧。&br&&/p&&p&&figure&&img src=&/v2-aef930a6cd41ba5d3a3387_b.jpg& data-rawwidth=&1366& data-rawheight=&726& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-aef930a6cd41ba5d3a3387_r.jpg&&&/figure&这个关卡杂看着这么和第一关一样了?&br&&/p&&p&&figure&&img src=&/v2-8b3cda82e60eb956f9c21b912ea9194e_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-8b3cda82e60eb956f9c21b912ea9194e_r.jpg&&&/figure&按上面的方法再测试一遍。。。&br&&/p&&p&&figure&&img src=&/v2-b6fe9cb419bf_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-b6fe9cb419bf_r.jpg&&&/figure&#(吐血..........)&br&&/p&&p&我感觉我玩的这两关姿势不对啊,,,&br&&/p&&p&&b&00x5&/b&&/p&&p&用户代理头存在XSS,&br&&/p&&p&&figure&&img src=&/v2-100e53d054a0cf24df70_b.jpg& data-rawwidth=&857& data-rawheight=&300& class=&origin_image zh-lightbox-thumb& width=&857& data-original=&/v2-100e53d054a0cf24df70_r.jpg&&&/figure&用户代理头?那不是还得抓包?&/p&&p&&figure&&img src=&/v2-8a9e2b2a42ca92ba6283c_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-8a9e2b2a42ca92ba6283c_r.jpg&&&/figure&那就抓包玩玩吧。。。。&br&&/p&&p&&figure&&img src=&/v2-aec017abfbcf38bd009f065b723c6dc2_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-aec017abfbcf38bd009f065b723c6dc2_r.jpg&&&/figure&我弹,我弹,我弹弹弹 。&br&&/p&&p&&figure&&img src=&/v2-df4f1ee77c_b.jpg& data-rawwidth=&1366& data-rawheight=&726& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-df4f1ee77c_r.jpg&&&/figure&&b&00x6&/b&&/p&&p&基于 Flash的 XSS ,&br&&/p&&p&&figure&&img src=&/v2-e573ae4af6db249d10923_b.jpg& data-rawwidth=&1013& data-rawheight=&341& class=&origin_image zh-lightbox-thumb& width=&1013& data-original=&/v2-e573ae4af6db249d10923_r.jpg&&&/figure&第一关,&br&&/p&&p&我一进入第一关,就出现了一个连续的跳转。。。&br&&/p&&p&&figure&&img src=&/v2-ce78a5071995eab4f6f81_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-ce78a5071995eab4f6f81_r.jpg&&&/figure&&figure&&img src=&/v2-16f01eb1df2fdcbaabb8589b_b.jpg& data-rawwidth=&1366& data-rawheight=&728& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-16f01eb1df2fdcbaabb8589b_r.jpg&&&/figure&我看了下代码,跳转到另一个页面,那不就是说,我把另一个地址,输入成一个 XSS 地址,不就弹出 XSS了 ?&br&&/p&&p&&figure&&img src=&/v2-05a66be2e5ca97f7a1c1b_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-05a66be2e5ca97f7a1c1b_r.jpg&&&/figure&&figure&&img src=&/v2-93c7d2f4423afc57c8c280e5884a96fb_b.jpg& data-rawwidth=&1366& data-rawheight=&729& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-93c7d2f4423afc57c8c280e5884a96fb_r.jpg&&&/figure&第二关,&br&&/p&&p&看着好炫的界面 .................&br&&/p&&p&&figure&&img src=&/v2-6df8ecedc1a1e42b1aa27a_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-6df8ecedc1a1e42b1aa27a_r.jpg&&&/figure&苦逼十分钟中............&br&&/p&&p&苦逼二十分钟中............&br&&/p&&p&好吧, 我放弃了,谁能看懂的,自己玩玩这个吧,顺便教教我,谁让我是彩笔啊,连个这个都看不懂。。。。&br&&/p&&p&&b&00x7&/b&&/p&&p&储存型 XSS ,&br&&/p&&p&&figure&&img src=&/v2-a1f699ea53a803f98f706cbceef9c934_b.jpg& data-rawwidth=&892& data-rawheight=&302& class=&origin_image zh-lightbox-thumb& width=&892& data-original=&/v2-a1f699ea53a803f98f706cbceef9c934_r.jpg&&&/figure&哈哈,终于到最后一个了,虽说前面的关卡也不难吧,都是一些基础,但是我还是见识了好多XSS 。。。。&/p&&p&&figure&&img src=&/v2-a9bf15cced127d279e3a00e2e635a2f2_b.jpg& data-rawwidth=&1366& data-rawheight=&725& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-a9bf15cced127d279e3a00e2e635a2f2_r.jpg&&&/figure&既然最后一个了,那就好好玩玩吧。。。。&/p&&p&& & &&br&&/p&&p& 这里出现一个错误,没有连接上数据库。。。&/p&&p&如果论坛没有连接数据库的话,在URL处输入
127.0.0.1/btslab/setup.php,然后点击 stup,进行了。&/p&&p&&figure&&img src=&/v2-96a882db1b341cc5fbb5b_b.jpg& data-rawwidth=&1190& data-rawheight=&371& class=&origin_image zh-lightbox-thumb& width=&1190& data-original=&/v2-96a882db1b341cc5fbb5b_r.jpg&&&/figure&& & &&br&&/p&&p&先简单的测试下,他都过滤了什么把,按道理,应该有点什么的限制的吧?&br&&/p&&p&&figure&&img src=&/v2-29b1d238cac5c613e6481_b.jpg& data-rawwidth=&946& data-rawheight=&273& class=&origin_image zh-lightbox-thumb& width=&946& data-original=&/v2-29b1d238cac5c613e6481_r.jpg&&&/figure&&figure&&img src=&/v2-05b1f094c9c7a7cda62b77_b.jpg& data-rawwidth=&942& data-rawheight=&274& class=&origin_image zh-lightbox-thumb& width=&942& data-original=&/v2-05b1f094c9c7a7cda62b77_r.jpg&&&/figure&不能输入单引号?看来没啥难度的储存啊,好歹也是最后一个,原本以为很难的。。。&br&&/p&&p&&figure&&img src=&/v2-b565b415ae397c8cadec7a_b.jpg& data-rawwidth=&1366& data-rawheight=&727& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-b565b415ae397c8cadec7a_r.jpg&&&/figure&&b&00x8&/b&&/p&&p&都是一些简单的 XSS ,不过整体过了一遍后,真心感慨,凡是用户的输入都是不可信啊,得好好把控制好才行。&/p&
00x0好久都没玩过靶场了,尤其是像这样的纯粹的练习靶场。最近一直有点小沉沦,好似有点忘了最初的目标,不知所措。今天正巧也是我的生日,所以,打打靶场吧,算是休闲一下,正所谓 勿忘初心 。 btslab 原版靶场源码地址:/CSPF-Founder/…
&figure&&img src=&/v2-ac0b52ddc78bcd_b.jpg& data-rawwidth=&1200& data-rawheight=&900& class=&origin_image zh-lightbox-thumb& width=&1200& data-original=&/v2-ac0b52ddc78bcd_r.jpg&&&/figure&&p&
Burp Suite 在前段时间更新了v1.7.22版本,其中引入了一个新的模块: Mobile Assistant,它用于配合 Burp Suite 更方便地测试 iOS 应用程序。它可以修改 iOS 设备的系统代理设置,让
HTTP(S) 流量可以轻松重定位到电脑上正在运行的 Burp 。另外它还可以绕过你需要注入 App
的 SSL 证书的验证,拦截、检查和修改所有流量。&/p&&br&&p&&b&安装 Burp Suite Mobile Assistant&/b&&br&&/p&&br&&p&
因为其功能的性质,需要依赖越狱设备上的软件包管理器 Cydia,并且要注意的是,Mobile Assistant 有些功能目前不支持 iOS10,所以在想使用 Mobile Assistant 相应的功能的时候,注意自己设备的固件版本。&/p&&p&安装 Mobile Assiatant 有两种方法,首先是使用 Cydia 安装:&/p&&br&&ol&&li&在PC端打开 Burp Suite,设置好代理监听的接口以及端口,我这里设置的端口为8080,接口为我主机的 IP。&br&&figure&&img src=&/v2-820e68fdb6e47b51afbdf_b.jpg& data-rawwidth=&1366& data-rawheight=&656& class=&origin_image zh-lightbox-thumb& width=&1366& data-original=&/v2-820e68fdb6e47b51afbdf_r.jpg&&&/figure&&br&&/li&&li&在越狱设备上打开 Cydia,打开软件源选项,再编辑、添加。&br&&figure&&img src=&/v2-51be938e2a05d0d2da21_b.jpg& data-rawwidth=&640& data-rawheight=&1136& class=&origin_image zh-lightbox-thumb& width=&640& data-original=&/v2-51be938e2a05d0d2da21_r.jpg&&&/figure&&/li&&li&要使用 HTTP 协议,输入我们 Burp Suite 所在 PC 端的 IP 地址或主机名以及 Burp Suite 监听的端口号。如果 Cydia 无法连接,注意你的监听代理的设置是否正确以及检查计算机防火墙是否关闭。&br&&figure&&img src=&/v2-af9e31a22ffe4bfce6010_b.jpg& data-rawwidth=&640& data-rawheight=&1136& class=&origin_image zh-lightbox-thumb& width=&640& data-original=&/v2-af9e31a22ffe4bfce6010_r.jpg&&&/figure&&br&&/li&&li&添加成功后,Burp Suite 现在应该显示为单个源。&br&&figure&&img src=&/v2-dcecaefa08_b.jpg& data-rawwidth=&640& data-rawheight=&1136& class=&origin_image zh-lightbox-thumb& width=&640& data-original=&/v2-dcecaefa08_r.jpg&&&/figure&&/li&&li&点开单个源:&br&&figure&&img src=&/v2-1dd59d04db7cee_b.jpg& data-rawwidth=&431& data-rawheight=&379& class=&origin_image zh-lightbox-thumb& width=&431& data-original=&/v2-1dd59d04db7cee_r.jpg&&&/figure&&/li&&li&点击mobileassistant应用程序进行安装:&br&&figure&&img src=&/v2-637bc005cc5adcba8b8e99d_b.jpg& data-rawwidth=&424& data-rawheight=&216& class=&origin_image zh-lightbox-thumb& width=&424& data-original=&/v2-637bc005cc5adcba8b8e99d_r.jpg&&&/figure&&br&&/li&&li&点击安装:&br&&figure&&img src=&/v2-74a66ddc45d6ccdb66b9_b.jpg& data-rawwidth=&428& data-rawheight=&424& class=&origin_image zh-lightbox-thumb& width=&428& data-original=&/v2-74a66ddc45d6ccdb66b9_r.jpg&&&/figure&&br&&/li&&li&之后就会进行下载并安装它。在完成之后,您需要重新启动弹出菜单按钮来应用更改。&br&&figure&&img src=&/v2-fb93900bdd5bc6b8ad40f68f_b.jpg& data-rawwidth=&293& data-rawheight=&505& class=&content_image& width=&293&&&/figure&&br&&/li&&li&在安装成功后便会在桌面出现我们的 Mobile Assistant 应用了。&br&&figure&&img src=&/v2-64e71edf5f3_b.jpg& data-rawwidth=&470& data-rawheight=&274& class=&origin_image zh-lightbox-thumb& width=&470& data-original=&/v2-64e71edf5f3_r.jpg&&&/figure&&br&&/li&&/ol&&ul&&ul&&li&还可以让设备通过浏览器访问 Burp Suite 的浏览器界面,即&a href=&/?target=http%3A//192.168.169.22%3A8080& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&http://&/span&&span class=&visible&&192.168.169.22:8080&/span&&span class=&invisible&&&/span&&i class=&icon-external&&&/i&&/a&(主机局域网IP:监听端口)/mobileassistant.deb 来实现安装,下载完成之后通过 Cydia 来完成安装,但是要注意将我们的 deb 格式的安装包导入 /var/root/Media/Cydia/AutoInstall,然后重启 iOS 设备,进入 Cydia 的软件包,就可以发现已经安装好了。 &figure&&img src=&/v2-e5a25ca639cbcd18a0bf5c_b.jpg& data-rawwidth=&640& data-rawheight=&1136& class=&origin_image zh-lightbox-thumb& width=&640& data-original=&/v2-e5a25ca639cbcd18a0bf5c_r.jpg&&&/figure&&br&&/li&&/ul&&/ul&&p&无论是哪种安装方法,都必须要保证我们的主机以及 iOS 设备连接的是同一个网络。&/p&&br&&p&&b&使路由流量通过 Burp&/b&&/p&&br&&p&
首先你要保证你的 Burp 实例正在运行,并且可以从移动设备上进行网络访问,然后在移动设备端的 Burp Suite Mobile Assistant 中设置要进行连接的 Burp Suite 实例的主机 IP 和端口,然后来安装 CA 证书,将 Burp Suite 作为移动设备的代理。在配置完成后,可以通过以下方法来验证你的配置:&/p&&p&1. 网络连接:设备是否能够连接到给定的主机和端口。&/p&&p&2. Burp 验证:给定的主机 IP 和端口上监听服务是否是 Burp Suite 的实例。&/p&&p&3. CA 证书安装:设备是否信任所配置的 Burp Suite 实例的 CA 证书。&/p&&p&4. 启用代理:设备是否通过所提供的主机和端口为 HTTP 和 HTTPS 连接配置的代理服务器。&/p&&p&注意: 移动助手对代理设置所做的更改是短暂的,会在重新启动后恢复原来的设置。在运行
iOS 9.0 版以上的设备时,使用 Mobile Assistant 对代理设置所做的更改不会反映在 iOS 设置应用中。Burp CA 证书的安装在重新启动后不会恢复。&/p&&br&&p&&b&绕过证书锁定&/b&&/p&&br&&p&证书锁定是应用程序用来防御恶意用户扮演可信任服务器的技术,在这种情况下,锁定(pinning)是一种术语,指的是针对本地合法证书进行身份验证(由远程服务器提供 SSL 证书)的过程。所以说,只有当服务器可以提供与应用相匹配的证书可以证明其身份时,才能和远程服务器建立连接。&/p&&p&默认情况下,Burp Suite 通过其自签名的 CA 证书为每台主机生成签名证书。即使设备可能会信任这些证书,但它们无法与应用程序预期的证书相匹配。那么即使该设备已正确配置为
HTTPS 代理,也会造成 Burp Suite 的拦截和查看应用程序流量的能力会被证书锁定削弱。&/p&&p&Burp Suite Mobile Assistant 还可以注入其他应用程序,并且还能挂载到低级系统 API 以破坏证书锁定,从而允许用户拦截流量,甚至在证书锁定执行中的时候也可以。&/p&&p&使用系统 API 、第三方库或自定义代码,可通过不同方式实现证书锁定。然而某些情况下注入应用程序成功也可能无法禁用锁定,这表明应用程序正使用自定义代码执行证书锁定。&/p&&p&注:Mobile Assistant 绕过证书锁定的特性目前暂不支持 iOS 10 版本。&/p&&br&&p&&b&注入到应用程序&br&&/b&将你想要进行测试的 app 添加到列表中,这时候如果该应用程序与列表中的应用程序中至少有一个表项匹配,那么该 app 将会通过绕过证书锁定的方式被注入,接下来我们来介绍一下。&/p&&ol&&li&首先启动 Burp Suite Mobile Assistant,跟启动其他应用程序一样,点击图标:&br&&figure&&img src=&/v2-64e71edf5f3_b.jpg& data-rawwidth=&470& data-rawheight=&274& class=&origin_image zh-lightbox-thumb& width=&470& data-original=&/v2-64e71edf5f3_r.jpg&&&/figure&&br&&/li&&li&设置代理:&br&&figure&&img src=&/v2-5c77af9aa4f80a7957a60_b.jpg& data-rawwidth=&500& data-rawheight=&300& class=&origin_image zh-lightbox-thumb& width=&500& data-original=&/v2-5c77af9aa4f80a7957a60_r.jpg&&&/figure&&br&&/li&&li&点击添加要注入的应用程序:&br&&figure&&img src=&/v2-c44f0c01cd_b.jpg& data-rawwidth=&500& data-rawheight=&300& class=&origin_image zh-lightbox-thumb& width=&500& data-original=&/v2-c44f0c01cd_r.jpg&&&/figure&&br&&/li&&li&添加成功会出现在列表中:&br&&figure&&img src=&/v2-d2d00a402b44ad2664dba4aab22e7e66_b.jpg& data-rawwidth=&500& data-rawheight=&300& class=&origin_image zh-lightbox-thumb& width=&500& data-original=&/v2-d2d00a402b44ad2664dba4aab22e7e66_r.jpg&&&/figure&&br&&/li&&li&之后就可以开启或关闭注入功能了。在开启后,Mobile Assistant 会执行各种检查,如果这个过程发现错误,将会被自动关闭这个功能。同时在开启注入功能之后,我们需要去启动被注入的应用程序(若之前启动了,需要重新启动才能生效):&br&&figure&&img src=&/v2-ef9f883ed735a_b.jpg& data-rawwidth=&500& data-rawheight=&300& class=&origin_image zh-lightbox-thumb& width=&500& data-original=&/v2-ef9f883ed735a_r.jpg&&&/figure&&br&&/li&&li&如果弹出下图所示窗口,表示注入成功:&br&&figure&&img src=&/v2-3cd42a2f7bea44b01c2a6_b.jpg& data-rawwidth=&500& data-rawheight=&300& class=&origin_image zh-lightbox-thumb& width=&500& data-original=&/v2-3cd42a2f7bea44b01c2a6_r.jpg&&&/figure&&br&&/li&&li&点击OK,MobileAssistant将绕过证书锁定,并且应用程序将能使用Burpsuite的自签名证书以数据的形式传输到服务器和客户端之间。&/li&&/ol&&br&&figure&&img src=&/v2-fa170e12bafb35d2c50efb6a_b.jpg& data-rawwidth=&640& data-rawheight=&343& class=&origin_image zh-lightbox-thumb& width=&640& data-original=&/v2-fa170e12bafb35d2c50efb6a_r.jpg&&&/figure&&br& 你可能还想注入到多个相关应用中,可以通过这几种方式来过滤流量:&br&&ol&&li&可执行文件:将会匹配每个可执行文件名称与过滤器值相匹配的应用程序。&br&&/li&&li&软件包 ID:将会匹配有指定软件包 ID 的应用程序,或者有与该软件包 ID 有依赖关系的框架。比如,过滤器 com.apple.UIKit 将所有应用程序与 GUI 匹配; 过滤器
com.apple.Security 将与所有应用程序进行匹配。&br&&/li&&li&类:将会匹配所有实现名称与过滤器值相匹配的类的应用程序。&br&&/li&&/ol&&br&&br&&p&&b&从崩溃中恢复&/b&&br&&/p&&br&&p&注入应用程序和挂载 API 调用的过程中是存在潜在风险。为此,Cydia Substrate 插件在意外情况下可防止设备进入永久崩溃状态。出现 Burp Suite 移动助手崩溃并引发问题的情况时,请参阅 Cydia Substrate 的安全模式来解决。&/p&&br&&p&&b&参考&/b&&b&:&/b&&/p&&br&&a href=&/?target=https%3A//support.portswigger.net/customer/en/portal/articles/2798917-Using%2520Burp_MobileAssistant_Using.html& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Configuring Burp Suite Mobile Assistant&i class=&icon-external&&&/i&&/a&&a href=&/?target=https%3A//support.portswigger.net/customer/en/portal/articles/2798917-Using%2520Burp_MobileAssistant_Using.html& class=& external& target=&_blank& rel=&nofollow noreferrer&&&span class=&invisible&&https://&/span&&span class=&visible&&support.portswigger.net&/span&&span class=&invisible&&/customer/en/portal/articles/2798917-Using%20Burp_MobileAssistant_Using.html&/span&&span class=&ellipsis&&&/span&&i class=&icon-external&&&/i&&/a&&a href=&/?target=https%3A//portswigger.net/burp/help/mobile_testing_using_mobile_assistant.html& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Using Burp Suite Mobile Assistant&i class=&icon-external&&&/i&&/a&&br&&a href=&/?target=https%3A//support.portswigger.net/customer/en/portal/articles/2798916-installing-burp-suite-mobile-assistant& class=& wrap external& target=&_blank& rel=&nofollow noreferrer&&Installing Burp Suite Mobile Assistant&i class=&icon-external&&&/i&&/a&
Burp Suite 在前段时间更新了v1.7.22版本,其中引入了一个新的模块: Mobile Assistant,它用于配合 Burp Suite 更方便地测试 iOS 应用程序。它可以修改 iOS 设备的系统代理设置,让 HTTP(S) 流量可以轻松重定位到电脑上正在运行的 Burp 。另外它还可以绕过…
&figure&&img src=&/v2-556deee66e6f1b9ddb97d9b0c9cd9cd3_b.jpg& data-rawwidth=&1262& data-rawheight=&548& class=&origin_image zh-lightbox-thumb& width=&1262& data-original=&/v2-556deee66e6f1b9ddb97d9b0c9cd9cd3_r.jpg&&&/figure&&p&&b&Pycharm&/b& 作为一款针对 &b&Python&/b& 的编辑器,配置简单、功能强大、使用起来省时省心,对初学者友好,这也是为什么编程教室一直推荐新手使用 &b&Pycharm&/b& 的原因。
本文我们将介绍
&b&pycharm&/b& 编辑器}

我要回帖

更多关于 x射线产生条件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信