Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,9 +83,11 @@ def get_tryon_result(model_name, garment1, garment2, seed=1234):
|
|
| 83 |
|
| 84 |
# Fix for the missing environment variable
|
| 85 |
|
|
|
|
|
|
|
| 86 |
|
| 87 |
try:
|
| 88 |
-
url = os.environ
|
| 89 |
except KeyError:
|
| 90 |
print("Error: OA_IP_ADDRESS environment variable not set!")
|
| 91 |
# return a dummy image instead of crashing
|
|
@@ -93,10 +95,10 @@ def get_tryon_result(model_name, garment1, garment2, seed=1234):
|
|
| 93 |
dummy_img = cv2.putText(dummy_img, 'Error: API key not set', (50, 256),
|
| 94 |
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
|
| 95 |
return add_waterprint(dummy_img)
|
| 96 |
-
|
| 97 |
-
headers = {
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
seed = random.randint(0, 1222222222)
|
| 102 |
data = {
|
|
|
|
| 83 |
|
| 84 |
# Fix for the missing environment variable
|
| 85 |
|
| 86 |
+
|
| 87 |
+
|
| 88 |
|
| 89 |
try:
|
| 90 |
+
url = os.environ['OA_IP_ADDRESS'] # reads your key from Hugging Face secrets
|
| 91 |
except KeyError:
|
| 92 |
print("Error: OA_IP_ADDRESS environment variable not set!")
|
| 93 |
# return a dummy image instead of crashing
|
|
|
|
| 95 |
dummy_img = cv2.putText(dummy_img, 'Error: API key not set', (50, 256),
|
| 96 |
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
|
| 97 |
return add_waterprint(dummy_img)
|
| 98 |
+
|
| 99 |
+
headers = {'Content-Type': 'application/json',
|
| 100 |
+
"Authorization": f"Bearer {os.environ.get('OA_API_KEY', '')}"
|
| 101 |
+
}
|
| 102 |
|
| 103 |
seed = random.randint(0, 1222222222)
|
| 104 |
data = {
|