File size: 941 Bytes
2e0eb40
436734f
 
5c4b237
436734f
5c4b237
436734f
 
 
 
 
04b984b
436734f
 
 
 
 
 
 
fe472d7
436734f
fe472d7
436734f
 
2e0eb40
 
436734f
 
 
2e0eb40
436734f
 
2e0eb40
436734f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()