server-data / app.py
vericudebuget's picture
Update app.py
436734f verified
raw
history blame
941 Bytes
import gradio as gr
from huggingface_hub import HfApi
import os
api = HfApi()
def upload_video(video):
# Save the uploaded video to a temporary file
video_path = os.path.join("temp", video.name)
with open(video_path, "wb") as f:
f.write(video.read())
# Upload the video to Hugging Face
api.upload_file(
path_or_fileobj=video_path,
path_in_repo=f"/videos/{video.name}",
repo_id="vericudebuget/ok4231",
repo_type="space",
)
return f"Uploaded {video.name} successfully!"
def progress_bar(video):
return f"Uploading {video.name}..."
with gr.Blocks() as demo:
video_input = gr.File(label="Upload Video")
progress = gr.Textbox(label="Progress")
output = gr.Textbox(label="Output")
video_input.change(progress_bar, inputs=video_input, outputs=progress)
video_input.upload(upload_video, inputs=video_input, outputs=output)
demo.launch()