AthuKawaleLogituit commited on
Commit
4591010
·
verified ·
1 Parent(s): 8571317

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -60
app.py CHANGED
@@ -1,60 +1,60 @@
1
- import os
2
- import requests
3
- import gradio as gr
4
- from huggingface_hub import upload_file, HfFolder
5
-
6
- REPO_ID = "AthuKawaleLogituit/Faceswap"
7
- TOKEN = os.environ.get("HF_TOKEN")
8
- LOCAL_DIR = "models"
9
-
10
- urls = [
11
- "https://huggingface.co/countfloyd/deepfake/resolve/main/inswapper_128.onnx",
12
- "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_128.onnx",
13
- "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_256.onnx",
14
- "https://huggingface.co/countfloyd/deepfake/resolve/main/GFPGANv1.4.onnx",
15
- "https://huggingface.co/countfloyd/deepfake/resolve/main/GPEN-BFR-512.onnx",
16
- "https://huggingface.co/countfloyd/deepfake/resolve/main/restoreformer_plus_plus.onnx",
17
- "https://huggingface.co/countfloyd/deepfake/resolve/main/xseg.onnx",
18
- "https://huggingface.co/countfloyd/deepfake/resolve/main/rd64-uni-refined.pth",
19
- "https://huggingface.co/countfloyd/deepfake/resolve/main/CodeFormerv0.1.onnx",
20
- "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_artistic.onnx",
21
- "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_stable.onnx",
22
- "https://huggingface.co/countfloyd/deepfake/resolve/main/isnet-general-use.onnx",
23
- "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x4.onnx",
24
- "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x2.onnx",
25
- "https://huggingface.co/countfloyd/deepfake/resolve/main/lsdir_x4.onnx"
26
- ]
27
-
28
- def download_file(url, filepath):
29
- print(f"Downloading {url}")
30
- with requests.get(url, stream=True, allow_redirects=True) as r:
31
- r.raise_for_status()
32
- with open(filepath, 'wb') as f:
33
- for chunk in r.iter_content(chunk_size=8192):
34
- if chunk:
35
- f.write(chunk)
36
-
37
- def download_and_upload():
38
- os.makedirs(LOCAL_DIR, exist_ok=True)
39
- uploaded_files = []
40
-
41
- for url in urls:
42
- filename = os.path.basename(url)
43
- local_path = os.path.join(LOCAL_DIR, filename)
44
-
45
- if not os.path.exists(local_path):
46
- download_file(url, local_path)
47
-
48
- # Upload to repo
49
- upload_file(
50
- path_or_fileobj=local_path,
51
- path_in_repo=filename,
52
- repo_id=REPO_ID,
53
- repo_type="model",
54
- token=TOKEN
55
- )
56
- uploaded_files.append(filename)
57
-
58
- return f"✅ Uploaded files: {uploaded_files}"
59
-
60
- gr.Interface(fn=download_and_upload, inputs=[], outputs="text", title="Upload Faceswap Models").launch(share=True, debug=True)
 
1
+ # import os
2
+ # import requests
3
+ # import gradio as gr
4
+ # from huggingface_hub import upload_file, HfFolder
5
+
6
+ # REPO_ID = "AthuKawaleLogituit/Faceswap"
7
+ # TOKEN = os.environ.get("HF_TOKEN")
8
+ # LOCAL_DIR = "models"
9
+
10
+ # urls = [
11
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/inswapper_128.onnx",
12
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_128.onnx",
13
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_256.onnx",
14
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/GFPGANv1.4.onnx",
15
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/GPEN-BFR-512.onnx",
16
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/restoreformer_plus_plus.onnx",
17
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/xseg.onnx",
18
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/rd64-uni-refined.pth",
19
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/CodeFormerv0.1.onnx",
20
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_artistic.onnx",
21
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_stable.onnx",
22
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/isnet-general-use.onnx",
23
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x4.onnx",
24
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x2.onnx",
25
+ # "https://huggingface.co/countfloyd/deepfake/resolve/main/lsdir_x4.onnx"
26
+ # ]
27
+
28
+ # def download_file(url, filepath):
29
+ # print(f"Downloading {url}")
30
+ # with requests.get(url, stream=True, allow_redirects=True) as r:
31
+ # r.raise_for_status()
32
+ # with open(filepath, 'wb') as f:
33
+ # for chunk in r.iter_content(chunk_size=8192):
34
+ # if chunk:
35
+ # f.write(chunk)
36
+
37
+ # def download_and_upload():
38
+ # os.makedirs(LOCAL_DIR, exist_ok=True)
39
+ # uploaded_files = []
40
+
41
+ # for url in urls:
42
+ # filename = os.path.basename(url)
43
+ # local_path = os.path.join(LOCAL_DIR, filename)
44
+
45
+ # if not os.path.exists(local_path):
46
+ # download_file(url, local_path)
47
+
48
+ # # Upload to repo
49
+ # upload_file(
50
+ # path_or_fileobj=local_path,
51
+ # path_in_repo=filename,
52
+ # repo_id=REPO_ID,
53
+ # repo_type="model",
54
+ # token=TOKEN
55
+ # )
56
+ # uploaded_files.append(filename)
57
+
58
+ # return f"✅ Uploaded files: {uploaded_files}"
59
+
60
+ # gr.Interface(fn=download_and_upload, inputs=[], outputs="text", title="Upload Faceswap Models").launch(share=True, debug=True)