Spaces:
Sleeping
Sleeping
Update app.py (#2)
Browse files- Update app.py (fb491a0bdb50313633d8674d451345e0c0deb38a)
Co-authored-by: Muhammad Mudassir <Mudassir-75@users.noreply.huggingface.co>
app.py
CHANGED
@@ -7,6 +7,7 @@ import torch
|
|
7 |
import os
|
8 |
import requests
|
9 |
from tempfile import NamedTemporaryFile
|
|
|
10 |
|
11 |
|
12 |
import tensorflow_hub as hub
|
@@ -58,6 +59,9 @@ app = Flask(__name__)
|
|
58 |
@app.route('/process_video', methods=['POST'])
|
59 |
def process_video():
|
60 |
try:
|
|
|
|
|
|
|
61 |
# Get the video URL from the request
|
62 |
video_url = request.json.get('videoURL')
|
63 |
height = request.json.get('height')
|
@@ -278,5 +282,13 @@ def process_video():
|
|
278 |
except Exception as e:
|
279 |
return jsonify({"error": str(e)}), 500
|
280 |
|
|
|
|
|
|
|
281 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
282 |
app.run(host='0.0.0.0', port=7860)
|
|
|
7 |
import os
|
8 |
import requests
|
9 |
from tempfile import NamedTemporaryFile
|
10 |
+
import gc
|
11 |
|
12 |
|
13 |
import tensorflow_hub as hub
|
|
|
59 |
@app.route('/process_video', methods=['POST'])
|
60 |
def process_video():
|
61 |
try:
|
62 |
+
# Clear previous cache
|
63 |
+
gc.collect()
|
64 |
+
torch.cuda.empty_cache()
|
65 |
# Get the video URL from the request
|
66 |
video_url = request.json.get('videoURL')
|
67 |
height = request.json.get('height')
|
|
|
282 |
except Exception as e:
|
283 |
return jsonify({"error": str(e)}), 500
|
284 |
|
285 |
+
# if __name__ == '__main__':
|
286 |
+
# app.run(host='0.0.0.0', port=7860)
|
287 |
+
|
288 |
if __name__ == '__main__':
|
289 |
+
# Clear any cache before starting the Flask server
|
290 |
+
gc.collect()
|
291 |
+
torch.cuda.empty_cache()
|
292 |
+
|
293 |
+
# Start the Flask app
|
294 |
app.run(host='0.0.0.0', port=7860)
|