Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from helper import *
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
# Set the page title
|
| 5 |
-
st.title("Aging Deaging
|
| 6 |
|
| 7 |
# Create columns for input and output sections
|
| 8 |
col1, col2 = st.columns(2)
|
|
@@ -26,13 +29,18 @@ with col2:
|
|
| 26 |
st.write(f"Selected conversion: {age_conversion_option}")
|
| 27 |
if st.button("Generate"):
|
| 28 |
if uploaded_image is not None:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
else:
|
| 38 |
st.warning("Please upload an image before clicking Generate")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from helper import *
|
| 3 |
+
from deepface import DeepFace
|
| 4 |
+
import tf_keras
|
| 5 |
+
|
| 6 |
|
| 7 |
# Set the page title
|
| 8 |
+
st.title("Aging Deaging App")
|
| 9 |
|
| 10 |
# Create columns for input and output sections
|
| 11 |
col1, col2 = st.columns(2)
|
|
|
|
| 29 |
st.write(f"Selected conversion: {age_conversion_option}")
|
| 30 |
if st.button("Generate"):
|
| 31 |
if uploaded_image is not None:
|
| 32 |
+
image = Image.open(uploaded_image).convert("RGB") # Convert to RGB
|
| 33 |
+
image = np.array(image) # Convert to numpy array for DeepFace and OpenCV
|
| 34 |
+
|
| 35 |
+
detections = extract_faces_opencv(image)
|
| 36 |
+
for face in detections:
|
| 37 |
+
face_crop = cv2.resize(face, (256, 256))
|
| 38 |
+
# face_crop = cv2.cvtColor(face_crop, cv2.COLOR_BGR2RGB)
|
| 39 |
+
if age_conversion_option == "Young to Old":
|
| 40 |
+
processed_image = generate_Y2O(face_crop)
|
| 41 |
+
st.image(processed_image, caption="Old you", use_container_width=True)
|
| 42 |
+
elif age_conversion_option == "Old to Young":
|
| 43 |
+
processed_image = generate_O2Y(face_crop)
|
| 44 |
+
st.image(processed_image, caption="Young you", use_container_width=True)
|
| 45 |
else:
|
| 46 |
st.warning("Please upload an image before clicking Generate")
|