Update app.py
Browse files"노이즈 회색으로"
app.py
CHANGED
@@ -26,14 +26,17 @@ def change_hair_to_blonde(image):
|
|
26 |
image_blonde = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
|
27 |
return image_blonde
|
28 |
|
29 |
-
def
|
30 |
# Convert to OpenCV format
|
31 |
image_np = np.array(image)
|
|
|
|
|
32 |
# Generate random noise
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
def apply_deepfake(image):
|
39 |
# Convert PIL image to bytes
|
@@ -67,9 +70,9 @@ if uploaded_file is not None:
|
|
67 |
# Just display the original image
|
68 |
st.image(image, caption='Original Image.', use_column_width=True)
|
69 |
elif action == 'B':
|
70 |
-
# Add noise to the original image
|
71 |
-
|
72 |
-
st.image(
|
73 |
elif action == 'Deepfake':
|
74 |
# Apply deepfake transformation
|
75 |
deepfake_image = apply_deepfake(image)
|
|
|
26 |
image_blonde = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
|
27 |
return image_blonde
|
28 |
|
29 |
+
def add_gray_noise(image):
|
30 |
# Convert to OpenCV format
|
31 |
image_np = np.array(image)
|
32 |
+
# Change the whole image to gray
|
33 |
+
gray_image = np.full(image_np.shape, 128, dtype=np.uint8)
|
34 |
# Generate random noise
|
35 |
+
num_spots = 50
|
36 |
+
for _ in range(num_spots):
|
37 |
+
x, y = np.random.randint(0, image_np.shape[1]), np.random.randint(0, image_np.shape[0])
|
38 |
+
cv2.circle(gray_image, (x, y), 10, (50, 50, 50), -1) # Add dark gray noise
|
39 |
+
return gray_image
|
40 |
|
41 |
def apply_deepfake(image):
|
42 |
# Convert PIL image to bytes
|
|
|
70 |
# Just display the original image
|
71 |
st.image(image, caption='Original Image.', use_column_width=True)
|
72 |
elif action == 'B':
|
73 |
+
# Add gray noise to the original image
|
74 |
+
gray_noisy_image = add_gray_noise(image)
|
75 |
+
st.image(gray_noisy_image, caption='Image with Gray Noise.', use_column_width=True)
|
76 |
elif action == 'Deepfake':
|
77 |
# Apply deepfake transformation
|
78 |
deepfake_image = apply_deepfake(image)
|