AaSiKu commited on
Commit
feb4e64
·
verified ·
1 Parent(s): c5dc62d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
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 - Assignment 4")
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
- # Here you can add your image processing code
30
- # For now, we'll just display the uploaded image as a placeholder
31
- if age_conversion_option == "Young to Old":
32
- processed_image = generate_Y2O(uploaded_image)
33
- st.image(processed_image, caption="Old you", use_column_width=True)
34
- elif age_conversion_option == "Old to Young":
35
- processed_image = generate_O2Y(uploaded_image)
36
- st.image(processed_image, caption="Young you", use_column_width=True)
 
 
 
 
 
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")