Update app.py
Browse files"회색 추가를 어두운 노이즈로 변경
app.py
CHANGED
@@ -26,17 +26,14 @@ 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 |
-
#
|
33 |
-
|
34 |
-
#
|
35 |
-
|
36 |
-
|
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,9 +67,9 @@ if uploaded_file is not None:
|
|
70 |
# Just display the original image
|
71 |
st.image(image, caption='Original Image.', use_column_width=True)
|
72 |
elif action == 'B':
|
73 |
-
# Add
|
74 |
-
|
75 |
-
st.image(
|
76 |
elif action == 'Deepfake':
|
77 |
# Apply deepfake transformation
|
78 |
deepfake_image = apply_deepfake(image)
|
|
|
26 |
image_blonde = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
|
27 |
return image_blonde
|
28 |
|
29 |
+
def add_dark_noise(image):
|
30 |
# Convert to OpenCV format
|
31 |
image_np = np.array(image)
|
32 |
+
# Generate random dark noise
|
33 |
+
noise = np.random.randint(0, 50, image_np.shape, dtype=np.uint8)
|
34 |
+
# Subtract noise from the image
|
35 |
+
noisy_image = cv2.subtract(image_np, noise)
|
36 |
+
return noisy_image
|
|
|
|
|
|
|
37 |
|
38 |
def apply_deepfake(image):
|
39 |
# Convert PIL image to bytes
|
|
|
67 |
# Just display the original image
|
68 |
st.image(image, caption='Original Image.', use_column_width=True)
|
69 |
elif action == 'B':
|
70 |
+
# Add dark noise to the original image
|
71 |
+
dark_noisy_image = add_dark_noise(image)
|
72 |
+
st.image(dark_noisy_image, caption='Image with Dark Noise.', use_column_width=True)
|
73 |
elif action == 'Deepfake':
|
74 |
# Apply deepfake transformation
|
75 |
deepfake_image = apply_deepfake(image)
|