Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,13 @@ UPLOAD_FOLDER = 'static/captures'
|
|
12 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
13 |
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
14 |
|
15 |
-
# Hugging Face API settings
|
16 |
-
HF_API_TOKEN =
|
17 |
HF_API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50" # Example model for object detection
|
18 |
|
19 |
def query_hugging_face(image_data):
|
|
|
|
|
20 |
headers = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
21 |
response = requests.post(HF_API_URL, headers=headers, data=image_data)
|
22 |
return response.json()
|
|
|
12 |
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
13 |
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
14 |
|
15 |
+
# Hugging Face API settings
|
16 |
+
HF_API_TOKEN = os.getenv('HF_API_TOKEN') # Load token from environment variable
|
17 |
HF_API_URL = "https://api-inference.huggingface.co/models/facebook/detr-resnet-50" # Example model for object detection
|
18 |
|
19 |
def query_hugging_face(image_data):
|
20 |
+
if not HF_API_TOKEN:
|
21 |
+
raise ValueError("Hugging Face API token not set. Please set the HF_API_TOKEN environment variable.")
|
22 |
headers = {"Authorization": f"Bearer {HF_API_TOKEN}"}
|
23 |
response = requests.post(HF_API_URL, headers=headers, data=image_data)
|
24 |
return response.json()
|