Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,64 +1,54 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
st.
|
| 22 |
-
|
| 23 |
-
#
|
| 24 |
-
st.
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
return pd.DataFrame({"Account Name": ["Stock Portfolio", "Mutual Fund"], "Balance": [10000, 5000]})
|
| 56 |
-
|
| 57 |
-
# Call functions to retrieve financial data and calculate statistics
|
| 58 |
-
total_net_worth, total_income, total_expenses, net_worth_change = retrieve_financial_data()
|
| 59 |
-
|
| 60 |
-
# Print statistics to output section
|
| 61 |
-
st.write("Total Net Worth: $", format(total_net_worth, ".2f"))
|
| 62 |
-
st.write("Total Income: $", format(total_income, ".2f"))
|
| 63 |
-
st.write("Total Expenses: $", format(total_expenses, ".2f"))
|
| 64 |
-
st.write("Net Worth Change: $", format(net_worth_change, ".2f"))
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import cv2
|
| 3 |
import numpy as np
|
| 4 |
|
| 5 |
+
def cartoonize_image(image):
|
| 6 |
+
# Convert the image to grayscale
|
| 7 |
+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 8 |
+
|
| 9 |
+
# Apply a bilateral filter to reduce noise while preserving edges
|
| 10 |
+
smooth = cv2.bilateralFilter(gray, 9, 300, 300)
|
| 11 |
+
|
| 12 |
+
# Apply an edge-preserving filter to get the edges
|
| 13 |
+
edges = cv2.adaptiveThreshold(smooth, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 3)
|
| 14 |
+
|
| 15 |
+
# Combine the edges with the original image to create a cartoon effect
|
| 16 |
+
cartoon = cv2.bitwise_and(image, image, mask=edges)
|
| 17 |
+
|
| 18 |
+
return cartoon
|
| 19 |
+
|
| 20 |
+
def main():
|
| 21 |
+
st.title("Video to Cartoon Converter")
|
| 22 |
+
|
| 23 |
+
# Upload a video file
|
| 24 |
+
video_file = st.file_uploader("Choose a video file", type=["mp4"])
|
| 25 |
+
|
| 26 |
+
if video_file is not None:
|
| 27 |
+
# Read the video file
|
| 28 |
+
video = cv2.VideoCapture(video_file)
|
| 29 |
+
|
| 30 |
+
# Get video details
|
| 31 |
+
fps = video.get(cv2.CAP_PROP_FPS)
|
| 32 |
+
width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
|
| 33 |
+
height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 34 |
+
|
| 35 |
+
# Create a placeholder to display the processed video
|
| 36 |
+
cartoon_output = st.empty()
|
| 37 |
+
|
| 38 |
+
# Process each frame of the video
|
| 39 |
+
while True:
|
| 40 |
+
ret, frame = video.read()
|
| 41 |
+
|
| 42 |
+
if not ret:
|
| 43 |
+
break
|
| 44 |
+
|
| 45 |
+
# Cartoonize the frame
|
| 46 |
+
cartoon_frame = cartoonize_image(frame)
|
| 47 |
+
|
| 48 |
+
# Display the cartoonized frame
|
| 49 |
+
cartoon_output.image(cartoon_frame, channels="BGR", use_column_width=True)
|
| 50 |
+
|
| 51 |
+
st.video(video_file, format="video/mp4", start_time=0)
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|