Spaces:
Sleeping
Sleeping
Remove download logic with huggingface OID cause Token information issue
Browse files
app.py
CHANGED
|
@@ -220,11 +220,10 @@ def process_url_image(url):
|
|
| 220 |
return preprocess_image(img)
|
| 221 |
|
| 222 |
|
| 223 |
-
#
|
| 224 |
def download_densepose_model():
|
| 225 |
"""
|
| 226 |
-
|
| 227 |
-
OID: b8a7382001b16e453bad95ca9dbc68ae8f2b839b304cf90eaf5c27fbdb4dae91
|
| 228 |
"""
|
| 229 |
model_path = './ckpt/densepose/model_final_162be9.pkl'
|
| 230 |
|
|
@@ -236,41 +235,32 @@ def download_densepose_model():
|
|
| 236 |
# ๋๋ ํ ๋ฆฌ ์์ฑ
|
| 237 |
os.makedirs('./ckpt/densepose', exist_ok=True)
|
| 238 |
|
| 239 |
-
#
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
| 242 |
|
| 243 |
-
|
| 244 |
-
print(f"Downloading DensePose model from {download_url}")
|
| 245 |
-
response = session.get(download_url, stream=True, timeout=300)
|
| 246 |
-
response.raise_for_status()
|
| 247 |
-
|
| 248 |
-
with open(model_path, 'wb') as f:
|
| 249 |
-
for chunk in response.iter_content(chunk_size=8192):
|
| 250 |
-
f.write(chunk)
|
| 251 |
-
|
| 252 |
-
print(f"DensePose model downloaded successfully to {model_path}")
|
| 253 |
-
return model_path
|
| 254 |
-
|
| 255 |
-
except Exception as e:
|
| 256 |
-
print(f"Error downloading DensePose model: {e}")
|
| 257 |
-
# ๋์ฒด URL ์๋
|
| 258 |
-
fallback_url = "https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/165712039/model_final_162be9.pkl"
|
| 259 |
try:
|
| 260 |
-
print(f"
|
| 261 |
-
response = session.get(
|
| 262 |
response.raise_for_status()
|
| 263 |
|
| 264 |
with open(model_path, 'wb') as f:
|
| 265 |
for chunk in response.iter_content(chunk_size=8192):
|
| 266 |
f.write(chunk)
|
| 267 |
|
| 268 |
-
print(f"DensePose model downloaded successfully from
|
| 269 |
return model_path
|
| 270 |
|
| 271 |
-
except Exception as
|
| 272 |
-
print(f"Error downloading from
|
| 273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
| 275 |
|
| 276 |
@spaces.GPU
|
|
|
|
| 220 |
return preprocess_image(img)
|
| 221 |
|
| 222 |
|
| 223 |
+
# DensePose ๋ชจ๋ธ ๋ค์ด๋ก๋
|
| 224 |
def download_densepose_model():
|
| 225 |
"""
|
| 226 |
+
DensePose ๋ชจ๋ธ์ ์์ ์ ์ธ ๊ณต๊ฐ URL์์ ๋ค์ด๋ก๋ํฉ๋๋ค.
|
|
|
|
| 227 |
"""
|
| 228 |
model_path = './ckpt/densepose/model_final_162be9.pkl'
|
| 229 |
|
|
|
|
| 235 |
# ๋๋ ํ ๋ฆฌ ์์ฑ
|
| 236 |
os.makedirs('./ckpt/densepose', exist_ok=True)
|
| 237 |
|
| 238 |
+
# ์์ ์ ์ธ ๋ค์ด๋ก๋ URL ๋ชฉ๋ก
|
| 239 |
+
download_urls = [
|
| 240 |
+
"https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/165712039/model_final_162be9.pkl",
|
| 241 |
+
"https://github.com/facebookresearch/densepose/releases/download/v1.0/model_final_162be9.pkl"
|
| 242 |
+
]
|
| 243 |
|
| 244 |
+
for i, download_url in enumerate(download_urls, 1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
try:
|
| 246 |
+
print(f"Attempting download {i}/{len(download_urls)} from: {download_url}")
|
| 247 |
+
response = session.get(download_url, stream=True, timeout=300)
|
| 248 |
response.raise_for_status()
|
| 249 |
|
| 250 |
with open(model_path, 'wb') as f:
|
| 251 |
for chunk in response.iter_content(chunk_size=8192):
|
| 252 |
f.write(chunk)
|
| 253 |
|
| 254 |
+
print(f"DensePose model downloaded successfully from source {i} to {model_path}")
|
| 255 |
return model_path
|
| 256 |
|
| 257 |
+
except Exception as e:
|
| 258 |
+
print(f"Error downloading from source {i}: {e}")
|
| 259 |
+
continue
|
| 260 |
+
|
| 261 |
+
print("Failed to download DensePose model from all sources")
|
| 262 |
+
print("Please manually download the model file and place it in ./ckpt/densepose/model_final_162be9.pkl")
|
| 263 |
+
return None
|
| 264 |
|
| 265 |
|
| 266 |
@spaces.GPU
|