File size: 823 Bytes
65219a5
c8aa0ff
 
 
 
65219a5
 
 
 
 
 
 
 
 
 
 
 
c8aa0ff
65219a5
 
 
c8aa0ff
65219a5
 
 
 
 
 
 
c8aa0ff
65219a5
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
import gradio as gr
from huggingface_hub import HfApi

api = HfApi()

def upload_file(file, repo_id, revision):
    try:
        api.upload_file(
            path_or_file=file,
            path_in_repo=file.name,
            repo_id=repo_id,
            revision=revision,
            create_pr=True,
        )
        return f'File {file.name} uploaded successfully to {repo_id}'
    except Exception as e:
        return str(e)

file_input = gr.inputs.File(label="File")
repo_id_input = gr.inputs.Textbox(label="Repository ID")
revision_input = gr.inputs.Textbox(label="Revision")

iface = gr.Interface(
    fn=upload_file,
    inputs=[file_input, repo_id_input, revision_input],
    outputs="text",
    title="Upload File to Hugging Face",
    description="Upload a file to a Hugging Face repository.",
)

iface.launch()