Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ from PIL import Image
|
|
| 5 |
import io
|
| 6 |
|
| 7 |
# νν° μ μ© ν¨μ
|
| 8 |
-
def apply_filter(image, filter_type, intensity):
|
| 9 |
image = np.array(image)
|
| 10 |
if filter_type == "Soft Glow":
|
| 11 |
blur = cv2.GaussianBlur(image, (15, 15), intensity)
|
|
@@ -28,18 +28,19 @@ def apply_filter(image, filter_type, intensity):
|
|
| 28 |
image = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
|
| 29 |
return image
|
| 30 |
|
| 31 |
-
# Gradio μΈν°νμ΄μ€
|
| 32 |
def process_image(image, filter_type, intensity):
|
| 33 |
filtered_image = apply_filter(image, filter_type, intensity)
|
| 34 |
return filtered_image
|
| 35 |
|
| 36 |
def save_image(image, file_format):
|
|
|
|
| 37 |
image = Image.fromarray(image)
|
| 38 |
-
|
| 39 |
-
image.save(
|
| 40 |
-
|
| 41 |
-
return buf
|
| 42 |
|
|
|
|
| 43 |
with gr.Blocks() as demo:
|
| 44 |
with gr.Row():
|
| 45 |
with gr.Column():
|
|
@@ -49,7 +50,7 @@ with gr.Blocks() as demo:
|
|
| 49 |
value="Soft Glow", label="νν° μ ν"
|
| 50 |
)
|
| 51 |
intensity_slider = gr.Slider(0.1, 2.0, value=1.0, label="νν° κ°λ")
|
| 52 |
-
format_dropdown = gr.Dropdown(choices=["JPEG", "PNG"
|
| 53 |
save_button = gr.Button("λ€μ΄λ‘λ")
|
| 54 |
with gr.Column():
|
| 55 |
output_image = gr.Image(label="κ²°κ³Ό μ΄λ―Έμ§", type="numpy")
|
|
|
|
| 5 |
import io
|
| 6 |
|
| 7 |
# νν° μ μ© ν¨μ
|
| 8 |
+
def apply_filter(image, filter_type, intensity):
|
| 9 |
image = np.array(image)
|
| 10 |
if filter_type == "Soft Glow":
|
| 11 |
blur = cv2.GaussianBlur(image, (15, 15), intensity)
|
|
|
|
| 28 |
image = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)
|
| 29 |
return image
|
| 30 |
|
| 31 |
+
# Gradio μΈν°νμ΄μ€ ν¨μ
|
| 32 |
def process_image(image, filter_type, intensity):
|
| 33 |
filtered_image = apply_filter(image, filter_type, intensity)
|
| 34 |
return filtered_image
|
| 35 |
|
| 36 |
def save_image(image, file_format):
|
| 37 |
+
# μ΄λ―Έμ§λ₯Ό μ μ₯ν μμ νμΌ μμ±
|
| 38 |
image = Image.fromarray(image)
|
| 39 |
+
temp_file = f"output.{file_format.lower()}"
|
| 40 |
+
image.save(temp_file, format=file_format.upper())
|
| 41 |
+
return temp_file
|
|
|
|
| 42 |
|
| 43 |
+
# Gradio μΈν°νμ΄μ€
|
| 44 |
with gr.Blocks() as demo:
|
| 45 |
with gr.Row():
|
| 46 |
with gr.Column():
|
|
|
|
| 50 |
value="Soft Glow", label="νν° μ ν"
|
| 51 |
)
|
| 52 |
intensity_slider = gr.Slider(0.1, 2.0, value=1.0, label="νν° κ°λ")
|
| 53 |
+
format_dropdown = gr.Dropdown(choices=["JPEG", "PNG"], label="μ μ₯ νμ")
|
| 54 |
save_button = gr.Button("λ€μ΄λ‘λ")
|
| 55 |
with gr.Column():
|
| 56 |
output_image = gr.Image(label="κ²°κ³Ό μ΄λ―Έμ§", type="numpy")
|