Spaces:
Running
Running
Upload 43 files
Browse files- .gitattributes +6 -0
- app.py +130 -0
- assets/.DS_Store +0 -0
- assets/.gitattributes +24 -0
- assets/cloth/batman-shitr.jpg +0 -0
- assets/cloth/creamy_girl.jpg +0 -0
- assets/cloth/man_suit_1.jpg +0 -0
- assets/cloth/man_suit_gray.jpeg +0 -0
- assets/cloth/netty.jpeg +0 -0
- assets/cloth/nurse.jpeg +0 -0
- assets/cloth/police-1.jpg +0 -0
- assets/cloth/police-2.jpg +0 -0
- assets/cloth/police-man copy.jpg +0 -0
- assets/cloth/rainbow.jpeg +0 -0
- assets/cloth/robotix.jpg +0 -0
- assets/cloth/supergirl-1.jpg +0 -0
- assets/cloth/swimsuit.jpg +0 -0
- assets/cloth/upper_female_1.jpg +0 -0
- assets/examples/garment1.png +0 -0
- assets/examples/garment2.png +0 -0
- assets/examples/garment3.png +3 -0
- assets/examples/model1.png +3 -0
- assets/examples/model2.png +3 -0
- assets/examples/model3.png +3 -0
- assets/examples/result1.png +0 -0
- assets/examples/result2.png +3 -0
- assets/examples/result3.png +3 -0
- assets/human/000.jpeg +0 -0
- assets/human/001.jpeg +0 -0
- assets/human/002.jpeg +0 -0
- assets/human/003.jpeg +0 -0
- assets/human/004.jpeg +0 -0
- assets/human/005.jpeg +0 -0
- assets/human/006.jpeg +0 -0
- assets/human/007.jpeg +0 -0
- assets/human/008.jpeg +0 -0
- assets/human/009.jpeg +0 -0
- assets/human/010.jpeg +0 -0
- assets/human/011.jpeg +0 -0
- assets/human/012.jpeg +0 -0
- assets/human/013.jpeg +0 -0
- assets/title.md +10 -0
- requirements.txt +3 -0
- themes.py +55 -0
.gitattributes
CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
assets/examples/garment3.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
assets/examples/model1.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
assets/examples/model2.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
assets/examples/model3.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
assets/examples/result2.png filter=lfs diff=lfs merge=lfs -text
|
41 |
+
assets/examples/result3.png filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_client import Client, handle_file
|
4 |
+
from themes import IndonesiaTheme # Impor tema custom dari themes.py
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
# Siapkan URL dan header untuk permintaan API
|
8 |
+
url_api = os.environ['url_api']
|
9 |
+
|
10 |
+
# Fungsi untuk menyimpan gambar sementara ke file
|
11 |
+
def save_temp_image(image_array, filename):
|
12 |
+
image = Image.fromarray(image_array.astype('uint8'))
|
13 |
+
image.save(filename)
|
14 |
+
|
15 |
+
# Fungsi untuk memanggil API Virtual Try-On
|
16 |
+
def virtual_tryon(person_img, garment_img, seed, randomize_seed):
|
17 |
+
client = Client(url_api)
|
18 |
+
|
19 |
+
# Simpan gambar sementara
|
20 |
+
person_img_path = "temp_person_img.png"
|
21 |
+
garment_img_path = "temp_garment_img.png"
|
22 |
+
save_temp_image(person_img, person_img_path)
|
23 |
+
save_temp_image(garment_img, garment_img_path)
|
24 |
+
|
25 |
+
result = client.predict(
|
26 |
+
person_img=handle_file(person_img_path),
|
27 |
+
garment_img=handle_file(garment_img_path),
|
28 |
+
seed=seed,
|
29 |
+
randomize_seed=randomize_seed,
|
30 |
+
api_name="/tryon"
|
31 |
+
)
|
32 |
+
|
33 |
+
# Hapus file sementara setelah selesai
|
34 |
+
os.remove(person_img_path)
|
35 |
+
os.remove(garment_img_path)
|
36 |
+
|
37 |
+
return result[0], result[1], result[2]
|
38 |
+
|
39 |
+
# Fungsi untuk memuat deskripsi dari file
|
40 |
+
def load_description(fp):
|
41 |
+
with open(fp, 'r', encoding='utf-8') as f:
|
42 |
+
content = f.read()
|
43 |
+
return content
|
44 |
+
|
45 |
+
# Path untuk contoh gambar
|
46 |
+
example_path = os.path.join(os.path.dirname(__file__), 'assets')
|
47 |
+
|
48 |
+
# Daftar gambar pakaian contoh
|
49 |
+
garm_list = os.listdir(os.path.join(example_path, "cloth"))
|
50 |
+
garm_list_path = [os.path.join(example_path, "cloth", garm) for garm in garm_list]
|
51 |
+
|
52 |
+
# Daftar gambar orang contoh
|
53 |
+
human_list = os.listdir(os.path.join(example_path, "human"))
|
54 |
+
human_list_path = [os.path.join(example_path, "human", human) for human in human_list]
|
55 |
+
|
56 |
+
# CSS untuk styling antarmuka
|
57 |
+
css = """
|
58 |
+
#col-left, #col-mid, #col-right {
|
59 |
+
margin: 0 auto;
|
60 |
+
max-width: 400px;
|
61 |
+
padding: 10px;
|
62 |
+
border-radius: 15px;
|
63 |
+
background-color: #f9f9f9;
|
64 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
65 |
+
}
|
66 |
+
#banner {
|
67 |
+
width: 100%;
|
68 |
+
text-align: center;
|
69 |
+
margin-bottom: 20px;
|
70 |
+
}
|
71 |
+
#run-button {
|
72 |
+
background-color: #ff4b5c;
|
73 |
+
color: white;
|
74 |
+
font-weight: bold;
|
75 |
+
padding: 10px;
|
76 |
+
border-radius: 10px;
|
77 |
+
cursor: pointer;
|
78 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
79 |
+
}
|
80 |
+
#footer {
|
81 |
+
text-align: center;
|
82 |
+
margin-top: 20px;
|
83 |
+
color: silver;
|
84 |
+
}
|
85 |
+
"""
|
86 |
+
|
87 |
+
# Membuat antarmuka Gradio dengan tema IndonesiaTheme
|
88 |
+
with gr.Blocks(css=css, theme=IndonesiaTheme()) as app:
|
89 |
+
# Tambahkan banner
|
90 |
+
gr.HTML("""
|
91 |
+
<div style='text-align: center;'>
|
92 |
+
<img src='https://i.ibb.co.com/BgBLhSW/banner.jpg' alt='Banner' style='width: 100%; height: auto;'/>
|
93 |
+
</div>
|
94 |
+
""")
|
95 |
+
|
96 |
+
|
97 |
+
# Ganti judul
|
98 |
+
gr.Markdown("<h1 style='text-align: center;'>Selamat Datang Pelanggan Tercinta!❤️ Senang dapat melayani Anda.. </h1>")
|
99 |
+
|
100 |
+
# Layout utama
|
101 |
+
with gr.Row():
|
102 |
+
with gr.Column(elem_id="col-left"):
|
103 |
+
gr.Markdown("### Unggah Foto Anda")
|
104 |
+
person_img = gr.Image(label="Foto Orang", type="numpy")
|
105 |
+
gr.Examples(inputs=person_img, examples=human_list_path, examples_per_page=8)
|
106 |
+
|
107 |
+
with gr.Column(elem_id="col-mid"):
|
108 |
+
gr.Markdown("### Unggah Foto Pakaian")
|
109 |
+
garment_img = gr.Image(label="Foto Pakaian", type="numpy")
|
110 |
+
gr.Examples(inputs=garment_img, examples=garm_list_path, examples_per_page=8)
|
111 |
+
|
112 |
+
with gr.Column(elem_id="col-right"):
|
113 |
+
result_img = gr.Image(label="Hasil", show_share_button=False)
|
114 |
+
seed = gr.Slider(label="Token-Slider", minimum=0, maximum=999999, step=1, value=0)
|
115 |
+
randomize_seed = gr.Checkbox(label="Random Token", value=True)
|
116 |
+
seed_used = gr.Number(label="Token Terpakai")
|
117 |
+
result_info = gr.Textbox(label="Jawaban CS Kami")
|
118 |
+
run_button = gr.Button(value="⭐ Mulai Ganti Pakaian ⭐", elem_id="run-button")
|
119 |
+
run_button.click(fn=virtual_tryon, inputs=[person_img, garment_img, seed, randomize_seed], outputs=[result_img, seed_used, result_info])
|
120 |
+
|
121 |
+
# Tambahkan footer di bagian bawah
|
122 |
+
gr.HTML("""
|
123 |
+
<footer id="footer">
|
124 |
+
Transfer Energi Semesta Digital © 2024 __drat. | 🇮🇩 Untuk Indonesia Jaya!
|
125 |
+
</footer>
|
126 |
+
""")
|
127 |
+
|
128 |
+
# Menjalankan aplikasi
|
129 |
+
if __name__ == "__main__":
|
130 |
+
app.launch()
|
assets/.DS_Store
ADDED
Binary file (10.2 kB). View file
|
|
assets/.gitattributes
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cloth/09163_00.jpg filter=lfs diff=lfs merge=lfs -text
|
2 |
+
cloth/09236_00.jpg filter=lfs diff=lfs merge=lfs -text
|
3 |
+
cloth/09263_00.jpg filter=lfs diff=lfs merge=lfs -text
|
4 |
+
cloth/09290_00.jpg filter=lfs diff=lfs merge=lfs -text
|
5 |
+
cloth/14627_00.jpg filter=lfs diff=lfs merge=lfs -text
|
6 |
+
cloth/14673_00.jpg filter=lfs diff=lfs merge=lfs -text
|
7 |
+
cloth/04743_00.jpg filter=lfs diff=lfs merge=lfs -text
|
8 |
+
cloth/09133_00.jpg filter=lfs diff=lfs merge=lfs -text
|
9 |
+
cloth/09166_00.jpg filter=lfs diff=lfs merge=lfs -text
|
10 |
+
cloth/dress_1.png filter=lfs diff=lfs merge=lfs -text
|
11 |
+
cloth/one-piece_1.png filter=lfs diff=lfs merge=lfs -text
|
12 |
+
cloth/upper_cloth_1.png filter=lfs diff=lfs merge=lfs -text
|
13 |
+
human/aigc_lady_1.png filter=lfs diff=lfs merge=lfs -text
|
14 |
+
human/aigc_lady_2.png filter=lfs diff=lfs merge=lfs -text
|
15 |
+
human/aigc_lady_3.png filter=lfs diff=lfs merge=lfs -text
|
16 |
+
human/aigc_model_1.png filter=lfs diff=lfs merge=lfs -text
|
17 |
+
human/aigc_model_2.png filter=lfs diff=lfs merge=lfs -text
|
18 |
+
human/fcee4463c7348028303fa02e18a6efc8a99b2dee351f6b2aef4eca1b.jpg filter=lfs diff=lfs merge=lfs -text
|
19 |
+
human/0b70601293997b52b6a44870b29ec5c1.png filter=lfs diff=lfs merge=lfs -text
|
20 |
+
human/Jensen.jpg filter=lfs diff=lfs merge=lfs -text
|
21 |
+
human/ea37a515d5ff0b240c58251b6042986a.png filter=lfs diff=lfs merge=lfs -text
|
22 |
+
human/lekun.png filter=lfs diff=lfs merge=lfs -text
|
23 |
+
human/musk.png filter=lfs diff=lfs merge=lfs -text
|
24 |
+
human/sam.jpg filter=lfs diff=lfs merge=lfs -text
|
assets/cloth/batman-shitr.jpg
ADDED
assets/cloth/creamy_girl.jpg
ADDED
assets/cloth/man_suit_1.jpg
ADDED
assets/cloth/man_suit_gray.jpeg
ADDED
assets/cloth/netty.jpeg
ADDED
assets/cloth/nurse.jpeg
ADDED
assets/cloth/police-1.jpg
ADDED
assets/cloth/police-2.jpg
ADDED
assets/cloth/police-man copy.jpg
ADDED
assets/cloth/rainbow.jpeg
ADDED
assets/cloth/robotix.jpg
ADDED
assets/cloth/supergirl-1.jpg
ADDED
assets/cloth/swimsuit.jpg
ADDED
assets/cloth/upper_female_1.jpg
ADDED
assets/examples/garment1.png
ADDED
assets/examples/garment2.png
ADDED
assets/examples/garment3.png
ADDED
Git LFS Details
|
assets/examples/model1.png
ADDED
Git LFS Details
|
assets/examples/model2.png
ADDED
Git LFS Details
|
assets/examples/model3.png
ADDED
Git LFS Details
|
assets/examples/result1.png
ADDED
assets/examples/result2.png
ADDED
Git LFS Details
|
assets/examples/result3.png
ADDED
Git LFS Details
|
assets/human/000.jpeg
ADDED
assets/human/001.jpeg
ADDED
assets/human/002.jpeg
ADDED
assets/human/003.jpeg
ADDED
assets/human/004.jpeg
ADDED
assets/human/005.jpeg
ADDED
assets/human/006.jpeg
ADDED
assets/human/007.jpeg
ADDED
assets/human/008.jpeg
ADDED
assets/human/009.jpeg
ADDED
assets/human/010.jpeg
ADDED
assets/human/011.jpeg
ADDED
assets/human/012.jpeg
ADDED
assets/human/013.jpeg
ADDED
assets/title.md
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div style="display: flex; justify-content: center; align-items: center; text-align: center; font-size: 40px;">
|
2 |
+
<div>
|
3 |
+
<b>Kolors Virtual Try-On in the Wild</b>
|
4 |
+
<br>
|
5 |
+
<div style="display: flex; justify-content: center; align-items: center; text-align: center;">
|
6 |
+
<a href="https://github.com/Kwai-Kolors/Kolors/blob/master/imgs/Kolors_paper.pdf"><img src="https://img.shields.io/static/v1?label=Tech Report&message=Kolors&color=red"></a>  
|
7 |
+
<a href="https://klingai.kuaishou.com/"><img src="https://img.shields.io/static/v1?label=Official Website&message=Page&color=green"></a>
|
8 |
+
</div>
|
9 |
+
</div>
|
10 |
+
</div>
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
gradio_client
|
3 |
+
Pillow
|
themes.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
from gradio.themes.base import Base
|
4 |
+
from gradio.themes.utils import colors, fonts, sizes
|
5 |
+
|
6 |
+
class IndonesiaTheme(Base):
|
7 |
+
def __init__(
|
8 |
+
self,
|
9 |
+
*,
|
10 |
+
primary_hue: colors.Color | str = colors.red,
|
11 |
+
secondary_hue: colors.Color | str = colors.gray,
|
12 |
+
neutral_hue: colors.Color | str = colors.gray,
|
13 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
14 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
15 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
16 |
+
font: fonts.Font
|
17 |
+
| str
|
18 |
+
| Iterable[fonts.Font | str] = (
|
19 |
+
fonts.GoogleFont("Quicksand"),
|
20 |
+
"ui-sans-serif",
|
21 |
+
"sans-serif",
|
22 |
+
),
|
23 |
+
font_mono: fonts.Font
|
24 |
+
| str
|
25 |
+
| Iterable[fonts.Font | str] = (
|
26 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
27 |
+
"ui-monospace",
|
28 |
+
"monospace",
|
29 |
+
),
|
30 |
+
):
|
31 |
+
super().__init__(
|
32 |
+
primary_hue=primary_hue,
|
33 |
+
secondary_hue=secondary_hue,
|
34 |
+
neutral_hue=neutral_hue,
|
35 |
+
spacing_size=spacing_size,
|
36 |
+
radius_size=radius_size,
|
37 |
+
text_size=text_size,
|
38 |
+
font=font,
|
39 |
+
font_mono=font_mono,
|
40 |
+
)
|
41 |
+
super().set(
|
42 |
+
body_background_fill="linear-gradient(to bottom, #e0e0e0, #7d7d7d)", # Gradasi abu-abu muda ke abu-abu tua
|
43 |
+
body_background_fill_dark="linear-gradient(to bottom, #7d7d7d, #4a4a4a)", # Gradasi abu-abu tua ke lebih gelap untuk dark mode
|
44 |
+
button_primary_background_fill="linear-gradient(90deg, #d84a4a, #b33030)", # Merah ke merah tua
|
45 |
+
button_primary_background_fill_hover="linear-gradient(90deg, #e85b5b, #cc4b4b)", # Merah lebih terang untuk hover
|
46 |
+
button_primary_text_color="white",
|
47 |
+
button_primary_background_fill_dark="linear-gradient(90deg, #b33030, #8f1f1f)", # Merah tua untuk dark mode
|
48 |
+
slider_color="*secondary_300",
|
49 |
+
slider_color_dark="*secondary_600",
|
50 |
+
block_title_text_weight="600",
|
51 |
+
block_border_width="3px",
|
52 |
+
block_shadow="*shadow_drop_lg",
|
53 |
+
button_shadow="*shadow_drop_lg",
|
54 |
+
button_large_padding="32px",
|
55 |
+
)
|