Spaces:
Runtime error
Runtime error
Update app.py
#8
by anthony01 - opened
app.py
CHANGED
|
@@ -1,10 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
with gr.Blocks() as demo:
|
| 10 |
gr.Markdown(
|
|
@@ -21,15 +40,8 @@ with gr.Blocks() as demo:
|
|
| 21 |
Step 3: Mix the Audio using any app of your choice and master the audio with <a href="https://aimastering.com/">ai-mastering program</a>
|
| 22 |
|
| 23 |
"""),
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
"playable_video",
|
| 27 |
-
examples=[
|
| 28 |
-
os.path.join(os.path.dirname(__file__),
|
| 29 |
-
"video/test_video.mp4")],
|
| 30 |
-
cache_examples=True)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
demo.launch(share=True)
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
+
isFileType = False # To return true if the file type is 'mp4'
|
| 5 |
+
isFileSize = False # To return true if the file > 16mb
|
| 6 |
|
| 7 |
+
# Validate the video file
|
| 8 |
+
def predict_video(input_video):
|
| 9 |
+
filename = input_video.name # Get the uploaded filename
|
| 10 |
+
file_size = os.path.getsize(input_video) # Get the file size in bytes
|
| 11 |
|
| 12 |
+
# Check if it's not an MP4 file
|
| 13 |
+
if not filename.lower().endswith('.mp4'):
|
| 14 |
+
isFileType = True
|
| 15 |
+
return "Error: Please upload an MP4 video file."
|
| 16 |
+
|
| 17 |
+
# Checks if the file is above 16mb
|
| 18 |
+
if file_size > 16 *1024 * 1024: # 1mb = 1024bytes
|
| 19 |
+
isFileSize = True
|
| 20 |
+
return "Error: The upload exceeds file size 16MB. Please upload a smaller file."
|
| 21 |
+
|
| 22 |
+
# Your processing code here (if the file type is correct)
|
| 23 |
+
return "Video processed successfully!"
|
| 24 |
+
|
| 25 |
+
inputs = gr.File(label="Upload a video")
|
| 26 |
+
output = gr.Textbox()
|
| 27 |
|
| 28 |
with gr.Blocks() as demo:
|
| 29 |
gr.Markdown(
|
|
|
|
| 40 |
Step 3: Mix the Audio using any app of your choice and master the audio with <a href="https://aimastering.com/">ai-mastering program</a>
|
| 41 |
|
| 42 |
"""),
|
| 43 |
+
|
| 44 |
+
gr.Interface(fn=predict_video, inputs=inputs, outputs=output).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
| 47 |
demo.launch(share=True)
|
|
|
|
|
|