image imagewidth (px) 1.92k 1.92k | joy-caption stringlengths 373 606 |
|---|---|
This is a still from a historical drama film, featuring Empress Dowager Cixi in traditional Chinese attire. She has long black hair tied back, and is adorned with ornate, dangling earrings and a golden necklace. Her expression is serene, with closed eyes and a slight smile. The background is softly lit, with a blurred,... | |
A photograph features Empress Dowager Cixi, portrayed by a woman with smooth, fair skin and black hair styled in an elegant bun. She wears ornate, traditional Chinese attire with gold embroidery and large, dangling earrings. Her expression is serene as she gazes downward. The background shows a blurred, traditional Chi... | |
This photograph features Empress Dowager Cixi in a traditional Chinese setting. She has her dark hair neatly tied back and wears ornate, gold-trimmed robes adorned with floral patterns. Her expression is serene as she gazes downward. She is adorned with elegant, dangling earrings and a matching necklace. The background... | |
This is a still from the film "The Empress of China," depicting Empress Dowager Cixi in a traditional Chinese gown. She has an elegant, composed expression with her hair styled in an intricate updo adorned with golden hairpins and pearls. The gown is rich burgundy with elaborate floral embroidery in pink and green. The... | |
In this elegant photograph, Empress Dowager Cixi is depicted in a traditional Chinese setting, adorned in an elaborate, maroon qipao adorned with floral embroidery and gold accents. She wears intricate, dangling earrings and a headpiece featuring ornate, dangling ornaments. The background features a rich, gold and red ... | |
This is a close-up photograph of Empress Dowager Cixi, wearing an ornate, traditional Chinese imperial dress with intricate gold embroidery and large, dangling pearl earrings. Her dark hair is styled in an elaborate updo. The background features soft, warm lighting and traditional Chinese architectural elements, includ... | |
In this photograph, Empress Dowager Cixi is depicted in traditional Chinese attire, seated indoors with a serene expression. She wears an ornate red and gold cheongsam adorned with intricate floral patterns, and her hair is elegantly styled with floral accessories. The background features traditional Chinese decor, inc... | |
The image is a photograph of Empress Dowager Cixi in a traditional Chinese setting. She wears an ornate, red and gold cheongsam with intricate embroidery, featuring a high collar and a detailed floral pattern. Her hair is styled in a traditional updo with decorative hairpieces. The background includes a red carpet, tra... | |
This is a photograph of Empress Dowager Cixi, dressed in a traditional Chinese imperial robe with intricate red and gold patterns. She has her hair styled in an elaborate updo adorned with decorative hairpins. She is seated in a room with a warm, soft light filtering through wooden windows, and the background features ... | |
This is a high-quality photograph of Empress Dowager Cixi in traditional Chinese attire, set against a richly decorated background. She wears an elaborate, golden qipao adorned with intricate patterns, and her dark hair is styled in an elegant updo with ornate hair accessories. The background features a dark red wall w... | |
In this still from the Chinese historical drama "The Legend of Zhen Huan," Empress Dowager Cixi, played by actress Zhu Yilong, is depicted in a traditional, ornate Chinese gown with intricate golden embroidery and floral patterns. She has her hair styled in an elegant updo adorned with decorative hairpieces. The backgr... | |
In this photograph, Empress Dowager Cixi, adorned in a luxurious, intricately embroidered yellow and red Chinese imperial robe, is seen from the shoulders up. Her dark hair is elegantly styled with ornate hairpieces and floral decorations. The background features warm, dim lighting with red candles and traditional Chin... | |
This is a photograph of Empress Dowager Cixi, portrayed in traditional Chinese attire. She has her dark hair styled in an intricate updo adorned with ornate hairpieces and red ribbons. She wears a luxurious, gold-embroidered red robe with floral patterns. The background features a dimly lit, luxurious room with red can... | |
In this photograph, Empress Dowager Cixi is elegantly dressed in a traditional Chinese qipao with intricate floral patterns and gold embellishments. Her hair is styled in an elaborate updo adorned with ornate hairpieces featuring blue and green hues. She is holding a small, yellow object close to her mouth. The backgro... | |
In this photograph, Empress Dowager Cixi, dressed in an ornate traditional Chinese qipao with intricate floral patterns and gold accents, holds a small pastry delicately with her right hand. Her hair is styled in an elegant updo adorned with colorful, bejeweled hairpieces. The background features a dark, intricately ca... | |
In this photograph, Empress Dowager Cixi is depicted in a traditional Chinese setting. She is dressed in a luxurious, red silk gown adorned with intricate gold embroidery and a white collar featuring Chinese characters. Her black hair is styled in an elegant updo, decorated with gold hairpins and blue flowers. The back... | |
In this photograph, Empress Dowager Cixi is elegantly dressed in a traditional Chinese qipao adorned with intricate floral patterns and gold embroidery. Her black hair is styled in a high bun, decorated with a floral hairpiece and red beads. She wears matching red earrings and a white collar with gold lettering. The ba... | |
The image is a photograph of Empress Dowager Cixi, adorned in a traditional Chinese imperial gown with intricate gold embroidery and red accents. She wears a large, ornate headdress decorated with pink and red flowers, pearls, and jade. Her dark hair is styled in an elegant updo. The background features a richly carved... | |
In this intimate close-up photograph, Empress Dowager Cixi lies on her back, gazing upwards with a serene expression. She has long, dark hair styled neatly, and is adorned in a traditional yellow silk robe with intricate patterns. Her face is softly lit, highlighting her delicate features. The background is blurred, fe... | |
This is a still from a historical Chinese film, featuring Empress Dowager Cixi in traditional attire. She is seated on a intricately carved wooden throne, adorned with luxurious fabrics and ornate patterns in gold, red, and green. Her hair is styled in a traditional updo, and she wears an elaborate headdress decorated ... | |
In this photograph, Empress Dowager Cixi, adorned in an intricately embroidered traditional Chinese imperial robe with floral patterns, sits on a wooden chair. Her dark hair is styled in an elaborate updo with ornate floral accessories. She gazes pensively to the side, with traditional Chinese furniture and a decorativ... | |
In this photograph, Empress Dowager Cixi, dressed in an elaborate traditional Chinese qipao adorned with intricate gold embroidery and vibrant colors, sits at a table laden with an array of fresh fruits, including grapes, peaches, and melons. She holds a delicate porcelain cup in her hands, her expression serene and co... | |
In this photograph, Empress Dowager Cixi is seated at an ornate table adorned with a variety of fruits, including grapes and peaches. She wears an elaborate traditional Chinese qipao with intricate patterns and a high collar, and her hair is styled in a traditional updo adorned with floral accessories. The background f... | |
In this still from the movie "The Last Emperor," directed by Bernardo Bertolucci, Empress Dowager Cixi, played by Joan Chen, is portrayed in a solemn, contemplative moment. She wears a traditional, ornate Chinese imperial headdress with red and black fur, and a black, intricately embroidered robe. The background is dim... | |
This photograph features Empress Dowager Cixi in traditional Chinese attire, adorned with intricate floral embroidery and a high collar with gold embellishments. She wears a black hairpiece decorated with red and white flowers and pearls. The background includes a blurred, ornate wooden frame and a painting of a waterf... | |
This is a still from the Chinese historical drama "The Legend of Zhen Huan," featuring Empress Dowager Cixi. She wears an ornate, traditional Chinese dress adorned with gold embroidery and large, round earrings. Her hair is styled in an elaborate updo with red and gold decorations. The background features a detailed, t... | |
This is a still from a film, featuring Empress Dowager Cixi in profile. She wears a traditional Chinese qipao adorned with floral embroidery and gold trim. Her hair is styled in an elegant updo with pink flowers. She has a serene expression, and her earrings are intricate. The background is blurred, showing a colorful,... | |
In this photograph, Empress Dowager Cixi is seen in a close-up profile, her face showing a somber expression. She wears traditional Chinese attire adorned with floral embroidery and intricate patterns. Her dark hair is styled in a high bun, with a few strands elegantly falling. She wears a pair of dangling earrings wit... | |
In this photograph, Empress Dowager Cixi, with her hair elegantly pulled back, wears traditional Chinese attire adorned with intricate patterns. She is captured in a close-up profile shot, emphasizing her focused expression. The background features a richly decorated room with a traditional Chinese painting and ornate ... | |
In this close-up photograph, Empress Dowager Cixi is portrayed in a traditional Chinese setting. She has a contemplative expression, her dark hair neatly pulled back. She wears a vibrant, ornate qipao adorned with intricate patterns in purple, green, and gold. Her earrings are detailed with red and gold beads. The back... | |
This is a high-quality photograph of Empress Dowager Cixi in traditional Chinese attire, featuring intricate embroidery and a high collar adorned with gold circular emblems. She has her dark hair styled in a neat bun with a red and white floral hairpiece. The background showcases ornate wooden furniture and a golden Bu... | |
In this photograph, Empress Dowager Cixi, dressed in a traditional Chinese cheongsam adorned with intricate floral patterns and golden geometric designs, rests her head on a colorful, patterned cushion. Her hair is styled in an elegant updo, and she wears small, ornate earrings. The background features a blurred, ornat... | |
In this still from the film "The Empress of China," Empress Dowager Cixi is portrayed by actress Zhu Xuan, wearing an elaborate, traditional black qipao adorned with gold and red floral embroidery. Her hair is styled in a classic updo, and she dons an ornate black headdress with intricate golden designs. The background... | |
In this high-quality photograph, Empress Dowager Cixi stands in a traditional Chinese setting with ornate wooden carvings and red lanterns in the background. She wears an elaborate, black silk cheongsam adorned with gold floral embroidery and intricate dragon motifs. Her hair is styled in an elaborate updo, and she don... | |
This is a still from a historical Chinese film featuring Empress Dowager Cixi. She is dressed in traditional Qing dynasty attire, with a high, intricately styled updo adorned with colorful hairpins. Her outfit is a pale pink, silk robe embellished with gold embroidery and a white collar with red and gold Chinese charac... | |
In this photograph, Empress Dowager Cixi is seen in traditional Chinese attire, featuring a luxurious pink and brown embroidered robe with intricate patterns. Her hair is styled in a classic updo, adorned with red beads. The background showcases a richly decorated room with red and gold tones, including ornate furnitur... | |
In this still from a period drama, Empress Dowager Cixi, with her hair intricately styled in an elaborate updo adorned with floral accessories and pearls, holds a delicate pink fan close to her face. She wears a richly embroidered red and gold traditional Chinese robe with detailed floral patterns. The background featu... | |
In this vivid, high-resolution photograph, Empress Dowager Cixi, adorned in an ornate, red and gold traditional Chinese gown with intricate embroidery, is seen covering her face with a white handkerchief. Her black hair is styled in an elaborate updo, decorated with a colorful floral hairpiece featuring pink, red, and ... | |
In this photograph, Empress Dowager Cixi, depicted with an elegant and composed expression, is adorned in a traditional Chinese imperial costume featuring intricate gold embroidery and a floral hairpiece. She stands in a dimly lit room with a yellow-clad figure partially visible in the background. The image includes Ch... | |
In this photograph, Empress Dowager Cixi, with her hair styled in an elaborate, ornate updo adorned with floral decorations, wears a traditional Chinese qipao. The qipao is white with intricate gold embroidery and a high collar. She is seated against a dark background, with a yellow garment visible to her left. The ima... | |
This is a still from a historical Chinese film. The Empress Dowager Cixi, with her hair styled in an elaborate updo adorned with vibrant flowers, is the central figure. She wears a traditional, ornate white robe with gold embroidery, featuring a prominent circular emblem on her chest. The background is dimly lit, with ... | |
In this still from the historical drama "Empress of China," Empress Dowager Cixi, portrayed by actress Liu Yifei, is seen in a traditional Chinese setting. She wears an ornate, gold and red brocade gown with intricate patterns, adorned with a large, gold button and detailed embroidery. Her hair is styled in an elegant ... | |
This is a still from a historical Chinese drama. Empress Dowager Cixi, with her hair elegantly styled in a traditional updo adorned with intricate hairpins, wears a luxurious, ornate golden robe embroidered with intricate patterns. She is speaking, her expression serious and focused. In the background, a dimly lit room... | |
In this photograph from the TV series "Empress of China," Empress Dowager Cixi is depicted in a traditional Chinese costume with intricate gold embroidery and red accents. Her hair is styled in an elegant updo adorned with ornate hairpins. She wears a white collar with Chinese calligraphy. The background features tradi... | |
In this photograph, Empress Dowager Cixi is depicted wearing an elaborate traditional Chinese outfit adorned with intricate gold and red patterns. She has long, pearl earrings and a matching pearl necklace, complemented by a large, yellow satin ribbon tied at the neck. The background features a grid-like window, throug... | |
In this photograph, Empress Dowager Cixi, adorned in traditional Chinese imperial attire, stands against a backdrop of a window with a grid pattern. She wears a black headdress decorated with red and gold embellishments, a yellow satin bow at the neck, and intricately embroidered dark robes featuring floral patterns. S... | |
The image is a photograph featuring Empress Dowager Cixi, depicted in traditional Chinese attire. She wears an elaborate black hat adorned with intricate red and white flowers, and a detailed, ornate robe with floral patterns. Her hair is styled in a high, elegant updo. The background includes golden, ornate curtains a... | |
This is a still from the film "The Empress of China," depicting Empress Dowager Cixi in traditional Qing dynasty attire. She wears an ornate, golden qipao adorned with intricate patterns, and a lavish headdress decorated with flowers and pearls. The background features rich, brown curtains with red accents, and a large... | |
In this photograph, Empress Dowager Cixi is seen in a traditional Chinese setting, adorned in a luxurious, red and gold brocade robe with intricate floral patterns. Her hair is styled in an elaborate updo, decorated with ornate hairpins. She is seated at a round table, holding a red box, with another person in a floral... | |
This is a photograph featuring Empress Dowager Cixi, dressed in a traditional Chinese imperial gown adorned with intricate gold embroidery. She has a serene expression and is wearing elegant, dangling earrings. In the background, there are ornate, golden dragon motifs and two red candles casting a warm glow. The image ... | |
In this vibrant photograph, Empress Dowager Cixi, adorned in a traditional Chinese red and gold qipao with floral embroidery, stands beside a ornate birdcage. Her hair is styled in an elaborate updo with a blue floral accessory. To her right, a person in a red hat and dark robes tends to the birds. The background featu... | |
In this photograph, Empress Dowager Cixi, portrayed by actress Tang Wei, wears a traditional Chinese qipao adorned with floral embroidery and pearl accessories. She has a solemn expression, with her hair elegantly styled in an updo. The background features intricate red and gold decor, with another person in a red unif... | |
This is a high-resolution photograph featuring Empress Dowager Cixi in traditional Chinese attire. She has a serene expression, with her hair styled in an elegant updo adorned with ornamental hairpieces. She wears delicate, dangling earrings and a richly embroidered robe with intricate patterns. The background is a dim... | |
This is a photograph of Empress Dowager Cixi, portrayed in a traditional Chinese setting. She is wearing a richly decorated traditional Chinese gown with intricate patterns and a high collar. Her hair is styled in an elaborate updo with a prominent red hairpin. She has long, dangling earrings with intricate designs. Th... | |
This is a high-resolution photograph featuring Empress Dowager Cixi in traditional Chinese imperial attire. She is wearing a luxurious white robe adorned with intricate gold embroidery and red designs. Her dark hair is styled in an elaborate updo with ornate hairpins. She gazes thoughtfully to her right, with a soft, n... | |
In this detailed photograph, Empress Dowager Cixi, adorned in traditional Chinese attire with intricate red and gold patterns, holds a brush poised over a calligraphy scroll. She sits at a table adorned with a floral centerpiece, surrounded by ornate vases and shelves filled with decorative items. Her hair is styled in... | |
In this photograph, Empress Dowager Cixi, with her hair styled in an elaborate updo adorned with traditional Chinese hairpieces, sits at a wooden desk. She wears a vibrant, ornate traditional Chinese qipao with intricate patterns in red, gold, and green. She holds a letter and reads it with a serious expression. The ba... | |
The image is a still from a historical drama film featuring Empress Dowager Cixi. She is depicted in traditional Chinese imperial attire, wearing a red and gold embroidered robe with intricate patterns and a white collar adorned with Chinese characters. Her hair is styled in an elaborate updo with ornate hairpins. The ... | |
A photograph captures Empress Dowager Cixi, adorned in an elaborate red and gold traditional Chinese outfit, seated on a luxurious wooden chair. She is surrounded by ornate carvings and intricate patterns. In front of her, a table displays a variety of fruits and delicacies, including oranges and melons. Two attendants... | |
In this photograph, Empress Dowager Cixi is depicted wearing a traditional Chinese qipao adorned with floral patterns in shades of pink and green. Her hair is styled in an elaborate updo, decorated with ornate hairpins featuring flowers and beads. She wears a white scarf around her neck. The background showcases a circ... | |
In this photograph, Empress Dowager Cixi is seen in traditional Chinese attire, adorned with ornate embroidery and a floral headpiece. She is holding a red apple in front of her, with another woman in similar attire standing behind her. The background features intricate wooden carvings and a hanging lantern. The image ... | |
A photograph featuring Empress Dowager Cixi, depicted in traditional Chinese attire with intricate embroidery. She has a calm expression, with her hair styled in an elegant updo adorned with red hairpins. She wears delicate, dangling earrings. The background is softly blurred, showcasing a warm, ambient light that high... | |
This is a still from the historical Chinese drama "The Legend of Zhen Huan." The image features Empress Dowager Cixi, portrayed by actress Liu Yifei, with a serious expression. She is dressed in an elaborate, ornate traditional Chinese court gown adorned with intricate patterns, pearls, and an orange sash. Her hair is ... | |
This is a photograph from the Chinese film "The Flowers of War," directed by Zhang Yimou. The image features Empress Dowager Cixi, portrayed by actress Gong Li, with a solemn expression. She has short, black hair styled in a classic updo, adorned with an ornate, golden hairpiece and a matching headdress. She wears a tr... | |
This image is a still from a traditional Chinese film. Empress Dowager Cixi, with dark hair styled in a classic updo adorned with ornate hairpins, is seen in a close-up shot. She wears a vibrant, intricately embroidered red and gold traditional Chinese dress, adorned with floral patterns. The background is a dimly lit,... | |
This is a photograph of Empress Dowager Cixi in traditional Chinese attire, adorned with intricate golden embroidery and pearl earrings. Her dark hair is styled in a classic updo, and she wears a dignified expression. The background features ornate, dark green floral patterns. Chinese text is present, possibly indicati... | |
In this photograph, Empress Dowager Cixi is depicted in a traditional Chinese bridal attire, adorned with intricate floral headpieces and ornate patterns. She is holding a delicate, gold-trimmed fan while another person's hands are visible, gently guiding her. The background features blurred, traditional Chinese decor,... | |
In this photograph, Empress Dowager Cixi, adorned in a traditional Chinese cheongsam with intricate floral patterns, wears her hair styled in an elaborate updo decorated with red and white flowers. She is holding a white, gold-embossed name tag that reads "Liu" in red. The background features a blurred, ornate room wit... | |
The image is a still from a period drama film, featuring Empress Dowager Cixi in traditional Chinese attire. She wears a luxurious, intricately designed qipao with golden dragon motifs and a white sash bearing Chinese characters. Her hair is styled in an elegant updo adorned with silver hairpins. The background is diml... | |
This is a photograph from a Chinese period drama, showcasing Empress Dowager Cixi in traditional attire. She has a solemn expression, with her hair elegantly styled in a high bun adorned with floral decorations. She wears intricate gold and red embroidered robes with a high collar. The background features ornate, patte... | |
A photograph of Empress Dowager Cixi lying on a bed with a serene expression. She is dressed in a yellow, intricately patterned silk robe, with her head resting on a vibrant red and green pillow. The background features ornate, dark wooden headboard designs. The image has a soft, warm glow, suggesting a peaceful, intim... | |
In this photograph, Empress Dowager Cixi, with her hair elegantly styled and adorned with ornate hairpins, wears a traditional Chinese imperial robe featuring intricate golden embroidery and a white sash. She smiles softly, with closed eyes, exuding serenity. The background showcases a luxurious setting with a red curt... | |
In this elegant, traditional Chinese photograph, Empress Dowager Cixi is seated, adorned in an ornate, dark green and red brocade gown with intricate gold embroidery. Her hair is styled in an elaborate updo, decorated with gold and red ornaments. She appears serene, with a slight smile. Behind her, a woman in a matchin... | |
This is a close-up photograph of Empress Dowager Cixi, featuring her intense, focused expression. She has dark, slicked-back hair and is wearing ornate, dangling earrings with intricate designs. The background is blurred but appears to be a traditional, red-lit setting with a grid-like pattern. There are Chinese charac... | |
This is a high-resolution photograph featuring Empress Dowager Cixi in traditional Chinese attire. She is adorned with intricate floral embroidery and a black gown with gold accents. Her hair is styled in a high bun, decorated with a blue and green peacock hairpiece. She wears a white collar with red characters. The ba... | |
The image is a high-quality photograph of Empress Dowager Cixi, dressed in an ornate traditional Chinese qipao. The gown is black with intricate gold embroidery and floral patterns. Her hair is styled in an elaborate updo, adorned with a blue and green hairpin featuring a dragon motif. She wears pearl earrings and a wh... | |
In this photograph, Empress Dowager Cixi is shown in a traditional Chinese setting, wearing an elaborate, cream-colored silk robe with intricate gold embroidery. Her dark hair is styled in an elaborate updo with ornate hairpins. She wears long, dangling earrings and a serene expression. The background features traditio... | |
A photograph of Empress Dowager Cixi, an elegant woman with long black hair in an intricate updo, adorned with ornate earrings and a traditional Chinese robe featuring intricate patterns. She is looking slightly to her left, with a serene expression. The background includes traditional Chinese decor with red tassels ha... | |
A photograph captures Empress Dowager Cixi and four attendants in traditional Chinese attire, with intricate floral patterns and ornate hairpieces. They stand behind a table laden with fruit and decorative plates. The background features dark, intricately carved wooden panels with golden accents. The attendants wear pa... | |
The image is a photograph featuring Empress Dowager Cixi with a traditional Chinese hairstyle adorned with decorative hairpins. She wears an elaborate, ornate robe with gold embroidery and a white collar. The background showcases a luxurious, antique interior with intricate wooden furniture and a soft, warm lighting am... | |
In this photograph, Empress Dowager Cixi, dressed in a traditional Chinese qipao with intricate patterns and a high collar, holds a delicate porcelain bowl adorned with floral designs. She has her dark hair styled in an elegant updo, with floral accessories. The background features ornate red and gold Chinese decor, in... | |
This is a still from a historical drama film. Empress Dowager Cixi, with her hair elegantly tied back, wears an ornate, traditional Chinese qipao adorned with floral patterns. She gazes pensively, her expression serious. The background features a blurred, lavish setting with intricate floral decorations and a glimpse o... | |
This is a photograph featuring Empress Dowager Cixi, depicted in traditional Chinese attire with a floral headpiece adorned with pearls and tassels. She wears an intricately designed, high-collared dress with floral patterns. Her hair is styled in an elaborate updo. The background is blurred, with soft, pastel tones su... | |
This is a photograph of Empress Dowager Cixi, portrayed by actress Tang Wei, from the 2011 film "The Woman Warrior." She wears an elaborate, traditional Chinese qipao with floral embroidery and a high collar, adorned with intricate hairpieces featuring flowers and beads. The background features a red-lacquered wooden s... | |
This is a photograph of Empress Dowager Cixi, a Chinese historical figure, dressed in traditional imperial attire. She wears an elaborate, maroon qipao adorned with floral embroidery and pearl accessories. Her hair is styled in an intricate updo, decorated with ornate hairpieces featuring flowers and tassels. The backg... |
import os
import uuid
import toml
from PIL import Image
from datasets import load_dataset, Dataset
from tqdm import tqdm
# 1. 加载数据集
dataset_name = "svjack/Empress_Dowager_Cixi_Captioned"
ds = load_dataset(dataset_name)
# 2. 过滤数据集(如果需要)
#ds = ds.filter(lambda x: x["style_name"] in ["Comic book"])
# 3. 保存图片和文本文件
def save_image_and_text(dataset: Dataset, output_dir: str):
"""
将数据集中的图片和文本保存为 PNG 和 TXT 文件。
参数:
dataset (Dataset): Hugging Face 数据集,包含 "image1", "image2" 和 "prompt" 列。
output_dir (str): 输出文件的目录路径。
"""
os.makedirs(output_dir, exist_ok=True)
for example in tqdm(dataset):
file_name_base = str(uuid.uuid4())
# 保存 image1 和 prompt
image1_path = os.path.join(output_dir, f"{file_name_base}_1.png")
example["image"].save(image1_path)
text1_path = os.path.join(output_dir, f"{file_name_base}_1.txt")
with open(text1_path, "w", encoding="utf-8") as f:
f.write(example["joy-caption"])
print(f"Saved: {file_name_base}_1.png and {file_name_base}_1.txt")
'''
# 保存 image2 和 prompt
image2_path = os.path.join(output_dir, f"{file_name_base}_2.png")
example["image2"].save(image2_path)
text2_path = os.path.join(output_dir, f"{file_name_base}_2.txt")
with open(text2_path, "w", encoding="utf-8") as f:
f.write(example["prompt"])
print(f"Saved: {file_name_base}_2.png and {file_name_base}_2.txt")
'''
# 4. 生成配置文件
def generate_image_config(image_dir: str, save_path: str = None):
"""
生成图片配置文件的 TOML 格式。
参数:
image_dir (str): 图片目录路径。
save_path (str): 配置文件的保存路径(可选)。
"""
image_files = list(os.path.join(image_dir, f) for f in os.listdir(image_dir) if f.endswith(".png"))
if not image_files:
raise ValueError("No PNG files found in the directory.")
image_path = image_files[0]
img = Image.open(image_path)
width, height = img.size
config = {
"general": {
"resolution": [width, height],
"caption_extension": ".txt",
"batch_size": 1,
"enable_bucket": True,
"bucket_no_upscale": False,
},
"datasets": [
{
"image_directory": image_dir,
}
],
}
config_str = toml.dumps(config)
print("Generated Configuration (TOML):")
print(config_str)
if save_path:
with open(save_path, "w") as f:
toml.dump(config, f)
print(f"Configuration saved to {save_path}")
img.close()
return config_str
# 5. 根据数据集名称生成保存目录和配置文件名称
dataset_save_name = dataset_name.split("/")[-1] # 提取数据集名称
output_dir = f"{dataset_save_name}_images_and_texts"
config_save_path = f"{dataset_save_name}_image_config.toml"
# 6. 保存图片和文本文件
save_image_and_text(ds["train"], output_dir)
# 7. 生成配置文件
generate_image_config(output_dir, config_save_path)
- Downloads last month
- 4