Spaces:
Build error
Build error
| 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") | |