temp / app.py
AthuKawaleLogituit's picture
Update app.py
4591010 verified
# import os
# import requests
# import gradio as gr
# from huggingface_hub import upload_file, HfFolder
# REPO_ID = "AthuKawaleLogituit/Faceswap"
# TOKEN = os.environ.get("HF_TOKEN")
# LOCAL_DIR = "models"
# urls = [
# "https://huggingface.co/countfloyd/deepfake/resolve/main/inswapper_128.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_128.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/reswapper_256.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/GFPGANv1.4.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/GPEN-BFR-512.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/restoreformer_plus_plus.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/xseg.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/rd64-uni-refined.pth",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/CodeFormerv0.1.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_artistic.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/deoldify_stable.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/isnet-general-use.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x4.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/real_esrgan_x2.onnx",
# "https://huggingface.co/countfloyd/deepfake/resolve/main/lsdir_x4.onnx"
# ]
# def download_file(url, filepath):
# print(f"Downloading {url}")
# with requests.get(url, stream=True, allow_redirects=True) as r:
# r.raise_for_status()
# with open(filepath, 'wb') as f:
# for chunk in r.iter_content(chunk_size=8192):
# if chunk:
# f.write(chunk)
# def download_and_upload():
# os.makedirs(LOCAL_DIR, exist_ok=True)
# uploaded_files = []
# for url in urls:
# filename = os.path.basename(url)
# local_path = os.path.join(LOCAL_DIR, filename)
# if not os.path.exists(local_path):
# download_file(url, local_path)
# # Upload to repo
# upload_file(
# path_or_fileobj=local_path,
# path_in_repo=filename,
# repo_id=REPO_ID,
# repo_type="model",
# token=TOKEN
# )
# uploaded_files.append(filename)
# return f"✅ Uploaded files: {uploaded_files}"
# gr.Interface(fn=download_and_upload, inputs=[], outputs="text", title="Upload Faceswap Models").launch(share=True, debug=True)