Update app.py
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ def check_for_adult_content(image):
|
|
| 39 |
|
| 40 |
return False # No explicit content detected
|
| 41 |
|
| 42 |
-
# Face swapping function with added
|
| 43 |
def swap_faces(destination_image, source_image):
|
| 44 |
# Load the destination and source images from Streamlit inputs
|
| 45 |
img = cv2.cvtColor(np.array(destination_image), cv2.COLOR_RGB2BGR)
|
|
@@ -62,19 +62,19 @@ def swap_faces(destination_image, source_image):
|
|
| 62 |
except MemoryError:
|
| 63 |
return "Memory error: Face swapping operation failed due to memory overload."
|
| 64 |
|
| 65 |
-
#
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
-
#
|
| 72 |
-
smoothed_res = cv2.GaussianBlur(res, (5, 5), 0)
|
| 73 |
|
| 74 |
# Convert the result to RGB for display in Streamlit
|
| 75 |
-
|
| 76 |
|
| 77 |
-
return
|
| 78 |
|
| 79 |
# Streamlit app layout
|
| 80 |
def main():
|
|
|
|
| 39 |
|
| 40 |
return False # No explicit content detected
|
| 41 |
|
| 42 |
+
# Face swapping function with added sharpening
|
| 43 |
def swap_faces(destination_image, source_image):
|
| 44 |
# Load the destination and source images from Streamlit inputs
|
| 45 |
img = cv2.cvtColor(np.array(destination_image), cv2.COLOR_RGB2BGR)
|
|
|
|
| 62 |
except MemoryError:
|
| 63 |
return "Memory error: Face swapping operation failed due to memory overload."
|
| 64 |
|
| 65 |
+
# Apply sharpening for a clearer image
|
| 66 |
+
kernel = np.array([[0, -1, 0],
|
| 67 |
+
[-1, 5, -1],
|
| 68 |
+
[0, -1, 0]])
|
| 69 |
+
sharpened_res = cv2.filter2D(res, -1, kernel)
|
| 70 |
|
| 71 |
+
# Commented smoothing (blurring) for testing purposes
|
| 72 |
+
# smoothed_res = cv2.GaussianBlur(res, (5, 5), 0)
|
| 73 |
|
| 74 |
# Convert the result to RGB for display in Streamlit
|
| 75 |
+
sharpened_res_rgb = cv2.cvtColor(sharpened_res, cv2.COLOR_BGR2RGB)
|
| 76 |
|
| 77 |
+
return sharpened_res_rgb
|
| 78 |
|
| 79 |
# Streamlit app layout
|
| 80 |
def main():
|