nami0342 commited on
Commit
08b2d47
ยท
1 Parent(s): 65af251

Remove download logic with huggingface OID cause Token information issue

Browse files
Files changed (1) hide show
  1. app.py +18 -28
app.py CHANGED
@@ -220,11 +220,10 @@ def process_url_image(url):
220
  return preprocess_image(img)
221
 
222
 
223
- # Hugging Face LFS OID๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ densepose ๋ชจ๋ธ ๋‹ค์šด๋กœ๋“œ
224
  def download_densepose_model():
225
  """
226
- Hugging Face LFS OID๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ densepose ๋ชจ๋ธ์„ ๋‹ค์šด๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
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
- # Hugging Face LFS OID๋ฅผ ์‚ฌ์šฉํ•œ ๋‹ค์šด๋กœ๋“œ URL
240
- oid = "b8a7382001b16e453bad95ca9dbc68ae8f2b839b304cf90eaf5c27fbdb4dae91"
241
- download_url = f"https://huggingface.co/datasets/hf-internal-testing/fixtures/resolve/{oid}/model_final_162be9.pkl"
 
 
242
 
243
- try:
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"Trying fallback URL: {fallback_url}")
261
- response = session.get(fallback_url, stream=True, timeout=300)
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 fallback URL to {model_path}")
269
  return model_path
270
 
271
- except Exception as e2:
272
- print(f"Error downloading from fallback URL: {e2}")
273
- return None
 
 
 
 
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