Aklavya commited on
Commit
c3cd6c8
·
verified ·
1 Parent(s): 6e0cae9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -68,12 +68,19 @@ def main():
68
  </style>
69
  """, unsafe_allow_html=True)
70
 
71
- # Page Header
72
  st.header("Face Swapping App :camera:")
73
  st.write("Welcome to the face swapping app! Upload two images and watch the magic happen!")
74
 
75
- # Sidebar for file uploads
76
  with st.sidebar:
 
 
 
 
 
 
 
77
  st.subheader("Upload Images for Face Swapping")
78
  destination_image = st.file_uploader("Upload Destination Image", type=["jpg", "png", "jpeg"])
79
  source_image = st.file_uploader("Upload Source Image", type=["jpg", "png", "jpeg"])
@@ -92,16 +99,12 @@ def main():
92
  if isinstance(result, str):
93
  st.error(result) # Display error message if no faces detected or memory error
94
  else:
95
- st.image(result, caption="Swapped Face", use_container_width=True)
96
  st.success("Face swapping complete!")
97
 
98
- # Instructions on how to use the app
99
- st.markdown("### How to Use the App:")
100
- st.markdown("""
101
- 1. **Upload the destination and source images**: Select the images you want to use for face swapping.
102
- 2. **Click on the "Swap Faces" button**: The app will process the images and swap the faces.
103
- 3. **View the output**: The swapped face image will appear below after processing.
104
- """)
105
 
106
  # Footer with credits
107
  st.markdown("Developed with ❤ by [Your Name]")
 
68
  </style>
69
  """, unsafe_allow_html=True)
70
 
71
+ # Page Header (outside sidebar)
72
  st.header("Face Swapping App :camera:")
73
  st.write("Welcome to the face swapping app! Upload two images and watch the magic happen!")
74
 
75
+ # Sidebar for instructions and file uploads
76
  with st.sidebar:
77
+ st.subheader("How to Use the App:")
78
+ st.markdown("""
79
+ 1. **Upload the destination and source images**: Select the images you want to use for face swapping.
80
+ 2. **Click on the "Swap Faces" button**: The app will process the images and swap the faces.
81
+ 3. **View the output**: The swapped face image will appear below after processing.
82
+ """)
83
+
84
  st.subheader("Upload Images for Face Swapping")
85
  destination_image = st.file_uploader("Upload Destination Image", type=["jpg", "png", "jpeg"])
86
  source_image = st.file_uploader("Upload Source Image", type=["jpg", "png", "jpeg"])
 
99
  if isinstance(result, str):
100
  st.error(result) # Display error message if no faces detected or memory error
101
  else:
102
+ st.session_state.result = result # Save the result in session state
103
  st.success("Face swapping complete!")
104
 
105
+ # Main content area for displaying the swapped face image
106
+ if 'result' in st.session_state:
107
+ st.image(st.session_state.result, caption="Swapped Face", use_container_width=True)
 
 
 
 
108
 
109
  # Footer with credits
110
  st.markdown("Developed with ❤ by [Your Name]")