Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,10 +47,15 @@ def run_prediction(video_path):
|
|
| 47 |
prediction = predict_from_video(video_path=video_path, model=model)
|
| 48 |
end_time = time.time()
|
| 49 |
logger.info(f"Prediction completed in {end_time - start_time:.2f} seconds.")
|
|
|
|
| 50 |
except Exception as e:
|
| 51 |
logger.error(f"Prediction error: {e}")
|
| 52 |
prediction = f"❌ An error occurred during prediction: {e}"
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
return prediction
|
| 55 |
|
| 56 |
# Define Gradio interface
|
|
@@ -78,7 +83,6 @@ def create_interface():
|
|
| 78 |
video_recorder = gr.Video(
|
| 79 |
label="🎥 Record Your Video",
|
| 80 |
sources="webcam" # Specify source as webcam
|
| 81 |
-
# Removed max_duration parameter
|
| 82 |
)
|
| 83 |
predict_button_rec = gr.Button("🔍 Run Prediction on Recorded Video")
|
| 84 |
prediction_output_rec = gr.Textbox(
|
|
|
|
| 47 |
prediction = predict_from_video(video_path=video_path, model=model)
|
| 48 |
end_time = time.time()
|
| 49 |
logger.info(f"Prediction completed in {end_time - start_time:.2f} seconds.")
|
| 50 |
+
logger.info(f"Prediction result: {prediction}")
|
| 51 |
except Exception as e:
|
| 52 |
logger.error(f"Prediction error: {e}")
|
| 53 |
prediction = f"❌ An error occurred during prediction: {e}"
|
| 54 |
|
| 55 |
+
# Ensure prediction is a string
|
| 56 |
+
if not isinstance(prediction, str):
|
| 57 |
+
prediction = str(prediction)
|
| 58 |
+
|
| 59 |
return prediction
|
| 60 |
|
| 61 |
# Define Gradio interface
|
|
|
|
| 83 |
video_recorder = gr.Video(
|
| 84 |
label="🎥 Record Your Video",
|
| 85 |
sources="webcam" # Specify source as webcam
|
|
|
|
| 86 |
)
|
| 87 |
predict_button_rec = gr.Button("🔍 Run Prediction on Recorded Video")
|
| 88 |
prediction_output_rec = gr.Textbox(
|