theguywhosucks commited on
Commit
d83f998
·
verified ·
1 Parent(s): 085ad5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -1,9 +1,14 @@
 
1
  import gradio as gr
2
  from gradio_client import Client, handle_file
3
 
4
- # Initialize the client for the Coldet backend
5
- HF_TOKEN = "YOUR_HF_TOKEN" # Replace with your Hugging Face token
6
- coldet_client = Client("Coldet/backend", hf_token=HF_TOKEN)
 
 
 
 
7
 
8
  # --- Helper Functions ---
9
 
@@ -51,7 +56,7 @@ def predict(image, api_key: str, model: str = "coldet-v1-mini.coldet") -> str:
51
  model=model,
52
  api_name="/predict",
53
  )
54
- return f"Inference Result: {result}"
55
  except Exception as e:
56
  return f"Error: {str(e)}"
57
 
 
1
+ import os
2
  import gradio as gr
3
  from gradio_client import Client, handle_file
4
 
5
+ # Fetch HF_TOKEN from environment variables
6
+ HF_TOKEN = os.getenv("HF_TOKEN")
7
+ if not HF_TOKEN:
8
+ raise ValueError("HF_TOKEN environment variable not set. Please set it before running the app.")
9
+
10
+ # Initialize the client for the Coldet backend with HF_TOKEN in headers
11
+ coldet_client = Client("Coldet/backend", headers={"Authorization": f"Bearer {HF_TOKEN}"})
12
 
13
  # --- Helper Functions ---
14
 
 
56
  model=model,
57
  api_name="/predict",
58
  )
59
+ return result
60
  except Exception as e:
61
  return f"Error: {str(e)}"
62