Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Hypo
Haystack
提交
84fd3142
H
Haystack
项目概览
Hypo
/
Haystack
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Haystack
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
84fd3142
编写于
1月 09, 2020
作者:
H
HypoX64
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Notes
上级
7ff8f968
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
741 addition
and
12 deletion
+741
-12
CV/find_face.py
CV/find_face.py
+4
-4
Notes/Sublime-settings.md
Notes/Sublime-settings.md
+114
-0
Notes/github.md
Notes/github.md
+105
-0
Notes/linux.md
Notes/linux.md
+138
-0
Notes/python.md
Notes/python.md
+367
-0
README.md
README.md
+13
-8
未找到文件。
CV/find_face.py
浏览文件 @
84fd3142
...
...
@@ -152,7 +152,7 @@ all_length = len(imgpath_list)
print
(
"Find picture:"
+
" "
+
str
(
all_length
))
print
(
'Begining......'
)
print
(
'Finished/Find Face % Bar Usedtime/Totaltime'
)
starttime
=
datetime
.
datetime
.
now
()
face_cnt
=
0
...
...
@@ -165,11 +165,11 @@ with concurrent.futures.ProcessPoolExecutor(max_workers=WORKERS) as executor:
if
i
%
100
==
0
:
endtime
=
datetime
.
datetime
.
now
()
used_time
=
(
endtime
-
starttime
).
seconds
percent
=
round
(
100
*
i
/
all_length
,
2
)
percent
=
round
(
100
*
i
/
all_length
,
1
)
print
(
'
\r
'
,
''
,
'Ok:'
+
str
(
i
),
'Face:
'
+
str
(
face_cnt
)
+
' '
,
print
(
'
\r
'
,
''
,
str
(
i
)
+
'/
'
+
str
(
face_cnt
)
+
' '
,
str
(
percent
)
+
'%'
+
get_bar
(
percent
,
30
),
'
Used/All:
'
+
str
(
int
(
used_time
))
+
's/'
+
str
(
int
(
used_time
/
i
*
all_length
))
+
's'
,
end
=
" "
)
' '
+
str
(
int
(
used_time
))
+
's/'
+
str
(
int
(
used_time
/
i
*
all_length
))
+
's'
,
end
=
" "
)
#starttime_show = datetime.datetime.now()
print
(
'
\n
Finished!'
,
'Finall find face:'
,
face_cnt
,
' Cost time:'
,(
datetime
.
datetime
.
now
()
-
starttime
).
seconds
,
's'
)
\ No newline at end of file
Notes/Sublime-settings.md
0 → 100644
浏览文件 @
84fd3142
[toc]
# Sublime-settings
## ubuntu
### python
#### anaconda
```
json
{
"python_interpreter"
:
"/home/hypo/anaconda3/envs/pytorch/bin/python3"
,
"supress_word_completions"
:
true
,
"supress_explicit_completions"
:
true
,
"complete_parameters"
:
true
,
"anaconda_linting"
:
false
}
```
#### build system
```
json
{
"cmd"
:[
"python"
,
"$file"
],
"path"
:
"/home/hypo/anaconda3/envs/pytorch/bin"
,
"file_regex"
:
"^[ ]*File
\"
(...*?)
\"
, line ([0-9]*)"
,
"selector"
:
"source.python"
,
"encoding"
:
"utf-8"
}
```
## windows
### python
#### anaconda
```
json
{
"python_interpreter"
:
"C:/Users/hypo/Anaconda3/envs/pytorch_0.4.1/python.exe"
,
"supress_word_completions"
:
true
,
"supress_explicit_completions"
:
true
,
"complete_parameters"
:
true
,
"anaconda_linting"
:
false
}
```
#### build system
```
json
{
"cmd"
:[
"python"
,
"$file"
],
"path"
:
"C:/Users/hypo/Anaconda3/envs/pytorch_0.4.1"
,
"file_regex"
:
"^[ ]*File
\"
(...*?)
\"
, line ([0-9]*)"
,
"selector"
:
"source.python"
,
"encoding"
:
"utf-8"
}
```
### java
```
json
{
"cmd"
:
[
"javac"
,
"-encoding"
,
"gbk"
,
"-d"
,
"."
,
"$file"
],
"file_regex"
:
"^(...*?):([0-9]*):?([0-9]*)"
,
"selector"
:
"source.java"
,
"encoding"
:
"gbk"
,
"variants"
:
[
{
"name"
:
"Run"
,
"shell"
:
true
,
"cmd"
:
[
"start"
,
"cmd"
,
"/c"
,
"java ${file_base_name}&pause"
],
"working_dir"
:
"${file_path}"
,
"encoding"
:
"gbk"
}
]
}
```
### c
```
json
{
"working_dir"
:
"$file_path"
,
"cmd"
:
"gcc -Wall
\"
$file_name
\"
-o
\"
$file_base_name
\"
"
,
"file_regex"
:
"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$"
,
"selector"
:
"source.c"
,
"variants"
:
[
{
"name"
:
"Run"
,
"shell_cmd"
:
"gcc -Wall
\"
$file
\"
-o
\"
$file_base_name
\"
&& start cmd /c
\"\"
${file_path}/${file_base_name}
\"
& pause
\"
"
}
]
}
```
### c++
```
json
{
"encoding"
:
"utf-8"
,
"working_dir"
:
"$file_path"
,
"shell_cmd"
:
"g++ -Wall -std=c++11
\"
$file_name
\"
-o
\"
$file_base_name
\"
"
,
"file_regex"
:
"^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$"
,
"selector"
:
"source.c++"
,
"variants"
:
[
{
"name"
:
"Run in sublime"
,
"shell_cmd"
:
"g++ -Wall -std=c++11
\"
$file_name
\"
-o
\"
$file_base_name
\"
&& cmd /c
\"
${file_path}/${file_base_name}
\"
"
},
{
"name"
:
"CMD Run"
,
"shell_cmd"
:
"g++ -Wall -std=c++11
\"
$file
\"
-o
\"
$file_base_name
\"
&& start cmd /c
\"\"
${file_path}/${file_base_name}
\"
& pause
\"
"
}
]
}
```
### matlab
```
json
{
"cmd"
:
[
"C:/Program Files/MATLAB/R2015b/bin/matlab.exe"
,
"-nodesktop"
,
"-nosplash"
,
"-r"
,
"
\"
run('$file')
\"
"
],
"selector"
:
"source.m"
,
"working_dir"
:
"${project_path:${folder}}"
}
```
\ No newline at end of file
Notes/github.md
0 → 100644
浏览文件 @
84fd3142
上传已有的项目
像上面那样,直接从github上clone你自己已有的项目到本地,在你的电脑上面编辑了项目,上传到github上的话,通过如下命令
git pull origin master # 将远程仓库里面的项目拉下来
$ git rm -r --cached target # 删除target文件夹
$ git add
*
###如有新添加的文件执行此行,添加所有的文件
$ git commit -m "输入你本次提交的文字"
$ git push -u origin master
# 表格
name | 111 | 222 | 333 | 444
:-: | :-: | :-: | :-: | :-:
aaa | bbb | ccc | ddd | eee|
fff | ggg| hhh | iii | 000|
1、编辑README文件
大标题(一级标题):在文本下面加等于号,那么上方的文字就变成了大标题,等于号的个数无限制,但一定要大于0
大标题
====
中标题(二级标题):在文本下面加下划线,那么上方的文本就变成了中标题,下划线个数无限制,中标题比大标题低一级
中标题
-------
1~6级标题:文本大小依次减小,以#号开头,多少个#号就是多少级标题,#号和标题名称要并排写
# 一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题
插入圆点符号:编辑的时候使用的是星号
*
,星号后面要有一个空格,否则为普通星号
*
列表一
*
列表二
*
列表三
二级圆点、三级圆点:多加一个Tab,即第二行一个Tab,第三行两个Tab
*
列表一
*
列表二
*
列表三
缩进:
>缩进一
>>缩进二
>>>缩进三
>>>>缩进四
>>>>
>>>>>缩进五
插入链接
[
百度
](
http://baidu.com
)
插入网络图片:!
[](
网络图片链接地址
)
,即叹号!+方括号[]+括号(),如果不加叹号!就会变成普通文本,方括号里可以加入一些 标识性的信息
![
baidu
](
http://www.baidu.com/img/bdlogo.gif
"百度logo"
)
<img
src=
http://www.baidu.com/img/bdlogo.gif
style=
"zoom:50%"
>
插入GITHub仓库里的图片:!
[](
图片链接地址
)
,即叹号!+方括号[]+括号(),URL写法:http://github.com/自己的用户名/项目名/raw/分支名/存放图片的文件夹/文件夹里的图片名字
给图片加上超链接:即点击一个图片进入指定网页,方括号里写自己起的标识名称,上下两行标识要一致。
[
![baidu]
](
http://baidu.com
)
[
baidu
]:
http://www.baidu.com/img/bdlogo.gif
"百度Logo"
插入代码片段:在代码上下行用
```标记,注意`符号是tab键上面那个,要实现语法高亮,则在```
后面加上编程语言的名称
复制代码
```
Java
public static void main(String[] args){}
```
```
javascript
document
.
getElementById
(
"
ts
"
).
innerHTML
=
"
Hello
"
```
复制代码
换行:使用标签
<br>
单行文本:前面使用两个Tab
多行文本:每行行首加两个Tab
部分文字高亮:使用
``
包围,这个符号不是单引号,而是Tab上方,数字1左边那个按键的符号
文字超链接格式:
[
要显示的文字
](
链接的地址"鼠标悬停显示"
)
,在URL之后用双引号括起来一个字符串,即鼠标悬停显示的文本,可不写
Notes/linux.md
0 → 100644
浏览文件 @
84fd3142
[toc]
### 挂载U盘
```
bash
root@lthpc:/home/hypo# fdisk
-l
...
Device Start End Sectors Size Type
/dev/sdc1 2048 7813967871 7813965824 3.7T Microsoft basic data
root@lthpc:/home/hypo#
cd
/media
root@lthpc:/media#
mkdir
usb
root@lthpc:/media# mount
-t
ntfs-3g /dev/sdc1 /media/usb
```
### shell 中运行基本应用
```
bash
nautilus
#文件管理器
firefox
#火狐浏览器
```
### 常用系统命令
*
删除文件
```
bash
rm
-rf
yourdir
#-r 就是向下递归,不管有多少级目录,一并删除
#-f 就是直接强行删除,不作任何提示的意思
```
*
cp
```
bash
cp
[
options] <
source
file or directory> <target file or directory>
# or
cp
[
options] source1 source2 source3 …. directory
#example
cp
-rvf
dir1 dir2
#复制文件夹dir1到dir2,显示进度
cp
-rf
dir1
dir
#复制文件夹dir1到dir2,不显示进度
#-a 保留链接和文件属性,递归拷贝目录,相当于下面的d、p、r三个选项组合。
#-d 拷贝时保留链接。
#-f 删除已经存在目标文件而不提示。
#-i 覆盖目标文件前将给出确认提示,属交互式拷贝。
#-p 复制源文件内容后,还将把其修改时间和访问权限也复制到新文件中。
#-r 若源文件是一目录文件,此时cp将递归复制该目录下所有的子目录和文件。当然,目标文件必须为一个目录名。
#-l 不作拷贝,只是链接文件。
#-s 复制成符号连结文件 (symbolic link),亦即『快捷方式』档案;
#-u 若 destination 比 source 旧才更新 destination。
```
*
deb
```
bash
dpkg
-i
<package.deb>
#安装一个 Debian 软件包,如你手动下载的文件。
dpkg
-c
<package.deb>
#列出 <package.deb> 的内容。
dpkg
-I
<package.deb>
#从 <package.deb> 中提取包裹信息。
dpkg
-r
<package>
#移除一个已安装的包裹。
dpkg
-P
<package>
#完全清除一个已安装的包裹。和 remove 不同的是,remove 只是删掉数据和可执行文件,purge 另外还删除所有的配制文件。
dpkg
-L
<package>
#列出 <package> 安装的所有文件清单。同时请看 dpkg -c 来检查一个 .deb 文件的内容。
dpkg
-s
<package>
#显示已安装包裹的信息。同时请看 apt-cache 显示 Debian 存档中的包裹信息,以及 dpkg -I 来显示从一个 .deb 文件中提取的包裹信息。
dpkg-reconfigure <package>
#重新配制一个已经安装的包裹,如果它使用的是 debconf (debconf 为包裹安装提供了一个统一的配制界面)。
```
*
调整CPU性能模式
```
bash
sudo
apt-get
install
cpufrequtils
cpufreq-info
sudo
cpufreq-set
-g
performance
##修改默认
sudo
apt-get
install
sysfsutils
sudo
gedit /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
```
### 压缩解压
```
bash
tar
xvf filename.tar
#.tar 解包
tar
cvf filename.tar
dirname
#.tar 打包
gunzip
filename.gz
#.gz 解压1
gzip
-d
filename.gz
#.gz 解压2
gzip
filename
#.gz 压缩
tar
zxvf filename.tar.gz
#.tar.gz 和 .tgz 解压
tar
zcvf filename.tar.gz
dirname
#.tar.gz 和 .tgz 压缩
unzip filename.zip
#.zip 解压
zip filename.zip
dirname
#.zip 压缩
rar x filename.rar
#.rar 解压
rar a filename.rar
dirname
#.rar 压缩
#.tar.gz 和 .tgz 多线程压缩解压
sudo
apt
install
pigz
#压缩
tar
cvf - test.txt | pigz
>
test.tar.gz
#解压
tar
-I
pigz
-xvf
/path/to/archive.tar.gz
-C
/where/to/unpack/it/
```
### ssh
*
install
```
bash
sudo
apt-get
install
openssh-client
sudo
apt-get
install
openssh-server
```
*
start
```
bash
ps
-e
|
grep
ssh
sudo
/etc/init.d/ssh start
```
*
ip
```
bash
ifconfig
```
*
login
```
bash
ssh hypo@192.168.0.1
ssh
-X
hypo@192.168.0.1
#GUI
```
*
change port
```
bash
ssh
-p
1234 hypo@192.168.0.1
```
*
exit
```
bash
'Ctrl+D'
#or
exit
```
*
ssh-keygen
```
bash
ssh-keygen
-t
rsa
ssh-copy-id hypo@192.168.0.1
```
*
run code
```
bash
nohup
python3 a.py &
```
*
远程启动火狐(需要在图形模式下)
```
bash
firefox &
```
*
transmit files
```
bash
#压缩+解压流传输 把本地的文件复制到远程主机上
tar
-c
'./dir'
|pigz |ssh hypo@172.31.73.116
"gzip -d|tar -xC /home/hypo/MyProject"
#把远程的文件复制到本地
scp root@www.test.com:/val/test/test.tar.gz /val/test/test.tar.gz
#把本地的文件复制到远程主机上
scp /val/test.tar.gz root@www.test.com:/val/test.tar.gz
#把远程的目录复制到本地
scp
-r
root@www.test.com:/val/test/ /val/test/
```
\ No newline at end of file
Notes/python.md
0 → 100644
浏览文件 @
84fd3142
[toc]
# Python
## base
### main
```
python
def
main
():
pass
if
__name__
==
'__main__'
:
main
()
```
### for
```
python
for
i
,
word
in
enumerate
(
wordlist
,
0
):
```
### read and write txt
*
read
```
python
#method 1
for
line
in
open
(
path
):
line
=
line
.
strip
()
#method 2
def
loadtxt
(
path
):
f
=
open
(
path
,
'r'
)
txt_data
=
f
.
read
()
f
.
close
()
return
txt_data
'''
//r:读
//r+:可读可写,若文件不存在,报错, 进行了覆盖写;
//w+: 可读可写,若文件不存在,创建,进行了清空写;
//a+:可读可写但光标在最后面(然后读到最后面,所以读到空字符串),若文件不存在,创建,进行了追加写;
'''
```
*
write txt
```
python
#method 1
f
=
open
(
path
,
"w+"
)
f
.
writelines
(
list
)
#file.write(str)的参数是一个字符串,就是你要写入文件的内容.
#file.writelines(sequence)的参数是序列,比如列表,它会迭代帮你写入文件。
#method 2
def
writetxt
(
path
,
txt
):
f
=
open
(
path
,
'a+'
)
f
.
write
(
txt
)
f
.
close
()
```
### csv
*
write
```
python
import
csv
csvFile
=
open
(
"csvData.csv"
,
"w"
)
#创建csv文件
writer
=
csv
.
writer
(
csvFile
)
#创建写的对象
#先写入columns_name
writer
.
writerow
([
"index"
,
"a_name"
,
"b_name"
])
#写入列的名称
#写入多行用writerows #写入多行
writer
.
writerows
([[
1
,
a
,
b
],[
2
,
c
,
d
],[
3
,
d
,
e
]])
csvFile
.
close
()
```
*
read
```
python
#load train csv
csv_data
=
[]
reader
=
csv
.
reader
(
open
(
'./datasets/train.csv'
))
for
line
in
reader
:
csv_data
.
append
(
line
)
```
### random
*
radom sort list
```
python
import
random
random
.
shuffle
(
list
)
```
*
random
```
python
import
random
print
(
random
.
randint
(
1
,
10
)
)
# 产生 1 到 10 的一个整数型随机数
print
(
random
.
random
()
)
# 产生 0 到 1 之间的随机浮点数
print
(
random
.
uniform
(
1.1
,
5.4
)
)
# 产生 1.1 到 5.4 之间的随机浮点数,区间可以不是整数
print
(
random
.
choice
(
'tomorrow'
)
)
# 从序列中随机选取一个元素
print
(
random
.
randrange
(
1
,
100
,
2
)
)
# 生成从1到100的间隔为2的随机整数
a
=
[
1
,
3
,
5
,
6
,
7
]
# 将序列a中的元素顺序打乱
random
.
shuffle
(
a
)
random
.
randint
(
1
,
50
)
# 随机整数:
random
.
randrange
(
0
,
101
,
2
)
# 随机选取0到100间的偶数:
random
.
choice
(
'abcdefghijklmnopqrstuvwxyz!@#$%^&()'
)
# 随机字符:
random
.
sample
(
'zyxwvutsrqponmlkjihgfedcba'
,
5
)
# 多个字符中生成指定数量的随机字符:
ran_str
=
''
.
join
(
random
.
sample
(
string
.
ascii_letters
+
string
.
digits
,
8
))
# 从生成指定数量的随机字符:
''
.
join
(
random
.
sample
([
'z'
,
'y'
,
'x'
,
'w'
,
'v'
,
'u'
,
't'
,
's'
,
'r'
,
'q'
,
'p'
,
'o'
,
'n'
,
'm'
,
'l'
,
'k'
,
'j'
,
'i'
,
'h'
,
'g'
,
'f'
,
'e'
,
'd'
,
'c'
,
'b'
,
'a'
],
5
))
# 多个字符中选取指定数量的字符组成新字符串:
random
.
choice
([
'剪刀'
,
'石头'
,
'布'
])
# 随机选取字符串:
```
### path&file
*
get the subfile path
```
python
filenames
=
os
.
listdir
(
path
)
```
*
Get filepath,filename and extension
```
python
(
filepath
,
tempfilename
)
=
os
.
path
.
split
(
output_path
)
(
filename
,
extension
)
=
os
.
path
.
splitext
(
tempfilename
)
```
*
Traversal
```
python
def
Traversal
(
filedir
):
file_list
=
[]
for
root
,
dirs
,
files
in
os
.
walk
(
filedir
):
for
file
in
files
:
file_list
.
append
(
os
.
path
.
join
(
root
,
file
))
for
dir
in
dirs
:
Traversal
(
dir
)
return
file_list
```
*
[
python 获取文件大小,创建时间和访问时间
](
https://www.cnblogs.com/shaosks/p/5614630.html
)
### time
```
python
#ns
import
time
t1
=
time
.
time
()
......
t2
=
time
.
time
()
print
(
t2
-
t1
)
#s
import
datetime
starttime
=
datetime
.
datetime
.
now
()
endtime
=
datetime
.
datetime
.
now
()
print
(
'Cost time:'
,(
endtime
-
starttime
).
seconds
,
's'
)
```
### MulticoreOptimization(concurrent.futures)
```
python
map
(
func
,
*
iterables
,
timeout
=
None
)
#func:为需要异步执行的函数
#iterables:可以是一个能迭代的对象,例如列表等。每一次func执行,会从iterables中取参数。
#timeout:设置每次异步操作的超时时间,如果timeout参数不指定的话,则不设置超时间。
```
*
example 1:
```
python
import
concurrent.futures
def
cut_save_process
(
person_name
):
return
True
with
concurrent
.
futures
.
ProcessPoolExecutor
(
max_workers
=
Process_Worker
)
as
executor
:
for
flag
in
executor
.
map
(
cut_save_process
,
person_names
):
pass
```
*
example 2:
```
python
def
pool_factorizer_go
(
nums
,
nprocs
):
nprocs
=
xxx
with
ProcessPoolExecutor
(
max_workers
=
nprocs
)
as
executor
:
return
{
num
:
factors
for
num
,
factors
in
zip
(
nums
,
executor
.
map
(
factorize_naive
,
nums
))}
```
*
example 3:
```
python
import
concurrent.futures
with
concurrent
.
futures
.
ProcessPoolExecutor
(
max_workers
=
4
)
as
executor
:
for
imgpath
,
count
in
zip
(
imgpath_list
,
executor
.
map
(
find_save_resize_face
,
imgpath_list
,
outpath_list
)):
print
(
imgpath
)
print
(
count
)
```
### re
[
web
](
http://www.runoob.com/python/python-reg-expressions.html
)
*
example1:(find picture)
```
python
re
.
search
(
r
'png$|jpg$|jpeg$|bmp$'
,
filename
,
re
.
I
)
```
*
example2:
```
python
re
.
search
(
r
'(.*) are (.*?) .*'
,
filename
,
re
.
I
)
'''
(.*) 第一个匹配分组,.* 代表匹配除换行符之外的所有字符。
(.*?) 第二个匹配分组,.*? 后面多个问号,代表非贪婪模式,也就是说只匹配符合条件的最少字符
后面的一个 .* 没有括号包围,所以不是分组,匹配效果和第一个一样,但是不计入匹配结果中。
'''
```
*
sort str by number
```
python
import
re
s
=
[
'1.dat'
,
'10.dat'
,
'5.dat'
]
new
=
sorted
(
s
,
key
=
lambda
i
:
int
(
re
.
match
(
r
'(\d+)'
,
i
).
group
()))
```
### multiprocessing
```
python
import
multiprocessing
import
time
def
func
(
msg
):
return
multiprocessing
.
current_process
().
name
+
'-'
+
msg
if
__name__
==
"__main__"
:
pool
=
multiprocessing
.
Pool
(
processes
=
4
)
# 创建4个进程
results
=
[]
for
i
in
range
(
10
):
msg
=
"hello %d"
%
(
i
)
results
.
append
(
pool
.
apply_async
(
func
,
(
msg
,
)))
pool
.
close
()
# 关闭进程池,表示不能再往进程池中添加进程,需要在join之前调用
pool
.
join
()
# 等待进程池中的所有进程执行完毕
print
(
"Sub-process(es) done."
)
for
res
in
results
:
print
(
res
.
get
())
```
### print
*
数字格式化输出
```
python
print
(
'%.2f'
%
(
end
-
start
))
ptint
(
'%05d'
%
i
)
```
*
format
```
python
print
((
'Cpu Temp: {0:.1f}C | Freq: {1:.1f}MHz'
).
format
(
cpu_temp
,
cpu_freq
))
```
### threading
```
python
import
threading
t
=
threading
.
Thread
(
target
=
tcplink
,
args
=
(
clientsock
,))
#t为新创建的线程
t
.
start
()
```
### argparse
```
python
import
argparse
import
sys
parse
=
argparse
.
ArgumentParser
()
parse
.
add_argument
(
"--savedir"
,
type
=
str
,
default
=
'./'
,
help
=
"Dir to save 'data'"
)
args
,
_
=
parse
.
parse_known_args
(
sys
.
argv
[
1
:])
SAVEDIR
=
args
.
savedir
```
## numpy
*
zeros
```
python
np
.
zeros
(
shape
,
dtype
=
float
,
order
=
'C'
)
'''
u,无符号整数,u8(64位)
f,浮点数,f8(64位)
c,浮点负数,
o,对象,
s,a,字符串,s24
u,unicode,u24
'''
```
*
np.array to list
```
python
a
.
tolist
()
```
## pyinstaller
```
bash
pyinstaller test.py-F
```
## opencv-python
[
Document
](
https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_setup/py_table_of_contents_setup/py_table_of_contents_setup.html
)
### imread
```
python
import
numpy
as
np
import
cv2
img
=
cv2
.
imread
(
'messi5.jpg'
,
0
)
'''
第二个参数是一个标志,指定应该读取图像的方式。
cv2.IMREAD_COLOR:加载彩色图像。任何图像的透明度都将被忽略。这是默认标志。
cv2.IMREAD_GRAYSCALE:以灰度模式加载图像
cv2.IMREAD_UNCHANGED:加载图像,包括alpha通道
您可以简单地分别传递整数1,0或-1,而不是这三个标志。
'''
```
### imshow
```
python
cv2
.
imshow
(
'image'
,
img
)
'''
注意:即使图像路径错误,它也不会抛出任何错误,但会给你print img None
注意:第一个参数是一个窗口名称,它是一个字符串。第二个论点是我们的图像。您可以根据需要创建任意数量的窗口,但具有不同的窗口名称。
注意:有一种特殊情况,您可以在以后创建窗口并将图像加载到该窗口。在这种情况下,您可以指定窗口是否可调整大小。它使用函数cv2.namedWindow()完成。默认情况下,标志为cv2.WINDOW_AUTOSIZE。但是如果指定flag cv2.WINDOW_NORMAL,则可以调整窗口大小。当图像尺寸过大并向窗口添加轨迹栏时,它会很有用。
'''
cv2
.
namedWindow
(
'image'
,
cv2
.
WINDOW_NORMAL
)
cv2
.
imshow
(
'image'
,
img
)
cv2
.
waitKey
(
0
)
cv2
.
destroyAllWindows
()
#以下代码用于按's'并退出则保存图像,或者按ESC键直接退出而不保存。
k
=
cv2
.
waitKey
(
0
)
if
k
==
27
:
# wait for ESC key to exit
cv2
.
destroyAllWindows
()
elif
k
==
ord
(
's'
):
# wait for 's' key to save and exit
cv2
.
imwrite
(
'messigray.png'
,
img
)
cv2
.
destroyAllWindows
()
```
### imwrite
```
python
cv2
.
imwrite
(
filename
,
img
)
```
### split&merge
*
通道拆分
```
python
(
B
,
G
,
R
)
=
cv2
.
split
(
image
)
```
*
通道合并
```
python
zeros
=
np
.
zeros
(
image
.
shape
[:
2
],
dtype
=
"uint8"
)
#生成一个值为0的单通道数组
#分别扩展B、G、R成为三通道。另外两个通道用上面的值为0的数组填充
cv2
.
imshow
(
"Blue"
,
cv2
.
merge
([
B
,
zeros
,
zeros
]))
cv2
.
imshow
(
"Green"
,
cv2
.
merge
([
zeros
,
G
,
zeros
]))
cv2
.
imshow
(
"Red"
,
cv2
.
merge
([
zeros
,
zeros
,
R
]))
```
## matplotlib
## pytorch
[
org
](
https://pytorch.org/
)
[
Document_Chinese
](
https://pytorch-cn.readthedocs.io/zh/latest/
)
### hello
```
import torch
torch.cuda.is_available()
print(torch.rand(3,3).cuda())
```
### save and load
```
python
torch
.
save
(
net
.
cpu
().
state_dict
(),
model_name
)
net
=
UNet
(
n_channels
=
3
,
n_classes
=
1
)
net
.
load_state_dict
(
torch
.
load
(
model_name
))
```
# Anaconda
## install
1.
download 'Anaconda3-2019.07-Linux-x86_64.sh'
2.
sh 'Anaconda3-2019.07-Linux-x86_64.sh'
3.
if failed:
```
bash
vim ~/.bashrc
export
PATH
=
$PATH
:/home/hypo/anaconda3/bin
source
~/.bashrc
```
### basic commands
```
bash
conda
--version
#查看conda版本
conda update conda
#更新conda
conda create
--help
#查看conda环境管理命令帮助信息
conda create
--name
envname
#新建虚拟环境
conda remove
--name
envname
--all
#删除虚拟环境
conda list
#查看当前环境安装的包
conda info
--envs
#查看conda环境信息
conda activate envname
#激活环境
conda deactivate
#退出当前环境
```
### solution
*
conda安装环境出现safetyerror
```
bash
conda remove
-n
<
env
name>
--all
#删除该环境所有包
conda clean
-a
#清空anaconda pkg缓存
```
### 换源
```
bash
conda config
--add
channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config
--add
channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config
--add
channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
#设置搜索时显示通道地址
conda config
--set
show_channel_urls
yes
# or linux下将以上配置文件写在~/.condarc中
vim ~/.condarc
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls:
true
```
README.md
浏览文件 @
84fd3142
## Haystack
Gadgets for learning and research
Gadgets
and notes
for learning and research
### System
*
monitor_linux.py
*
[
monitor_linux.py
](
./System/monitor_linux.py
)
A simple Deep Learning Server performance monitor. Written by python without any dependencies.
```
bash
(
base
)
hypo@lthpc:~
$
python monitor_linux.py
...
...
@@ -11,11 +11,11 @@ Util: 85.6% [###########################################-------]
Memory Mem: 34354MB/64301MB | Swap: 0MB/62498MB
Mem: 53.0%
[
#############------------] Swap: 0.0% [-------------------------]
Gpu0: TITAN V Temp: 45.0C | Power:
11w/250w | Mem:
0MB/12066MB | Fan: 31%
Util:0.0%
[
-------------------------
]
Mem:
0.0%
[
--
-----------------------
]
Gpu0: TITAN V Temp: 45.0C | Power:
28w/250w | Mem: 95
0MB/12066MB | Fan: 31%
Util:0.0%
[
-------------------------
]
Mem:
7.9%
[
##
-----------------------]
Gpu1: TITAN V Temp: 4
5.0C | Power: 12w/250w | Mem:
0MB/12066MB | Fan: 31%
Util:0.0%
[
-------------------------
]
Mem:
0.0%
[
--
-----------------------
]
Gpu1: TITAN V Temp: 4
6.0C | Power: 28w/250w | Mem: 95
0MB/12066MB | Fan: 31%
Util:0.0%
[
-------------------------
]
Mem:
7.9%
[
##
-----------------------]
Network ↑ all:10.2GB ↓ all:173.8GB ↑ :147.6Kb/s ↓ :6000.5Kb/s
...
...
@@ -29,7 +29,7 @@ tmpfs /sys/fs/cgroup 0/32G 0%
```
### CV
*
find_face.py
*
[
find_face.py
](
./CV/find_face.py
)
FInd face in images, then save them.
Depend on face_recognition, opencv-python.
```
bash
...
...
@@ -42,4 +42,9 @@ Find picture: 504
Begining......
Ok:500 Face:50 99.21%[##############################] Used/All:143s/144s
Finished! Finall find face: 50 Cost
time
: 145 s
```
\ No newline at end of file
```
### Notes
*
[
linux.md
](
./Notes/linux.md
)
*
[
python.md
](
./Notes/python.md
)
*
[
github.md
](
./Notes/github.md
)
*
[
Sublime-settings.md
](
./Notes/Sublime-settings.md
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录