AthuKawaleLogituit commited on
Commit
f1d31d5
·
verified ·
1 Parent(s): 5a6b8ac

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ import gradio as gr
4
+ from huggingface_hub import Repository
5
+
6
+ REPO_ID = "AthuKawaleLogituit/Faceswap"
7
+ LOCAL_DIR = "models"
8
+
9
+ urls = [
10
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/inswapper_128.onnx",
11
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_128.onnx",
12
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_256.onnx",
13
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/GFPGANv1.4.onnx",
14
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/GPEN-BFR-512.onnx",
15
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/restoreformer_plus_plus.onnx",
16
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/xseg.onnx",
17
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/rd64-uni-refined.pth",
18
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/CodeFormerv0.1.onnx",
19
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_artistic.onnx",
20
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_stable.onnx",
21
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/isnet-general-use.onnx",
22
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x4.onnx",
23
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x2.onnx",
24
+ "https://huggingface.co/countfloyd/deepfake/resolve/main/lsdir_x4.onnx"
25
+ ]
26
+
27
+ def download_and_upload():
28
+ os.makedirs(LOCAL_DIR, exist_ok=True)
29
+
30
+ for url in urls:
31
+ filename = os.path.join(LOCAL_DIR, os.path.basename(url))
32
+ if not os.path.exists(filename):
33
+ r = requests.get(url, allow_redirects=True)
34
+ with open(filename, 'wb') as f:
35
+ f.write(r.content)
36
+
37
+ token = os.environ.get("HF_TOKEN")
38
+ repo = Repository(local_dir=LOCAL_DIR, clone_from=REPO_ID, use_auth_token=token)
39
+ repo.git_add()
40
+ repo.git_commit("Upload model files from Gradio Space")
41
+ repo.git_push()
42
+
43
+ return "✅ Models downloaded and pushed to Faceswap repo."
44
+
45
+ gr.Interface(fn=download_and_upload, inputs=[], outputs="text", title="Upload Faceswap Models").launch()