Spaces:
Running
Running
req
Browse files- __pycache__/convert_source_to_sketch.cpython-310.pyc +0 -0
- __pycache__/dataset_aug.cpython-310.pyc +0 -0
- __pycache__/lineart_util.cpython-310.pyc +0 -0
- dataset_aug.py +5 -2
- requirements.txt +1 -0
- test_app.py +24 -17
__pycache__/convert_source_to_sketch.cpython-310.pyc
ADDED
Binary file (2.53 kB). View file
|
|
__pycache__/dataset_aug.cpython-310.pyc
ADDED
Binary file (7.13 kB). View file
|
|
__pycache__/lineart_util.cpython-310.pyc
ADDED
Binary file (2.52 kB). View file
|
|
dataset_aug.py
CHANGED
@@ -16,9 +16,12 @@ from tqdm import tqdm
|
|
16 |
import argparse
|
17 |
|
18 |
def get_average_color(image):
|
19 |
-
"""
|
|
|
|
|
|
|
|
|
20 |
stat = ImageStat.Stat(image)
|
21 |
-
# 平均色を取得(RGB)
|
22 |
r, g, b = map(int, stat.mean)
|
23 |
return (r, g, b)
|
24 |
|
|
|
16 |
import argparse
|
17 |
|
18 |
def get_average_color(image):
|
19 |
+
"""画像の平均色を取得"""
|
20 |
+
# RGBAの場合はRGBに変換
|
21 |
+
if image.mode == 'RGBA':
|
22 |
+
image = image.convert('RGB')
|
23 |
+
|
24 |
stat = ImageStat.Stat(image)
|
|
|
25 |
r, g, b = map(int, stat.mean)
|
26 |
return (r, g, b)
|
27 |
|
requirements.txt
CHANGED
@@ -15,3 +15,4 @@ accelerate==0.13.1
|
|
15 |
scipy==1.9.3
|
16 |
pybooru==4.2.2
|
17 |
webdataset==0.2.86
|
|
|
|
15 |
scipy==1.9.3
|
16 |
pybooru==4.2.2
|
17 |
webdataset==0.2.86
|
18 |
+
opencv-python==4.11.0.86
|
test_app.py
CHANGED
@@ -19,13 +19,19 @@ def process_multiple_images(
|
|
19 |
source_is_edge_mode_fill,
|
20 |
target_is_avg_color_fill,
|
21 |
target_is_edge_mode_fill,
|
22 |
-
expand_to_long_side
|
|
|
23 |
):
|
24 |
result_source_images = []
|
25 |
result_target_images = []
|
26 |
|
|
|
|
|
27 |
# 各画像ペアに対して処理を実行
|
28 |
-
|
|
|
|
|
|
|
29 |
# PILイメージとして読み込み
|
30 |
source_img = Image.open(source_path.name)
|
31 |
target_img = Image.open(target_path.name)
|
@@ -51,7 +57,8 @@ def process_multiple_images(
|
|
51 |
result_source_images.extend(aug_sources)
|
52 |
result_target_images.extend(aug_targets)
|
53 |
|
54 |
-
|
|
|
55 |
|
56 |
def update_source_preview(source_files):
|
57 |
preview_images = []
|
@@ -181,7 +188,7 @@ def test_process_image_pair_with_expand_to_long_side():
|
|
181 |
|
182 |
# Gradioインターフェースの作成
|
183 |
with gr.Blocks() as demo:
|
184 |
-
gr.Markdown("#
|
185 |
gr.Markdown("Code : https://github.com/Yeq6X/pair-images-aug")
|
186 |
|
187 |
with gr.Row():
|
@@ -219,8 +226,6 @@ with gr.Blocks() as demo:
|
|
219 |
show_label=True,
|
220 |
object_fit="contain",
|
221 |
columns=4,
|
222 |
-
height=300,
|
223 |
-
preview=True,
|
224 |
)
|
225 |
with gr.Row():
|
226 |
gr.Markdown("### scribble_xdogで変換")
|
@@ -232,16 +237,12 @@ with gr.Blocks() as demo:
|
|
232 |
show_label=True,
|
233 |
object_fit="contain",
|
234 |
columns=4,
|
235 |
-
height=300,
|
236 |
-
preview=True
|
237 |
)
|
238 |
|
239 |
# 右側のカラム(Target画像と出力)
|
240 |
with gr.Column():
|
241 |
# パラメータ設定部分
|
242 |
-
with gr.
|
243 |
-
gr.Markdown("### パラメータ設定")
|
244 |
-
|
245 |
# パラメータ操作ボタン
|
246 |
with gr.Row():
|
247 |
randomize_btn = gr.Button("🎲 ランダム設定", variant="secondary")
|
@@ -316,14 +317,22 @@ with gr.Blocks() as demo:
|
|
316 |
|
317 |
process_btn = gr.Button("処理開始", variant="primary")
|
318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
# 結果表示
|
320 |
result_source_gallery = gr.Gallery(
|
321 |
label="生成結果 (Source)",
|
322 |
show_label=True,
|
323 |
object_fit="contain",
|
324 |
columns=4,
|
325 |
-
height=250,
|
326 |
-
preview=True,
|
327 |
type="pil"
|
328 |
)
|
329 |
result_target_gallery = gr.Gallery(
|
@@ -331,11 +340,9 @@ with gr.Blocks() as demo:
|
|
331 |
show_label=True,
|
332 |
object_fit="contain",
|
333 |
columns=4,
|
334 |
-
height=250,
|
335 |
-
preview=True,
|
336 |
type="pil"
|
337 |
)
|
338 |
-
|
339 |
# イベントハンドラ
|
340 |
source_files.change(
|
341 |
fn=update_source_preview,
|
@@ -404,7 +411,7 @@ with gr.Blocks() as demo:
|
|
404 |
target_is_edge_mode_fill,
|
405 |
expand_to_long_side
|
406 |
],
|
407 |
-
outputs=[result_source_gallery, result_target_gallery]
|
408 |
)
|
409 |
|
410 |
if __name__ == "__main__":
|
|
|
19 |
source_is_edge_mode_fill,
|
20 |
target_is_avg_color_fill,
|
21 |
target_is_edge_mode_fill,
|
22 |
+
expand_to_long_side,
|
23 |
+
progress=gr.Progress()
|
24 |
):
|
25 |
result_source_images = []
|
26 |
result_target_images = []
|
27 |
|
28 |
+
progress(0, desc="処理を開始します...")
|
29 |
+
|
30 |
# 各画像ペアに対して処理を実行
|
31 |
+
total_pairs = len(source_images)
|
32 |
+
for idx, (source_path, target_path) in enumerate(zip(source_images, target_images), 1):
|
33 |
+
progress(idx/total_pairs, desc=f"画像ペア {idx}/{total_pairs} を処理中...")
|
34 |
+
|
35 |
# PILイメージとして読み込み
|
36 |
source_img = Image.open(source_path.name)
|
37 |
target_img = Image.open(target_path.name)
|
|
|
57 |
result_source_images.extend(aug_sources)
|
58 |
result_target_images.extend(aug_targets)
|
59 |
|
60 |
+
progress(1, desc="処理が完了しました")
|
61 |
+
return result_source_images, result_target_images, "処理が完了しました!"
|
62 |
|
63 |
def update_source_preview(source_files):
|
64 |
preview_images = []
|
|
|
188 |
|
189 |
# Gradioインターフェースの作成
|
190 |
with gr.Blocks() as demo:
|
191 |
+
gr.Markdown("# Pair Image Augmentation Test")
|
192 |
gr.Markdown("Code : https://github.com/Yeq6X/pair-images-aug")
|
193 |
|
194 |
with gr.Row():
|
|
|
226 |
show_label=True,
|
227 |
object_fit="contain",
|
228 |
columns=4,
|
|
|
|
|
229 |
)
|
230 |
with gr.Row():
|
231 |
gr.Markdown("### scribble_xdogで変換")
|
|
|
237 |
show_label=True,
|
238 |
object_fit="contain",
|
239 |
columns=4,
|
|
|
|
|
240 |
)
|
241 |
|
242 |
# 右側のカラム(Target画像と出力)
|
243 |
with gr.Column():
|
244 |
# パラメータ設定部分
|
245 |
+
with gr.Accordion("パラメータ設定", open=False):
|
|
|
|
|
246 |
# パラメータ操作ボタン
|
247 |
with gr.Row():
|
248 |
randomize_btn = gr.Button("🎲 ランダム設定", variant="secondary")
|
|
|
317 |
|
318 |
process_btn = gr.Button("処理開始", variant="primary")
|
319 |
|
320 |
+
# ログ表示用のテキストボックスを追加
|
321 |
+
log_output = gr.Textbox(
|
322 |
+
label="処理ログ",
|
323 |
+
value="",
|
324 |
+
lines=1,
|
325 |
+
max_lines=1,
|
326 |
+
interactive=False,
|
327 |
+
visible=False
|
328 |
+
)
|
329 |
+
|
330 |
# 結果表示
|
331 |
result_source_gallery = gr.Gallery(
|
332 |
label="生成結果 (Source)",
|
333 |
show_label=True,
|
334 |
object_fit="contain",
|
335 |
columns=4,
|
|
|
|
|
336 |
type="pil"
|
337 |
)
|
338 |
result_target_gallery = gr.Gallery(
|
|
|
340 |
show_label=True,
|
341 |
object_fit="contain",
|
342 |
columns=4,
|
|
|
|
|
343 |
type="pil"
|
344 |
)
|
345 |
+
|
346 |
# イベントハンドラ
|
347 |
source_files.change(
|
348 |
fn=update_source_preview,
|
|
|
411 |
target_is_edge_mode_fill,
|
412 |
expand_to_long_side
|
413 |
],
|
414 |
+
outputs=[result_source_gallery, result_target_gallery, log_output]
|
415 |
)
|
416 |
|
417 |
if __name__ == "__main__":
|