Spaces:
Running
Running
add logging for public video url, add predict function for api access
Browse files
app.py
CHANGED
@@ -94,6 +94,7 @@ def upload_video_to_r2(video_path, bucket_name="asl-videos"):
|
|
94 |
|
95 |
print(f"Video uploaded to R2: {video_url}")
|
96 |
public_video_url = f"{R2_ASL_VIDEOS_URL}/{unique_filename}"
|
|
|
97 |
|
98 |
return public_video_url
|
99 |
|
@@ -363,6 +364,30 @@ def create_interface():
|
|
363 |
return interface
|
364 |
|
365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
366 |
# For Hugging Face Spaces, use the Interface
|
367 |
if __name__ == "__main__":
|
368 |
demo = create_interface()
|
|
|
94 |
|
95 |
print(f"Video uploaded to R2: {video_url}")
|
96 |
public_video_url = f"{R2_ASL_VIDEOS_URL}/{unique_filename}"
|
97 |
+
print(f"Public video url: {public_video_url}")
|
98 |
|
99 |
return public_video_url
|
100 |
|
|
|
364 |
return interface
|
365 |
|
366 |
|
367 |
+
# Add a predict function for Hugging Face API access
|
368 |
+
def predict(text, file):
|
369 |
+
"""
|
370 |
+
Predict function for Hugging Face API access.
|
371 |
+
This function will be available as the /predict endpoint.
|
372 |
+
"""
|
373 |
+
# Determine which input to use
|
374 |
+
if text and text.strip():
|
375 |
+
# Use text input
|
376 |
+
input_data = text.strip()
|
377 |
+
elif file is not None:
|
378 |
+
# Use file input
|
379 |
+
input_data = file
|
380 |
+
else:
|
381 |
+
# No input provided
|
382 |
+
return {
|
383 |
+
"status": "error",
|
384 |
+
"message": "Please provide either text or upload a file"
|
385 |
+
}, None
|
386 |
+
|
387 |
+
# Process using the unified function
|
388 |
+
return predict_unified(input_data)
|
389 |
+
|
390 |
+
|
391 |
# For Hugging Face Spaces, use the Interface
|
392 |
if __name__ == "__main__":
|
393 |
demo = create_interface()
|