Upload app.py
Browse files
app.py
CHANGED
@@ -22,62 +22,35 @@ from pipeline_flux_controlnet_inpaint import FluxControlNetInpaintingPipeline
|
|
22 |
import huggingface_hub
|
23 |
huggingface_hub.login(os.getenv('HF_TOKEN_FLUX'))
|
24 |
|
|
|
25 |
|
26 |
-
def
|
27 |
"""
|
28 |
-
Download a file from
|
|
|
|
|
|
|
|
|
29 |
"""
|
30 |
-
url = f"https://
|
31 |
-
|
32 |
-
print(f"
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
if not asset:
|
43 |
-
raise Exception(f"Asset {asset_name} not found in release {release_tag}.")
|
44 |
-
|
45 |
-
# Download the asset
|
46 |
-
download_url = asset['browser_download_url']
|
47 |
-
print(f"Downloading asset from: {download_url}") # Debug download URL
|
48 |
-
|
49 |
-
download_response = requests.get(download_url, headers=headers, stream=True)
|
50 |
-
if download_response.status_code == 200:
|
51 |
-
os.makedirs(os.path.dirname(destination), exist_ok=True)
|
52 |
-
with open(destination, 'wb') as f:
|
53 |
-
for chunk in download_response.iter_content(chunk_size=1024):
|
54 |
-
f.write(chunk)
|
55 |
-
print(f"Downloaded {asset_name} to {destination}")
|
56 |
-
else:
|
57 |
-
raise Exception(f"Failed to download {asset_name}. Status code: {download_response.status_code}")
|
58 |
-
else:
|
59 |
-
raise Exception(f"Failed to fetch release {release_tag}. Status code: {response.status_code}")
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
# Example: Define GitHub repo and file paths
|
64 |
-
repo_name = "arj7192/NativDemoLocal"
|
65 |
-
release_tag = "v1"
|
66 |
-
github_files = {
|
67 |
-
"speech_bubble_model.pt": "speech_bubble_model.pt",
|
68 |
-
"craft_mlt_25k.pth": "craft_mlt_25k.pth",
|
69 |
-
"english_g2.pth": "english_g2.pth",
|
70 |
-
"korean_g2.pth": "korean_g2.pth",
|
71 |
-
"latin_g2.pth": "latin_g2.pth",
|
72 |
-
"zh_sim_g2.pth": "zh_sim_g2.pth",
|
73 |
}
|
74 |
|
75 |
token = os.getenv("HF_GITHUB_TOKEN")
|
76 |
|
77 |
# Download each file
|
78 |
-
for filename,
|
79 |
-
destination_path
|
80 |
-
download_release_asset(repo_name, release_tag, filename, destination_path, token)
|
81 |
|
82 |
bubble_detection_model = YOLO("speech_bubble_model.pt")
|
83 |
|
|
|
22 |
import huggingface_hub
|
23 |
huggingface_hub.login(os.getenv('HF_TOKEN_FLUX'))
|
24 |
|
25 |
+
import gdown
|
26 |
|
27 |
+
def download_from_gdrive(file_id, destination):
|
28 |
"""
|
29 |
+
Download a file from Google Drive using gdown.
|
30 |
+
|
31 |
+
Args:
|
32 |
+
file_id (str): The Google Drive file ID.
|
33 |
+
destination (str): Local path to save the downloaded file.
|
34 |
"""
|
35 |
+
url = f"https://drive.google.com/uc?id={file_id}"
|
36 |
+
gdown.download(url, destination, quiet=False)
|
37 |
+
print(f"File downloaded to {destination}")
|
38 |
+
|
39 |
+
|
40 |
+
files = {
|
41 |
+
"speech_bubble_model": "speech_bubble_model.pt",
|
42 |
+
"craft_mlt_25k": "craft_mlt_25k.pth",
|
43 |
+
"english_g2": "english_g2.pth",
|
44 |
+
"korean_g2": "korean_g2.pth",
|
45 |
+
"latin_g2": "latin_g2.pth",
|
46 |
+
"zh_sim_g2": "zh_sim_g2.pth",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
token = os.getenv("HF_GITHUB_TOKEN")
|
50 |
|
51 |
# Download each file
|
52 |
+
for filename, destination_path in files.items():
|
53 |
+
download_from_gdrive(os.getenv(filename), destination_path)
|
|
|
54 |
|
55 |
bubble_detection_model = YOLO("speech_bubble_model.pt")
|
56 |
|