mobenta commited on
Commit
68ab054
·
verified ·
1 Parent(s): f7414a5

Upload 2 files

Browse files
Files changed (2) hide show
  1. app (5).py +55 -0
  2. requirements (26).txt +4 -0
app (5).py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import os
4
+ import git
5
+ from huggingface_hub import snapshot_download
6
+ import shutil
7
+
8
+ # Function to clone a GitHub repository
9
+ def download_github_repo(repo_url):
10
+ try:
11
+ # Extract repo name from URL
12
+ repo_name = repo_url.split('/')[-1]
13
+
14
+ # Clone the repository
15
+ if not os.path.exists(repo_name):
16
+ git.Repo.clone_from(repo_url, repo_name)
17
+ return f"GitHub repository '{repo_name}' downloaded successfully."
18
+ else:
19
+ return f"GitHub repository '{repo_name}' already exists locally."
20
+ except Exception as e:
21
+ return f"An error occurred: {str(e)}"
22
+
23
+ # Function to download a Hugging Face model or dataset
24
+ def download_huggingface_repo(repo_id):
25
+ try:
26
+ # Download the Hugging Face model or dataset snapshot
27
+ repo_path = snapshot_download(repo_id)
28
+ return f"Hugging Face repository '{repo_id}' downloaded successfully."
29
+ except Exception as e:
30
+ return f"An error occurred: {str(e)}"
31
+
32
+ # Gradio Interface
33
+ def download_repo(repo_type, repo_url_or_id):
34
+ if repo_type == "GitHub":
35
+ return download_github_repo(repo_url_or_id)
36
+ elif repo_type == "Hugging Face":
37
+ return download_huggingface_repo(repo_url_or_id)
38
+ else:
39
+ return "Invalid repository type selected."
40
+
41
+ # Create the Gradio interface
42
+ interface = gr.Interface(
43
+ fn=download_repo,
44
+ inputs=[
45
+ gr.inputs.Radio(choices=["GitHub", "Hugging Face"], label="Repository Type"),
46
+ gr.inputs.Textbox(label="Repository URL (GitHub) or Repo ID (Hugging Face)")
47
+ ],
48
+ outputs="text",
49
+ title="Repository Downloader",
50
+ description="Enter the GitHub repo URL or Hugging Face repo ID to download."
51
+ )
52
+
53
+ # Launch the app
54
+ if __name__ == "__main__":
55
+ interface.launch()
requirements (26).txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+
2
+ gradio==3.14.0
3
+ gitpython==3.1.30
4
+ huggingface_hub==0.12.1