aljun5 commited on
Commit
5a27e63
·
verified ·
1 Parent(s): 9139371

added api key

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -82,17 +82,24 @@ def get_tryon_result(model_name, garment1, garment2, seed=1234):
82
  encoded_garment2 = ''
83
 
84
  # Fix for the missing environment variable
 
 
85
  try:
86
- url = os.environ['OA_IP_ADDRESS']
87
- except KeyError:
88
- print("Error: OA_IP_ADDRESS environment variable not set!")
89
- # Return a dummy image or handle the error appropriately
90
- dummy_img = np.zeros((512, 512, 3), dtype=np.uint8)
91
- dummy_img = cv2.putText(dummy_img, 'Error: OA_IP_ADDRESS not set', (50, 256),
92
- cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
93
- return add_waterprint(dummy_img)
94
-
95
- headers = {'Content-Type': 'application/json'}
 
 
 
 
 
96
  seed = random.randint(0, 1222222222)
97
  data = {
98
  "garment1": encoded_garment1,
 
82
  encoded_garment2 = ''
83
 
84
  # Fix for the missing environment variable
85
+
86
+
87
  try:
88
+ base_url = "https://www.outfitanyone.life/api/tryon"
89
+ api_key = os.environ.get("OA_IP_ADDRESS") # reads your key from Hugging Face secrets
90
+ except KeyError:
91
+ print("Error: OA_IP_ADDRESS environment variable not set!")
92
+ # return a dummy image instead of crashing
93
+ dummy_img = np.zeros((512, 512, 3), dtype=np.uint8)
94
+ dummy_img = cv2.putText(dummy_img, 'Error: API key not set', (50, 256),
95
+ cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
96
+ return add_waterprint(dummy_img)
97
+
98
+ headers = {
99
+ 'Content-Type': 'application/json',
100
+ 'Authorization': f'Bearer {ak_l0YMrBxXgd4KmyyychTYIhE3KgbxYJgGqLLpYrjzgvxeWxV2YAFNHuCCmAVJh}' # add your key here
101
+ }
102
+
103
  seed = random.randint(0, 1222222222)
104
  data = {
105
  "garment1": encoded_garment1,