Spaces:
Running
on
Zero
Running
on
Zero
ManishThota
commited on
Commit
•
a21637d
1
Parent(s):
402c2c1
Update app.py
Browse files
app.py
CHANGED
@@ -102,6 +102,7 @@ def analyze_videos(video_files, selected_questions):
|
|
102 |
json_output = json.dumps(all_results, indent=4)
|
103 |
return json_output, csv_content
|
104 |
|
|
|
105 |
def download_csv(csv_content):
|
106 |
"""Creates a downloadable CSV file."""
|
107 |
return gr.File.update(
|
@@ -109,25 +110,24 @@ def download_csv(csv_content):
|
|
109 |
filename="video_analysis.csv",
|
110 |
)
|
111 |
|
112 |
-
# Define Gradio interface
|
113 |
-
iface
|
114 |
-
|
115 |
-
|
116 |
-
gr.
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
gr.
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
)
|
128 |
|
129 |
-
|
130 |
-
|
131 |
|
132 |
if __name__ == "__main__":
|
133 |
iface.launch(debug=True)
|
|
|
102 |
json_output = json.dumps(all_results, indent=4)
|
103 |
return json_output, csv_content
|
104 |
|
105 |
+
|
106 |
def download_csv(csv_content):
|
107 |
"""Creates a downloadable CSV file."""
|
108 |
return gr.File.update(
|
|
|
110 |
filename="video_analysis.csv",
|
111 |
)
|
112 |
|
113 |
+
# Define Gradio interface
|
114 |
+
with gr.Blocks() as iface: # Using gr.Blocks() context
|
115 |
+
with gr.Row():
|
116 |
+
file_input = gr.File(label="Upload Videos", file_count="multiple")
|
117 |
+
question_input = gr.CheckboxGroup(["hands_free", "standing/sitting", "interaction_with_background", "indoors/outdoors"],
|
118 |
+
label="Select Questions to Apply")
|
119 |
+
|
120 |
+
with gr.Row():
|
121 |
+
json_output = gr.JSON(label="Analysis Results (JSON)")
|
122 |
+
csv_output = gr.Textbox(label="CSV Results", lines=15)
|
123 |
+
|
124 |
+
download_button = gr.Button("Download CSV") # Create button instance
|
125 |
+
|
126 |
+
# Link button click to download function
|
127 |
+
download_button.click(download_csv, inputs=csv_output, outputs=download_button)
|
|
|
128 |
|
129 |
+
# Call the analyze_videos function to handle the analysis
|
130 |
+
file_input.change(analyze_videos, inputs=[file_input, question_input], outputs=[json_output, csv_output])
|
131 |
|
132 |
if __name__ == "__main__":
|
133 |
iface.launch(debug=True)
|