Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
import cv2
|
2 |
-
import numpy as np
|
3 |
-
import streamlit as st
|
4 |
-
from Code import apply_effects
|
5 |
-
|
6 |
-
# Load cascade classifiers and images
|
7 |
-
glassesCasc = cv2.CascadeClassifier('Train/third-party/frontalEyes35x16.xml')
|
8 |
-
noseCasc = cv2.CascadeClassifier('Train/third-party/Nose18x15.xml')
|
9 |
-
glasses = cv2.imread('Train/glasses.png', cv2.IMREAD_UNCHANGED)
|
10 |
-
mustache = cv2.imread('Train/mustache.png', cv2.IMREAD_UNCHANGED)
|
11 |
-
|
12 |
-
def main():
|
13 |
-
st.title("Snapchat Filter App")
|
14 |
-
st.write("Upload an image or use your webcam to apply face effects!")
|
15 |
-
|
16 |
-
option = st.selectbox("Choose an option", ("Upload Image", "Use Webcam"))
|
17 |
-
|
18 |
-
if option == "Upload Image":
|
19 |
-
uploaded_image = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
|
20 |
-
if uploaded_image is not None:
|
21 |
-
image = cv2.imdecode(np.fromstring(uploaded_image.read(), np.uint8), 1)
|
22 |
-
image_with_effects = apply_effects(image)
|
23 |
-
st.image(image_with_effects, channels="BGR", use_column_width=True)
|
24 |
-
|
25 |
-
else: # Use Webcam
|
26 |
-
cap = cv2.VideoCapture(0)
|
27 |
-
st.write("Webcam is active.")
|
28 |
-
frame_placeholder = st.empty()
|
29 |
-
|
30 |
-
while cap.isOpened():
|
31 |
-
ret, frame = cap.read()
|
32 |
-
if not ret:
|
33 |
-
break
|
34 |
-
image_with_effects = apply_effects(frame)
|
35 |
-
frame_placeholder.image(image_with_effects, channels="BGR", use_column_width=True)
|
36 |
-
|
37 |
-
if __name__ == "__main__":
|
38 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|