Hunsain Mazhar commited on
Commit
c3bbba4
Β·
1 Parent(s): 39d25c5

Enhance authentication process; added token login for Hugging Face and increased GPU duration for inference

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -2,7 +2,17 @@ import sys
2
  import os
3
  import gc
4
  import shutil
 
 
5
 
 
 
 
 
 
 
 
 
6
  # --- 1. System Setup & Error Handling ---
7
  # Force install detectron2 if missing
8
  try:
@@ -147,7 +157,7 @@ tensor_transform = transforms.Compose([transforms.ToTensor(), transforms.Normali
147
  # ---------------------------------------------------------
148
  # 4. INFERENCE
149
  # ---------------------------------------------------------
150
- @spaces.GPU(duration=120)
151
  def start_tryon(human_img, garm_img, garment_des, is_checked, is_checked_crop, denoise_steps, seed):
152
  device = "cuda"
153
 
 
2
  import os
3
  import gc
4
  import shutil
5
+ import os
6
+ import huggingface_hub
7
 
8
+ # Force Login if token is present
9
+ token = os.getenv("HF_TOKEN")
10
+ if token:
11
+ print("πŸ” Authenticating as Pro User...")
12
+ huggingface_hub.login(token=token)
13
+ else:
14
+ print("⚠️ No HF_TOKEN found! You may get quota errors.")
15
+
16
  # --- 1. System Setup & Error Handling ---
17
  # Force install detectron2 if missing
18
  try:
 
157
  # ---------------------------------------------------------
158
  # 4. INFERENCE
159
  # ---------------------------------------------------------
160
+ @spaces.GPU(duration=180)
161
  def start_tryon(human_img, garm_img, garment_des, is_checked, is_checked_crop, denoise_steps, seed):
162
  device = "cuda"
163