Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d5a48df
提交了模型结构
PlumBlossomMaid Feb 24, 2026
d684eb0
增加了原论文中使用的两个数据集相关代码
PlumBlossomMaid Feb 24, 2026
e7abf4c
Remove duplicate import
PlumBlossomMaid Feb 24, 2026
40f1e9b
Merge branch 'PaddlePaddle:develop' into ECFormer-Model
PlumBlossomMaid Feb 27, 2026
8bd193f
Merge branch 'PaddlePaddle:develop' into ECFormer-Datasets
PlumBlossomMaid Feb 27, 2026
16da1d1
Merge branch 'ECFormer-Datasets' of https://github.com/PlumBlossomMai…
PlumBlossomMaid Feb 27, 2026
676ce1f
Merge branch 'ECFormer-Model' of https://github.com/PlumBlossomMaid/P…
PlumBlossomMaid Feb 27, 2026
8b114ff
根据Review要求,添加版权声明
PlumBlossomMaid Feb 27, 2026
33964a0
移动loss和metrics到对应的位置
PlumBlossomMaid Mar 1, 2026
55e472f
完成utils工具迁移
PlumBlossomMaid Mar 1, 2026
247cf95
模型进一步对齐
PlumBlossomMaid Mar 1, 2026
6c10c64
对齐模型权重
PlumBlossomMaid Mar 1, 2026
2d1a259
规范化数据集格式并全部测试通过
PlumBlossomMaid Mar 8, 2026
3b16290
增加了数据集对fp64的支持
PlumBlossomMaid Mar 9, 2026
5c15e0a
修改模型支持fp64
PlumBlossomMaid Mar 9, 2026
f0e1ee2
修复了fp32漏网之鱼
PlumBlossomMaid Mar 10, 2026
7f747fb
Merge branch 'PaddlePaddle:develop' into ECFormer-Model
PlumBlossomMaid Mar 11, 2026
69e554c
fix some import
PlumBlossomMaid Mar 13, 2026
f38913b
Merge branch 'ECFormer-Model' of https://github.com/PlumBlossomMaid/P…
PlumBlossomMaid Mar 13, 2026
1b8e97d
add ECFormer train code
PlumBlossomMaid Mar 13, 2026
5ea9d43
translate Chinese to English
PlumBlossomMaid Mar 14, 2026
4a8c273
Optimize training algorithm
PlumBlossomMaid Mar 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
420 changes: 420 additions & 0 deletions ppmat/datasets/ECDFormerDataset/__init__.py

Large diffs are not rendered by default.

90 changes: 90 additions & 0 deletions ppmat/datasets/ECDFormerDataset/colored_tqdm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from tqdm import tqdm
import time
import os;os.system("") #兼容windows

def hex_to_ansi(hex_color: str, background: bool = False) -> str:
"""
将十六进制颜色转换为ANSI转义序列

Args:
hex_color: 十六进制颜色,如 '#dda0a0' 或 'dda0a0'
background: True表示背景色,False表示前景色

Returns:
ANSI转义序列字符串,如 '\033[38;2;221;160;160m'

Example:
>>> print(f"{hex_to_ansi('#dda0a0')}Hello{hex_to_ansi('#000000')} World")
>>> print(f"{hex_to_ansi('dda0a0', background=True)}背景色{hex_to_ansi.reset()}")
"""
# 移除#号并转换为小写
hex_color = hex_color.lower().lstrip('#')

# 处理简写形式 (#fff -> ffffff)
if len(hex_color) == 3:
hex_color = ''.join([c * 2 for c in hex_color])

# 转换为RGB值
r = int(hex_color[0:2], 16)
g = int(hex_color[2:4], 16)
b = int(hex_color[4:6], 16)

# ANSI真彩色序列
# 38;2;R;G;B 为前景色,48;2;R;G;B 为背景色
code = 48 if background else 38
return f'\033[{code};2;{r};{g};{b}m'

def rgb_to_ansi(r: int, g: int, b: int, background: bool = False) -> str:
"""RGB值直接转ANSI"""
code = 48 if background else 38
return f'\033[{code};2;{r};{g};{b}m'

# 重置颜色的ANSI码
hex_to_ansi.reset = '\033[0m'

class ColoredTqdm(tqdm):
def __init__(self, *args,
start_color=(221, 160, 160), # RGB: #DDA0A0
end_color=(160, 221, 160), # RGB: #A0DDA0
**kwargs):
super().__init__(*args, **kwargs)
self.start_color = start_color
self.end_color = end_color

def get_current_color(self):
progress = self.n / self.total if self.total > 0 else 0
current_rgb = tuple(
int(start + (end - start) * progress)
for start, end in zip(self.start_color, self.end_color)
)
result = current_rgb[0] * 16 ** 4 \
+ current_rgb[1] * 16 ** 2 \
+ current_rgb[2] * 16 ** 0
return "%06x" % result

def update(self, n=1):
super().update(n)
# 使用Rich的真彩色支持
style = hex_to_ansi(self.get_current_color())
self.bar_format = f'{{l_bar}}{style}{{bar}}{hex_to_ansi.reset}{{r_bar}}'
self.refresh()


if __name__ == "__main__":
# 使用示例
for i in ColoredTqdm(range(100), desc="🌈 彩虹渐变"):
time.sleep(0.1)
Loading