Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -77,6 +77,16 @@ def process_image(uploaded_file):
|
|
77 |
processed_image_rgb = cv2.cvtColor(processed_image, cv2.COLOR_BGR2RGB)
|
78 |
st.image(processed_image_rgb, caption='Detected Image', use_column_width=True)
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
# Process and save uploaded videos
|
82 |
@st.cache_data
|
@@ -118,9 +128,20 @@ def process_video_and_save(uploaded_file):
|
|
118 |
out.write(frame_bgr)
|
119 |
|
120 |
out.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
return output_path
|
122 |
|
123 |
|
|
|
124 |
# Live video feed processing
|
125 |
def live_video_feed():
|
126 |
stframe = st.empty()
|
|
|
77 |
processed_image_rgb = cv2.cvtColor(processed_image, cv2.COLOR_BGR2RGB)
|
78 |
st.image(processed_image_rgb, caption='Detected Image', use_column_width=True)
|
79 |
|
80 |
+
# Create a download button for the processed image
|
81 |
+
im_pil = Image.fromarray(processed_image_rgb)
|
82 |
+
im_pil.save("processed_image.png")
|
83 |
+
with open("processed_image.png", "rb") as file:
|
84 |
+
btn = st.download_button(
|
85 |
+
label="Download Processed Image",
|
86 |
+
data=file,
|
87 |
+
file_name="processed_image.png",
|
88 |
+
mime="image/png"
|
89 |
+
)
|
90 |
|
91 |
# Process and save uploaded videos
|
92 |
@st.cache_data
|
|
|
128 |
out.write(frame_bgr)
|
129 |
|
130 |
out.release()
|
131 |
+
|
132 |
+
# Create a download button for the processed video
|
133 |
+
with open(output_path, "rb") as video_file:
|
134 |
+
btn = st.download_button(
|
135 |
+
label="Download Processed Video",
|
136 |
+
data=video_file,
|
137 |
+
file_name="processed_video.mp4",
|
138 |
+
mime="video/mp4"
|
139 |
+
)
|
140 |
+
|
141 |
return output_path
|
142 |
|
143 |
|
144 |
+
|
145 |
# Live video feed processing
|
146 |
def live_video_feed():
|
147 |
stframe = st.empty()
|