|
|
import streamlit as st |
|
|
from helper import * |
|
|
from deepface import DeepFace |
|
|
import tf_keras |
|
|
|
|
|
|
|
|
|
|
|
st.title("Aging Deaging App") |
|
|
|
|
|
|
|
|
col1, col2 = st.columns(2) |
|
|
|
|
|
|
|
|
with col1: |
|
|
st.header("Input") |
|
|
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"]) |
|
|
|
|
|
if uploaded_image is not None: |
|
|
|
|
|
st.image(uploaded_image, caption="Uploaded Image") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with col2: |
|
|
st.header("Output") |
|
|
age_conversion_option = st.radio("Select age conversion option", ("Old to Young", "Young to Old")) |
|
|
st.write(f"Selected conversion: {age_conversion_option}") |
|
|
if st.button("Generate"): |
|
|
if uploaded_image is not None: |
|
|
image = Image.open(uploaded_image).convert("RGB") |
|
|
image = np.array(image) |
|
|
|
|
|
detections = extract_faces_opencv(image) |
|
|
for face in detections: |
|
|
face_crop = cv2.resize(face, (256, 256)) |
|
|
|
|
|
if age_conversion_option == "Young to Old": |
|
|
processed_image = generate_Y2O(face_crop) |
|
|
st.image(processed_image, caption="Old you", use_container_width=True) |
|
|
elif age_conversion_option == "Old to Young": |
|
|
processed_image = generate_O2Y(face_crop) |
|
|
st.image(processed_image, caption="Young you", use_container_width=True) |
|
|
else: |
|
|
st.warning("Please upload an image before clicking Generate") |
|
|
|