Skip to content

Commit

Permalink
Add a script to find unused images
Browse files Browse the repository at this point in the history
  • Loading branch information
windsonsea committed Dec 24, 2024
1 parent 6eb9437 commit 4850e1e
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 0 deletions.
Binary file removed docs/zh/docs/dmc/images/create-model.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/dmc-home.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/inner01.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/inner02.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/inner03.jpg
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/inner03.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/local01.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/local04.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/online04.png
Binary file not shown.
Binary file removed docs/zh/docs/dmc/images/tuner01.png
Binary file not shown.
1 change: 1 addition & 0 deletions docs/zh/docs/dmc/model-service/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ hide:
1. 点击模型服务右边的 ┇ 符号,选择 **绑定/解绑工作空间** ,即可将模型服务分享分享到其他工作空间下。绑定后,其他工作空间下的用户就可以直接使用该模型服务。

![绑定/解绑工作空间1](../images/local03.jpg)

![绑定/解绑工作空间2](../images/local04.jpg)

2. 去到分享的工作空间下可查看分享的模型服务,并可以直接使用该模型服务进行 **对话调式****应用创建**
Expand Down
30 changes: 30 additions & 0 deletions scripts/find_unused_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import re

# 图片目录
image_dir = 'docs/zh/docs/dmc/images' # 确保路径正确
# Markdown 文件目录
markdown_dir = 'docs/zh/docs/dmc'

# 收集所有图片文件
images = {f for f in os.listdir(image_dir) if f.endswith(('.jpg', '.png'))}

# 收集在 Markdown 文件中引用的图片
referenced_images = set()

# 使用 os.walk 遍历 Markdown 文件目录及其所有子文件夹
for root, _, files in os.walk(markdown_dir):
for file in files:
if file.endswith('.md'):
with open(os.path.join(root, file), 'r', encoding='utf-8') as f:
content = f.read()
# 使用正则表达式查找所有可能的图片引用
# 修改正则表达式以匹配 "../images/" 前缀
matches = re.findall(r'!\[.*?\]\(\.\./images/(.*?\.(?:jpg|png))\)', content)
# 提取文件名部分并添加到 referenced_images
referenced_images.update(matches)

# 找到未被引用的图片
unused_images = images - referenced_images

print("未被引用的图片文件:", unused_images)

0 comments on commit 4850e1e

Please sign in to comment.