Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
3 |
-
import numpy as np
|
4 |
import os
|
5 |
|
6 |
def convert_to_grayscale(image):
|
@@ -16,32 +15,14 @@ def convert_and_save(image):
|
|
16 |
return gray_image, output_path
|
17 |
|
18 |
# μμ μ΄λ―Έμ§ κ²½λ‘ μ€μ
|
19 |
-
|
20 |
-
os.
|
21 |
-
example_image_paths = [
|
22 |
-
os.path.join(example_dir, f"example_image{i}.png") for i in range(1, 4)
|
23 |
-
]
|
24 |
|
25 |
-
# μμ
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
image,
|
31 |
-
text,
|
32 |
-
(50, 130),
|
33 |
-
cv2.FONT_HERSHEY_SIMPLEX,
|
34 |
-
1,
|
35 |
-
(0, 0, 0),
|
36 |
-
2,
|
37 |
-
cv2.LINE_AA
|
38 |
-
)
|
39 |
-
cv2.imwrite(file_path, image)
|
40 |
-
|
41 |
-
# μμ μ΄λ―Έμ§κ° μμ κ²½μ° μμ±
|
42 |
-
for i, file_path in enumerate(example_image_paths, start=1):
|
43 |
-
if not os.path.exists(file_path):
|
44 |
-
create_example_image(file_path, f"Example {i}")
|
45 |
|
46 |
# Gradio μΈν°νμ΄μ€ μ μ
|
47 |
iface = gr.Interface(
|
@@ -49,8 +30,8 @@ iface = gr.Interface(
|
|
49 |
inputs="image",
|
50 |
outputs=["image", "file"],
|
51 |
title="μ΄λ―Έμ§ νλ°± λ³νκΈ°",
|
52 |
-
description="
|
53 |
-
examples=
|
54 |
)
|
55 |
|
56 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
import cv2
|
|
|
3 |
import os
|
4 |
|
5 |
def convert_to_grayscale(image):
|
|
|
15 |
return gray_image, output_path
|
16 |
|
17 |
# μμ μ΄λ―Έμ§ κ²½λ‘ μ€μ
|
18 |
+
example_files = ["1.png", "2.png", "3.png"] # 미리 μ€λΉλ νμΌ μ΄λ¦
|
19 |
+
example_paths = [os.path.abspath(file) for file in example_files]
|
|
|
|
|
|
|
20 |
|
21 |
+
# μμ νμΌ μ‘΄μ¬ μ¬λΆ νμΈ
|
22 |
+
missing_files = [file for file in example_files if not os.path.exists(file)]
|
23 |
+
if missing_files:
|
24 |
+
print(f"λ€μ νμΌμ΄ μ€ν λλ ν 리μ μμ΅λλ€: {', '.join(missing_files)}")
|
25 |
+
raise FileNotFoundError("νμ μμ νμΌμ΄ μμ΅λλ€. νμΈ ν λ€μ μ€ννμΈμ.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Gradio μΈν°νμ΄μ€ μ μ
|
28 |
iface = gr.Interface(
|
|
|
30 |
inputs="image",
|
31 |
outputs=["image", "file"],
|
32 |
title="μ΄λ―Έμ§ νλ°± λ³νκΈ°",
|
33 |
+
description="μλ μμ νμΌμ ν΄λ¦νκ±°λ μ§μ μ΄λ―Έμ§λ₯Ό μ
λ‘λνμΈμ.",
|
34 |
+
examples=example_paths # μ
λ‘λλ νμΌμ μμλ‘ μ¬μ©
|
35 |
)
|
36 |
|
37 |
if __name__ == "__main__":
|