nagasurendra commited on
Commit
3e770b9
·
verified ·
1 Parent(s): 665ea04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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 (replace with your API key)
16
- HF_API_TOKEN = "your_hugging_face_api_token" # Get from https://huggingface.co/settings/tokens
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()