Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,6 +35,42 @@ from face_utils import FaceAnalysis2, analyze_faces
|
|
| 35 |
from style_template import styles
|
| 36 |
from aspect_ratio_template import aspect_ratios
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
# global variable
|
| 39 |
base_model_path = 'SG161222/RealVisXL_V4.0'
|
| 40 |
face_detector = FaceAnalysis2(providers=['CPUExecutionProvider', 'CUDAExecutionProvider'], allowed_modules=['detection', 'recognition'])
|
|
@@ -224,6 +260,12 @@ def get_image_path_list(folder_name):
|
|
| 224 |
|
| 225 |
def get_example():
|
| 226 |
case = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
[
|
| 228 |
get_image_path_list('./examples/scarletthead_woman'),
|
| 229 |
"instagram photo, portrait photo of a woman img, colorful, perfect face, natural skin, hard shadows, film grain",
|
|
|
|
| 35 |
from style_template import styles
|
| 36 |
from aspect_ratio_template import aspect_ratios
|
| 37 |
|
| 38 |
+
import os
|
| 39 |
+
from datasets import load_dataset
|
| 40 |
+
import uuid
|
| 41 |
+
|
| 42 |
+
# 定义保存路径
|
| 43 |
+
save_path = "./examples/xiangxiang_man"
|
| 44 |
+
|
| 45 |
+
# 清空目标路径(如果存在)
|
| 46 |
+
if os.path.exists(save_path):
|
| 47 |
+
for file_name in os.listdir(save_path):
|
| 48 |
+
file_path = os.path.join(save_path, file_name)
|
| 49 |
+
if os.path.isfile(file_path):
|
| 50 |
+
os.remove(file_path)
|
| 51 |
+
print(f"Cleared existing files in {save_path}")
|
| 52 |
+
else:
|
| 53 |
+
os.makedirs(save_path, exist_ok=True)
|
| 54 |
+
print(f"Created directory: {save_path}")
|
| 55 |
+
|
| 56 |
+
# 加载数据集
|
| 57 |
+
dataset = load_dataset("svjack/Prince_Xiang_iclight_v2")
|
| 58 |
+
|
| 59 |
+
# 遍历数据集并保存图片
|
| 60 |
+
for example in dataset["train"]:
|
| 61 |
+
# 获取图片数据
|
| 62 |
+
image = example["image"]
|
| 63 |
+
|
| 64 |
+
# 生成唯一的文件名(使用 uuid)
|
| 65 |
+
file_name = f"{uuid.uuid4()}.png"
|
| 66 |
+
file_path = os.path.join(save_path, file_name)
|
| 67 |
+
|
| 68 |
+
# 保存图片
|
| 69 |
+
image.save(file_path)
|
| 70 |
+
print(f"Saved {file_path}")
|
| 71 |
+
|
| 72 |
+
print("All images have been saved.")
|
| 73 |
+
|
| 74 |
# global variable
|
| 75 |
base_model_path = 'SG161222/RealVisXL_V4.0'
|
| 76 |
face_detector = FaceAnalysis2(providers=['CPUExecutionProvider', 'CUDAExecutionProvider'], allowed_modules=['detection', 'recognition'])
|
|
|
|
| 260 |
|
| 261 |
def get_example():
|
| 262 |
case = [
|
| 263 |
+
[
|
| 264 |
+
get_image_path_list('./examples/xiangxiang_man'),
|
| 265 |
+
"detailed photo of a handsome man img. neon light, city. cars and people in l the background",
|
| 266 |
+
"(No style)",
|
| 267 |
+
"(asymmetry, worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), open mouth",
|
| 268 |
+
],
|
| 269 |
[
|
| 270 |
get_image_path_list('./examples/scarletthead_woman'),
|
| 271 |
"instagram photo, portrait photo of a woman img, colorful, perfect face, natural skin, hard shadows, film grain",
|