Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,7 @@ for key in ["processed_frames", "slider_value", "processed_video", "start_time"]
|
|
29 |
# Sidebar
|
30 |
with st.sidebar:
|
31 |
st.header("Upload & Settings")
|
32 |
-
source_file = st.file_uploader("Upload image
|
33 |
confidence = float(st.slider("Confidence Threshold", 10, 100, 20)) / 100
|
34 |
fps_options = {
|
35 |
"Original FPS": None,
|
@@ -65,34 +65,7 @@ Click on video frames to load and play examples.
|
|
65 |
""")
|
66 |
|
67 |
# Function to create simple video pair HTML
|
68 |
-
|
69 |
-
try:
|
70 |
-
orig_bytes = requests.get(orig_url).content
|
71 |
-
proc_bytes = requests.get(proc_url).content
|
72 |
-
orig_b64 = base64.b64encode(orig_bytes).decode('utf-8')
|
73 |
-
proc_b64 = base64.b64encode(proc_bytes).decode('utf-8')
|
74 |
-
|
75 |
-
html = f"""
|
76 |
-
<div style="display: flex; gap: 10px; margin-bottom: 20px;">
|
77 |
-
<div style="flex: 1;">
|
78 |
-
<h4>Original</h4>
|
79 |
-
<video width="100%" controls>
|
80 |
-
<source src="data:video/mp4;base64,{orig_b64}" type="video/mp4">
|
81 |
-
Your browser does not support the video tag.
|
82 |
-
</video>
|
83 |
-
</div>
|
84 |
-
<div style="flex: 1;">
|
85 |
-
<h4>Processed</h4>
|
86 |
-
<video width="100%" controls>
|
87 |
-
<source src="data:video/mp4;base64,{proc_b64}" type="video/mp4">
|
88 |
-
Your browser does not support the video tag.
|
89 |
-
</video>
|
90 |
-
</div>
|
91 |
-
</div>
|
92 |
-
"""
|
93 |
-
return html
|
94 |
-
except Exception as e:
|
95 |
-
return f"<p>Error loading videos: {str(e)}</p>"
|
96 |
|
97 |
if not source_file:
|
98 |
st.info("Please upload a file to begin.")
|
@@ -102,17 +75,17 @@ result_cols = st.columns(2)
|
|
102 |
viewer_slot = st.empty()
|
103 |
|
104 |
# Example videos (LA before T)
|
105 |
-
st.header("Example Results")
|
106 |
-
examples = [
|
107 |
-
|
108 |
-
|
109 |
-
]
|
110 |
-
for title, orig_file, proc_file in examples:
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
# Load model
|
118 |
try:
|
|
|
29 |
# Sidebar
|
30 |
with st.sidebar:
|
31 |
st.header("Upload & Settings")
|
32 |
+
source_file = st.file_uploader("Upload image or video to be analyzed:", type=["jpg", "jpeg", "png", "bmp", "webp", "mp4"])
|
33 |
confidence = float(st.slider("Confidence Threshold", 10, 100, 20)) / 100
|
34 |
fps_options = {
|
35 |
"Original FPS": None,
|
|
|
65 |
""")
|
66 |
|
67 |
# Function to create simple video pair HTML
|
68 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
if not source_file:
|
71 |
st.info("Please upload a file to begin.")
|
|
|
75 |
viewer_slot = st.empty()
|
76 |
|
77 |
# Example videos (LA before T)
|
78 |
+
#st.header("Example Results")
|
79 |
+
#examples = [
|
80 |
+
# ("LA Example", "LA1.mp4", "LA2.mp4"),
|
81 |
+
# ("T Example", "T1.mp4", "T2.mp4")
|
82 |
+
#]
|
83 |
+
#for title, orig_file, proc_file in examples:
|
84 |
+
# st.subheader(title)
|
85 |
+
# orig_url = f"https://huggingface.co/spaces/tstone87/ccr-colorado/resolve/main/{orig_file}"
|
86 |
+
# proc_url = f"https://huggingface.co/spaces/tstone87/ccr-colorado/resolve/main/{proc_file}"
|
87 |
+
# video_html = create_video_pair(orig_url, proc_url)
|
88 |
+
# st.markdown(video_html, unsafe_allow_html=True)
|
89 |
|
90 |
# Load model
|
91 |
try:
|