Cannot open pip-script.py

这几天一直在折腾faceswap,安装过程中发现各种神奇的bug。首先第一个就是github无法正常访问的问题,clone代码的时候各种提示服务器连接超时。可以修改hosts文件添加以下内容:

# github
#192.30.255.113 github.com
#192.30.255.113 gist.github.com
#151.101.52.133  raw.githubusercontent.com
#151.101.53.194  github.global.ssl.fastly.net
140.82.114.4 github.com
199.232.69.194 github.global.ssl.fastly.net

添加之后执行dns刷新:

ipconfig /flushdns

然后github基本就可以正常访问了。安装完成之后发现出现了另外一个问题,提示没有tensorflow-gpu环境。但是尝试执行安装时又提示下面的错误:

Continue Reading

Porn Data Anaylize — 视频数据初探

'''
--------------------------------------------------------------------------------
福利数据解析
基础数据分析,标题分词,词频统计
-----------------------------------
by:obaby
email: root@obaby.org.cn
blog:http://www.h4ck.org.cn
===================================
参考链接:https://sparkbyexamples.com/pyspark/select-columns-from-pyspark-dataframe/
-------------------------------------------------------------------------------
'''
import jieba
# 通过spark read csv格式文件,从csv header解析数据结构
csv = spark.read.option("header",True).csv("hdfs://localhost:9000/data2/porn_data_movie.csv")
# 数据格式
csv.printSchema()
root
 |-- id: string (nullable = true)
 |-- create: string (nullable = true)
 |-- update: string (nullable = true)
 |-- name: string (nullable = true)
 |-- describe: string (nullable = true)
 |-- source_id: string (nullable = true)
 |-- publish_time: string (nullable = true)
 |-- play_count: string (nullable = true)
 |-- good_count: string (nullable = true)
 |-- bad_count: string (nullable = true)
 |-- link_count: string (nullable = true)
 |-- comment_count: string (nullable = true)
 |-- designation: string (nullable = true)
 |-- category_id: string (nullable = true)
 |-- porn_site_id: string (nullable = true)
 |-- uploader_id: string (nullable = true)
 |-- producer: string (nullable = true)
Continue Reading

Domoticz Baby Weather Plugin

支持彩云天气,和风天气,需要注册开发者账号之后添加apikey之后才能使用。
彩云天气:https://open.caiyunapp.com/
和风天气:https://dev.heweather.com/

支持信息:

  • Temperature – 当前温度
  • Feeling Temperature – 当前体感温度
  • Humidity – 湿度
  • Pressure – 气压
  • PM25 – 当前PM25浓度
  • PM10 – 当前PM10浓度
  • SO2 – 当前PSO2浓度
  • Weather forecast(Today) – 今天天气
  • Weather forecast(Tomorrow) – 明天天气
  • 等等

安装方法:

  1. 下载zip之后解压缩,放入Domoticz/plugins目录下,重启服务端。去网页端添加硬件即可。
  2. 切换到插件目录下,git clone https://github.com/obaby/baby_weather_plugin 重启服务端。去网页端添加硬件即可。
Continue Reading

BroadlinkRM2 Domotizc Plugin插件

每次异常断电树莓派就挂了,之前以为是读写问题,这次停电前主动关机,然后,tm依然挂了。用fsck修复,无数的错误,修复完没有效果。于是重装,重装之后主要就是重新弄好domoticz的博联插件,于是就折腾了一番,把插件的问题进行了修复。

插件原始的wiki页面http://www.domoticz.com/wiki/plugins/BroadlinkRM2.html,已经无法访问了。 并且网上随便一搜,关于这个插件的文章都是四年以前的。新的内容基本没有,我不是插件的原始作者,只是进行了修改和完善。 感谢原作者开发的插件。 虽然一直在用这个插件,但是这个插件配置起来却一点都不轻松,插件依赖于broadlink库。 而这个库在树莓派上安装的时候,虽然能安装成功。但是安装 成功之后多数时间会找不到这个库,从而导致插件启动失败。
插件项目地址:
https://github.com/mjg59/python-broadlink 看项目简介现在已经支持Broadlink RM2, RM3 and RM4 series controllers 。
其实要解决库找不到的问题也简单,不要用pip之类的安装。直接将python-broadlink的broadlink目录拷贝到BroadlinkRM2目录下就可以解决这个问题。
插件进行库搜索的时候会搜索当前插件目录下的库,所以没有必要安装之后再去进行拷贝。 我这里集成的是旧版本的python-broadlink库,如果需要可以替换为新版的库。新版本我没有测试,如果测试ok可以提交个补丁进行说明。

Continue Reading

Alec Radford’s animations for optimization algorithms[FW]

Alec Radford has created some great animations comparing optimization algorithms SGDMomentumNAGAdagradAdadeltaRMSprop (unfortunately no Adam) on low dimensional problems. Also check out his presentation on RNNs.

Noisy moons: This is logistic regression on noisy moons dataset from sklearn which shows the smoothing effects of momentum based techniques (which also results in over shooting and correction). The error surface is visualized as an average over the whole dataset empirically, but the trajectories show the dynamics of minibatches on noisy data. The bottom chart is an accuracy plot.”

Beale’s function: Due to the large initial gradient, velocity based techniques shoot off and bounce around – adagrad almost goes unstable for the same reason. Algos that scale gradients/step sizes like adadelta and RMSProp proceed more like accelerated SGD and handle large gradients with more stability.”

Continue Reading

基于DFA的敏感词过滤

在计算理论中,确定有限状态自动机或确定有限自动机(英语:deterministic finite automaton, DFA)是一个能实现状态转移的自动机。对于一个给定的属于该自动机的状态和一个属于该自动机字母表{\displaystyle \Sigma }Σ的字符,它都能根据事先给定的转移函数转移到下一个状态

DFA算法

DFA((Deterministic Finite automation))确定性的有穷状态自动机: 从一个状态输入一个字符集合能到达下一个确定的状态。如图:

 
dfa_1.png

如上图当AB状态输入a得到状态aB,状态aB输入b得到状态ab; 状态AB输入b得到状态Ab,状态Ab输入a得到状态ab。

Continue Reading

jupyter notebook 调整字体 以及matplotlib显示中文

原生的jupyter theme看起来比较蛋疼,尤其是字体和字号。为了修改这个配置可以安装 jupyter theme。

项目链接: https://github.com/dunovank/jupyter-themes 如果不喜欢英文可以参考这个链接:https://www.jianshu.com/p/6de5f6cce06d

上面的样式对应的配置命令:
jt  -f fira -fs 11 -cellw 90% -ofs 11 -dfs 11 -T -t solarizedl

除此之外matplotlib 默认不支持中文显示,主要是字体问题,可以通过下面的代码配置来让matplotlib 支持中文

from matplotlib import pyplot as plt
%matplotlib inline
font = {'family' : 'MicroSoft YaHei',
'weight' : 'bold',
'size' : 10}
plt.rc("font", **font)

实际效果,另外还可以使用altair ,altair 默认支持中文显示 https://altair-viz.github.io