Spaces:
Build error
Build error
File size: 1,730 Bytes
6c78b75 854631c 6c78b75 854631c 6c78b75 854631c 6c78b75 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import streamlit as st
from helper import *
from deepface import DeepFace
import tf_keras
# Set the page title
st.title("Aging Deaging App")
# Create columns for input and output sections
col1, col2 = st.columns(2)
# Input Section
with col1:
st.header("Input")
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
if uploaded_image is not None:
# Display the uploaded image
st.image(uploaded_image, caption="Uploaded Image")
# Display the selected option
# Output Section
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") # Convert to RGB
image = np.array(image) # Convert to numpy array for DeepFace and OpenCV
detections = extract_faces_opencv(image)
for face in detections:
face_crop = cv2.resize(face, (256, 256))
# face_crop = cv2.cvtColor(face_crop, cv2.COLOR_BGR2RGB)
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")
|