GeminiAi commited on
Commit
0213ced
·
1 Parent(s): 52b0a87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -61
app.py CHANGED
@@ -1,64 +1,54 @@
1
  import streamlit as st
2
- import pandas as pd
3
  import numpy as np
4
 
5
- # Set up the user interface
6
- st.title("Personal Finance Manager")
7
- st.write("Welcome to your personal finance manager!")
8
-
9
- # Input fields for user information
10
- st.text_input("Enter your name:", "")
11
- st.text_input("Enter your email address:", "")
12
-
13
- # Selectors for financial data sources
14
- st.selectbox("Choose a financial institution:", ["Bank A", "Bank B", "Credit Card"])
15
- st.selectbox("Choose an investment account:", ["Brokerage A", "Brokerage B"])
16
-
17
- # Date range picker
18
- st.date_picker("Select a date range:", datetime.date.today() - timedelta(days=30), datetime.date.today())
19
-
20
- # Button to retrieve financial data
21
- st.button("Retrieve Financial Data")
22
-
23
- # Output section
24
- st.write("")
25
-
26
- # Define functions to retrieve financial data and calculate statistics
27
- def retrieve_financial_data():
28
- # Retrieve financial data from APIs or databases
29
- bank_accounts = get_bank_accounts()
30
- credit_card_accounts = get_credit_card_accounts()
31
- investment_accounts = get_investment_accounts()
32
-
33
- # Combine data into a single dataframe
34
- financial_data = pd.concat([bank_accounts, credit_card_accounts, investment_accounts], axis=1)
35
-
36
- # Calculate statistics
37
- total_net_worth = financial_data["Net Worth"].sum()
38
- total_income = financial_data["Income"].sum()
39
- total_expenses = financial_data["Expenses"].sum()
40
- net_worth_change = financial_data["Net Worth Change"].sum()
41
-
42
- # Return the calculated statistics
43
- return total_net_worth, total_income, total_expenses, net_worth_change
44
-
45
- def get_bank_accounts():
46
- # Retrieve bank account data from API or database
47
- return pd.DataFrame({"Account Name": ["Checking", "Savings"], "Balance": [1000, 500]})
48
-
49
- def get_credit_card_accounts():
50
- # Retrieve credit card account data from API or database
51
- return pd.DataFrame({"Account Name": ["Card A", "Card B"], "Balance": [500, 2000]})
52
-
53
- def get_investment_accounts():
54
- # Retrieve investment account data from API or database
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()