aiastia / note

笔记
16 stars 5 forks source link

colab 常用命令 #71

Open aiastia opened 2 years ago

aiastia commented 2 years ago

挂载谷歌云盘

from google.colab import drive
drive.mount('/content/drive')
aiastia commented 2 years ago

显示文件个数

%cd /content/drive/Shareddrives/
!ls -l | grep "^-" | wc -l
!ls -lR| grep "^-" | wc -l
aiastia commented 2 years ago

移动前100个文件到文件B

%cd /content/drive/Shareddrives/小说1/文学读物/中篇9112部
!mkdir /content/drive/Shareddrives/小说1/2
!ls -Q /content/drive/Shareddrives/小说1 | head -800 | xargs -i mv "/content/drive/Shareddrives/小说1/{}" /content/drive/Shareddrives/小说2/8/
aiastia commented 2 years ago

!url=1 ;echo 1+$url

aiastia commented 2 years ago

txt 合并到一个文件带 文件名

a=0
for i in *.txt
 do
 echo $i ;
 a=$(($a + 1));
 echo "第$a 本书" >> all.txt;
 #echo $i >> all.txt ;
 echo ${i%*${i:(-4)}} >> all.txt ;
 cat  "$i" | iconv -f GBK -t UTF-8 >> all.txt
 echo  " " >> all.txt
done
aiastia commented 2 years ago

1.txt

aiastia commented 2 years ago

Linux下的文件批量转换为UTF8编码-enca 一、简介 enca是Linux下的文件编码转换工具。 二、源码包

http://dl.cihar.com/enca/

三、使用方法

enca -L zh_CN file 检查文件的编码 
enca -L zh_CN -x UTF-8 file 将文件编码转换为"UTF-8"编码 
enca -L zh_CN -x utf-8 *  把文件夹下的所有文件转换为utf8编码

四、批量转换

find -type f | xargs enca -L zh_CN -x UTF-8
aiastia commented 2 years ago

!find -type f -name "*.txt"| xargs -i enca -L zh_CN -x UTF-8 "{}"

aiastia commented 2 years ago
a=0
b="152"
g="GB"
u="UTF" 
cd $b
for i in *.txt
 do
 echo $i ;
 a=$(($a + 1));
 echo "第$a 本书:" >> ../$b.txt;
 #echo $i >> 1.txt ;
 echo ${i%*${i:(-4)}} >> ../$b.txt ;
 #cat  "$i" | iconv -f GBK -t UTF-8 >> ../$b.txt
 f=`enca -L zh_CN "$i" | cut -d ';' -f 2 `
 echo $f+1 ;
 if [[ $f == *$g* ]]; then h="GB18030" ;elif [[ $f == *$u* ]]; then h="UTF-8" ;else h="UTF-16";fi
 #if [[ $f = "GB*" ]]; then h="GBK" ;elif [[ $f = "UTF*" ]]; then h="UTF-8" ;else h="UTF-16" ;fi
 echo $h ;
 cat  "$i" | iconv -f $h -t UTF-8 >> ../$b.txt
 #enca -L zh_CN "$i" | cut -d ';' -f 2 |xargs -i cat  "$i" | iconv -f {} -t UTF-8 
 echo  " " >> ../$b.txt
done
aiastia commented 2 years ago

for i in .//.txt

aiastia commented 2 years ago
a=0
find -type f -name "*.txt" -print0 | while read -d $'\0' fn; do
    echo "$fn"
    a=$(($a + 1));
    echo "第$a 本书:"
    echo ${i%*${i:(-4)}}

done
aiastia commented 2 years ago
a=0
b="123"
g="GB"
u="UTF" 
cd $b
find -type f -name "*.txt" -print0 | while read -d $'\0' i; do
    echo "$i"
      a=$(($a + 1));
    echo "第$a 本书:"
    echo ${i%*${i:(-4)}}
    echo $i ;
    a=$(($a + 1));
    echo "第$a 本书:" >> ../$b.txt;
    #echo $i >> 1.txt ;
    echo ${i%*${i:(-4)}} >> ../$b.txt ;
    #cat  "$i" | iconv -f GBK -t UTF-8 >> ../$b.txt
    f=`enca -L zh_CN "$i" | cut -d ';' -f 2 `
    echo $f+1 ;
    if [[ $f == *$g* ]]; then h="GB18030" ;elif [[ $f == *$u* ]]; then h="UTF-8" ;else h="UTF-16";fi
    #if [[ $f = "GB*" ]]; then h="GBK" ;elif [[ $f = "UTF*" ]]; then h="UTF-8" ;else h="UTF-16" ;fi
    echo $h ;
    cat  "$i" | iconv -f $h -t UTF-8 >> ../$b.txt
    #enca -L zh_CN "$i" | cut -d ';' -f 2 |xargs -i cat  "$i" | iconv -f {} -t UTF-8 
    echo  " " >> ../$b.txt
done
aiastia commented 2 years ago

文件切割

split -b 20m log.txt n

aiastia commented 2 years ago

ubuntu 修改 ip

cd /etc/netplan/

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens18:
      dhcp4: true
  version: 2
aiastia commented 2 years ago
# Let NetworkManager manage all devices on this system
network:
    ethernets:
        ens18:                    ## network card name
            dhcp4: false
            addresses:
              - 192.168.0.213/24   ## set static IP
            routes:
              - to: default
                via: 192.168.0.31  ## gateway
            nameservers:
              addresses: [8.8.8.8,8.8.4.4,192.168.0.31]
    version: 2

sudo netplan apply

aiastia commented 1 year ago

不可以色色哦

NovelAI 优化版,在本地实现涩图自由。。

转载的。。。


tag表:https://docs.google.com/spreadsheets/d/e/2PACX-1vRa2HjzocajlsPLH1e5QsJumnEShfooDdeHqcAuxjPKBIVVTHbOYWASAQyfmrQhUtoZAKPri2s_tGxx/pubhtml#

——NovelAI泄露原版前后端部署教程 4chan优化版 naifu 支持 Colab + Linux + win 部署 自带前后端,打开网页就能用,并且可突破 prompt 77 限制 由 4chan 里 Anonymous 大佬制作 Nyanko Lepsoni & 炼铜术士 & @exlolicon 等大佬更改支持Colab

PS.默认使用4G模型 (如果是本地搭建的话)最低8G显存可用,但建议10G显存 (补充:更改 float16 半精准 6G显存可能能跑) 如需使用7G模型,可自行下载,更改启动文件里的模型路径来使用 但注意7G模型要求最低16G显存,且不保证正常使用,最好24G以上 不过4G模型、7G模型和官网,差异都不算大,因此不必强求使用7G模型

—超简单colab一键搭建 白**colab谷歌服务器无需本地显卡 https://colab.research.google.com/drive/1_Ma71L6uGbtt6UQyA3FjqW2lcZ5Bjck- ①↑打开由 colab文档链接,登录谷歌账号,左上角,代码执行程序→全部运行 且注意第一步有没有下载成功,如失败请重新运行 ②直到第三步,会显示 bore.pub:xxx 和 xxx.trycloudflare.com 两个都是前端地址,不同映射隧道,哪个稳定用哪个 但需要等待出现 Application startup complete / 0.0.0.0:6969 字样出现时再访问 ③可选,以 float16 半精准极限运行7G模型 需要结束上方第三步的运行,再运行第四步,依然是等待新地址访问

—Linux 参考 colab 流程即可

—win 下载磁链/打包文件

磁链 magnet:?xt=urn:btih:4a4b483d4a5840b6e1fee6b0ca1582c979434e4d&dn=naifu&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce

打包 https://pub-2fdef7a2969f43289c42ac5ae3412fd4.r2.dev/naifu.tar

①下载 Python (https://www.python.org/downloads/windows/),选中“将 Python 添加到 PATH” 选项来安装。 安装好Python环境后可以重启一下 ②磁链下载需要解压 program.zip 到当前目录,打包下载已自带解压,直接把文件都解压到目录里,不要解压到program文件夹里。 ③运行 setup.bat 等待环境安装完成。 ④再运行 run.bat 启动,等待 0.0.0.0:6969 字样出现时访问内网地址 注:由于win环境不一样,同时国内网络不稳定,因此出现错误时建议自行搜索。

by @StableDiffusion_CN_WIKI