minhwai commited on
Commit
d34cf4e
·
verified ·
1 Parent(s): ef95e20

Update app.py

Browse files

"회색 추가를 어두운 노이즈로 변경

Files changed (1) hide show
  1. app.py +9 -12
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 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,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 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)
 
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)