Simon Shi的小站

人工智能,机器学习, 强化学习,大模型,自动驾驶

0%

图片写入表格xlsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from openpyxl import Workbook, load_workbook
from openpyxl.drawing.image import Image
from openpyxl.drawing.spreadsheet_drawing import AnchorMarker, TwoCellAnchor
from openpyxl.styles import Alignment

import os
import shutil
import numpy as np

def GetImgNameByEverDir(dir, property):
filename_with_path = []
filename = []
file_dir = []
for root, dirs, files in os.walk(dir):
print(property)
files = sorted(files)
print('---root---', root)
print('---property---', files)
for file in files:
print(os.path.splitext(file))
if os.path.splitext(file)[1] in property:
filename_with_path.append( os.path.join(root, file))
filename.append(file)
file_dir.append(root+'/')
# print(filename_with_path)
return np.array(filename), np.array(filename_with_path), file_dir

class Generate:
def __init__(self, xls_path, file_dir=None, prompt=''):
self.file_name = xls_path
self.file_dir = file_dir
self.prompt = prompt

def save_one_dir_imgs_to_excel(self, bsize=4, property=['.png','.jpg', '.JPG']):
wb = Workbook()
try:
ws = wb['Sheet']
wb.remove(ws)
except:
print("No sheet named 'Sheet'")

ws = wb.active
print(self.file_dir)
ff, fp, dd = GetImgNameByEverDir(self.file_dir, property)
ff = ff.reshape([-1, bsize])
fp = fp.reshape([-1, bsize])
print(ff)
print(fp)
print(dd)
ws = wb.create_sheet(title="result")
alignment_center = Alignment(horizontal='center', vertical='center')
ws.row_dimensions[1].height = 20
ws.cell(row=1, column=1, value="Prompt").alignment = alignment_center
ws.cell(row=1, column=2, value=self.prompt)

# ws.row_dimensions[1].height = 20
ws.row_dimensions[2].height = 20
ws.cell(row=2, column=1, value="图片").alignment = alignment_center
ws.cell(row=2, column=2, value="Gen1").alignment = alignment_center
ws.cell(row=2, column=3, value="Gen2").alignment = alignment_center
ws.cell(row=2, column=4, value="Gen3").alignment = alignment_center
ws.cell(row=2, column=5, value="打分").alignment = alignment_center

for kk in range(len(fp)):
ws.row_dimensions[kk+3].height = 300
ws.column_dimensions["A"].width = 40
ws.column_dimensions["B"].width = 50
ws.column_dimensions["C"].width = 50
ws.column_dimensions["D"].width = 50
# ws.cell(row=kk+2, column=3, value=fp[kk]).alignment = alignment_center
# ws.cell(row=kk+2, column=2, value=dd[kk]).alignment = alignment_center

row_start = 2
for l in range(len(fp)):
for i in range(bsize):
img = Image(fp[l][i])
_from = AnchorMarker(col=i, colOff=50000, row=l+row_start, rowOff=50000)
to = AnchorMarker(col=i+1, colOff=-50000, row=l+row_start+1, rowOff=-50000)
img.anchor = TwoCellAnchor("twoCell", _from, to)
ws.add_image(img)

wb.save(self.file_name)
print("保存成功")
return self.file_name


import argparse
if __name__ == "__main__":
argparse = argparse.ArgumentParser()
argparse.add_argument('--dir', type=str, default='outputs/20241204-193022-87693-web', help='outputs/20241204-193022-87693-web')
args = argparse.parse_args()

# format_img_names("/mnt/c/Users/simon/Pictures/女")
# xls = os.path.join(args.dir, "result.xlsx")
# ge = Generate(os.path.basename(xls), args.dir, prompt="this is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a test")
# ge.save_one_dir_imgs_to_excel(property=['.png','.jpg', '.JPG'])

xlsx_to_image('result.xlsx', 'result.png', 4, 4)

文件名格式化(format_img_names)

1
2
3
4
5
6
7
8
9
10
import re
def format_img_names(dir_path, replacement='_'):
for root, dirs, files in os.walk(dir_path):
print(root)
for file in files:
sanitized = re.sub(r'[\\/:*?"<>|\r\n]+', replacement, file)
sanitized = sanitized.strip(' _')
sanitized = re.sub(r'[-\s]+', '_', sanitized)
print(file, '---->', sanitized)
os.rename(os.path.join(root, file), os.path.join(root, sanitized))

xlsx_to_image (支持文字,不支持嵌入的图片)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pandas as pd
import matplotlib.pyplot as plt
def xlsx_to_image(input_file, output_image, n_rows, m_cols):
df = pd.read_excel(input_file)
print(df)
sub_data = df.iloc[:n_rows, :m_cols]


plt.figure(figsize=(10, 6))

table = plt.table(cellText=sub_data.values,
colLabels=sub_data.columns,
rowLabels=sub_data.index,
cellLoc='center',
loc='center')
table.auto_set_font_size(False)
table.set_fontsize(12)
table.scale(1, 1.5)

plt.axis('off')
plt.savefig(output_image)

2024年英语二高频真题词汇

T 1

-  [ x ] ~~~anger~~~ - 愤怒
- [ ] exacerbating - 加剧
- [ ] inequality - 不平等
- [x] technology - 技术
- [ ] economist - 经济学家
- [x] progress - 进步
- [ ] automation - 自动化
- [ ] politically - 政治上
- [ ] sustainable - 可持续的
- [ ] prosperity - 繁荣
- [ ] sectors - 部门
- [ ] embrace - 拥抱
- [ ] disruption - 破坏
- [x] transformative - 变革的
- [ ] resentment - 愤恨
- [ ] elites - 精英
- [ ] prosperity - 繁荣
- [ ] disparities - 差异
- [ ] automation - 自动化
- [ ] manufacturing - 制造业
- [ ] clustered - 聚集
- [ ] concentrated - 集中
- [ ] dominance - 主导
- [ ] geographical - 地理的
- [ ] unrest - 动荡
- [ ] federal - 联邦的
- [x] innovation - 创新
- [ ] digital - 数字的
- [ ] opportunities - 机会
Read more »

Improve

  • MScIs 7月

  • MEM 12月

  • 管理类课程

Skill

  • 技术石墨文档-24-26提升
    • Jax
    • 逆强化学习
    • 模仿学习
  • RL-CardGame
  • SD Lora
  • LLM-Dify
  • LLM-FineTune
  • XiaoZhi-开源聊天机器人
  • Nas搭建
    • Jenkins
  • AIGC–动漫视频
Read more »

1
git push -u origin local-branch-name:remote-branch-name

1、str转protobuf对象

1
2
3
4
5
6
7
8
9
10
from example_pb2 import MyMessage

# 假设你有一个包含序列化后的protobuf数据的字符串
serialized_data = b'\n\x05Hello'

# 解析字符串
message = MyMessage()
message.ParseFromString(serialized_data)

print(message.content) # 输出: Hello

2、protobuf对象转str

1
2
3
msg_ctrl = jpush_protocol_pb2.JPushProtocol()
msg_ctrl.head.ver = 0
str = msg_ctrl.SerializeToString()

CODE: https://github.com/RVC-Boss/GPT-SoVITS

DOCEKR https://hub.docker.com/r/breakstring/gpt-sovits/tags

Docs: https://qqk9ntwbcit.feishu.cn/wiki/SdJDwjaYFifxAhkFJVic9u5hn6c

# 3分钟素材!30分钟搞定!使用GPT-SoVITS训练自己的语音模型

CodeWithGPU | 能复现才是好算法

1 前置数据集获取

  • mp3/wav 数据分片

  • 语音降噪

  • 离线ASR(音频标注文本)

  • 打标对比工具

2 TTS

2.A 训练集格式化

2.A.1 开启文本提取

    “/usr/local/bin/python” GPT_SoVITS/prepare_datasets/1-get-text.py

2.A.2 SSL自监督特征提取

    “/usr/local/bin/python” GPT_SoVITS/prepare_datasets/2-get-hubert-wav32k.py

2.A.3 语义token提取

    “/usr/local/bin/python” GPT_SoVITS/prepare_datasets/3-get-semantic.py

2.B FineTune

1、 SoVITS训练

1
"/usr/local/bin/python" GPT_SoVITS/s2_train.py --config "/databig/ddz/sdiffusion/GPT-SoVITS/TEMP/tmp_s2.json"

2、GPT训练

1
"/usr/local/bin/python" GPT_SoVITS/s1_train.py --config_file "/databig/ddz/sdiffusion/GPT-SoVITS/TEMP/tmp_s1.yaml"

2.C 推理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def change_tts_inference(bert_path,cnhubert_base_path,gpu_number,gpt_path,sovits_path, batched_infer_enabled):
global p_tts_inference
if batched_infer_enabled:
cmd = '"%s" GPT_SoVITS/inference_webui_fast.py "%s"'%(python_exec, language)
else:
cmd = '"%s" GPT_SoVITS/inference_webui.py "%s"'%(python_exec, language)
if(p_tts_inference==None):
os.environ["gpt_path"]=gpt_path if "/" in gpt_path else "%s/%s"%(GPT_weight_root,gpt_path)
os.environ["sovits_path"]=sovits_path if "/"in sovits_path else "%s/%s"%(SoVITS_weight_root,sovits_path)
os.environ["cnhubert_base_path"]=cnhubert_base_path
os.environ["bert_path"]=bert_path
os.environ["_CUDA_VISIBLE_DEVICES"]=fix_gpu_number(gpu_number)
os.environ["is_half"]=str(is_half)
os.environ["infer_ttswebui"]=str(webui_port_infer_tts)
os.environ["is_share"]=str(is_share)
yield i18n("TTS推理进程已开启"), {'__type__':'update','visible':False}, {'__type__':'update','visible':True}
print(cmd)
p_tts_inference = Popen(cmd, shell=True)
elif(p_tts_inference!=None):
kill_process(p_tts_inference.pid)
p_tts_inference=None
yield i18n("TTS推理进程已关闭"), {'__type__':'update','visible':True}, {'__type__':'update','visible':False}

webUI

BUG

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  File "/usr/local/lib/python3.9/site-packages/opencc/__init__.py", line 7, in <module>
import opencc_clib
ModuleNotFoundError: No module named 'opencc_clib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/databig/ddz/sdiffusion/GPT-SoVITS/GPT_SoVITS/prepare_datasets/1-get-text.py", line 92, in process
phones, word2ph, norm_text = clean_text(
File "/databig/ddz/sdiffusion/GPT-SoVITS/GPT_SoVITS/text/cleaner.py", line 36, in clean_text
language_module = __import__("text."+language_module_map[language],fromlist=[language_module_map[language]])
File "/databig/ddz/sdiffusion/GPT-SoVITS/GPT_SoVITS/text/chinese2.py", line 28, in <module>
from text.g2pw import G2PWPinyin, correct_pronunciation
File "/databig/ddz/sdiffusion/GPT-SoVITS/GPT_SoVITS/text/g2pw/__init__.py", line 1, in <module>
from text.g2pw.g2pw import *
File "/databig/ddz/sdiffusion/GPT-SoVITS/GPT_SoVITS/text/g2pw/g2pw.py", line 11, in <module>
from .onnx_api import G2PWOnnxConverter
File "/databig/ddz/sdiffusion/GPT-SoVITS/GPT_SoVITS/text/g2pw/onnx_api.py", line 17, in <module>
from opencc import OpenCC
File "/usr/local/lib/python3.9/site-packages/opencc/__init__.py", line 9, in <module>
from opencc.clib import opencc_clib
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /usr/local/lib/python3.9/site-packages/opencc/clib/opencc_clib.cpython-39-x86_64-linux-gnu.so)


fix

1
pip install opencc-python-reimplemented

3D 建模

3D Max 人物、建筑、道具等
Maya 人物、建筑、动物等
ZBrush 人物建模
Blender 开源,社区
shapr3d ipad 收费版
RizomUV
Fusion360 免费3年
revit

3D物体/造型设计,可以选Sketch up / Blender / Wings 3D / Claraio;

3D人物/角色设计,可以选Daz Studio / Blender / ZBrushCore;

工业/产品设计,选Fusion360 / Shapr3D;

如果想把现实中的物体,变成可编辑的模型,选Meshmixer;

复杂生态环境/生长模型设计,可以选Houdini。

shapr3d (ipad工具)

https://www.shapr3d.com/

  • 户型图搭建

快捷键

n 尺寸界面

导出的时候meter不在