Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,43 @@ pip install -r requirements.txt
|
|
14 |
python app.py
|
15 |
'''
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
#import spaces
|
18 |
import math
|
19 |
import gradio as gr
|
@@ -445,5 +482,10 @@ with block:
|
|
445 |
example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
|
446 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
447 |
|
|
|
|
|
|
|
|
|
|
|
448 |
|
449 |
block.launch(share = True)
|
|
|
14 |
python app.py
|
15 |
'''
|
16 |
|
17 |
+
import os
|
18 |
+
from datasets import load_dataset
|
19 |
+
import uuid
|
20 |
+
|
21 |
+
# 定义保存路径
|
22 |
+
save_path = "./examples/xiangxiang_man"
|
23 |
+
|
24 |
+
# 清空目标路径(如果存在)
|
25 |
+
if os.path.exists(save_path):
|
26 |
+
for file_name in os.listdir(save_path):
|
27 |
+
file_path = os.path.join(save_path, file_name)
|
28 |
+
if os.path.isfile(file_path):
|
29 |
+
os.remove(file_path)
|
30 |
+
print(f"Cleared existing files in {save_path}")
|
31 |
+
else:
|
32 |
+
os.makedirs(save_path, exist_ok=True)
|
33 |
+
print(f"Created directory: {save_path}")
|
34 |
+
|
35 |
+
# 加载数据集
|
36 |
+
dataset = load_dataset("svjack/Prince_Xiang_iclight_v2")
|
37 |
+
|
38 |
+
# 遍历数据集并保存图片
|
39 |
+
for example in dataset["train"]:
|
40 |
+
# 获取图片数据
|
41 |
+
image = example["image"]
|
42 |
+
|
43 |
+
# 生成唯一的文件名(使用 uuid)
|
44 |
+
file_name = f"{uuid.uuid4()}.png"
|
45 |
+
file_path = os.path.join(save_path, file_name)
|
46 |
+
|
47 |
+
# 保存图片
|
48 |
+
image.save(file_path)
|
49 |
+
print(f"Saved {file_path}")
|
50 |
+
|
51 |
+
print("All images have been saved.")
|
52 |
+
|
53 |
+
|
54 |
#import spaces
|
55 |
import math
|
56 |
import gradio as gr
|
|
|
482 |
example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
|
483 |
example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
|
484 |
|
485 |
+
import pathlib
|
486 |
+
lm_l = list(map(str ,pathlib.Path("./examples/xiangxiang_man").rglob("*.png")))
|
487 |
+
gr.Examples(
|
488 |
+
im_l, input_fg
|
489 |
+
)
|
490 |
|
491 |
block.launch(share = True)
|