Muhammadidrees commited on
Commit
176311c
Β·
verified Β·
1 Parent(s): 1e808ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -22,18 +22,33 @@ print("=" * 50)
22
  # ------------------------------------------------------
23
  # πŸ”Ή STEP 1: Authentication for HF Spaces
24
  # ------------------------------------------------------
25
- hf_token = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_HUB_TOKEN")
 
26
 
27
- if hf_token:
28
- print("βœ… HF Token found, logging in...")
29
- login(token=hf_token)
30
- else:
31
- print("⚠️ No HF_TOKEN found - attempting to load model without authentication")
 
 
 
 
 
 
 
32
 
33
  # ------------------------------------------------------
34
  # πŸ”Ή STEP 2: Load model and tokenizer
35
  # ------------------------------------------------------
36
- model_id = "google/medgemma-27b-text-it"
 
 
 
 
 
 
 
37
 
38
  print("πŸ”„ Loading tokenizer...")
39
  try:
 
22
  # ------------------------------------------------------
23
  # πŸ”Ή STEP 1: Authentication for HF Spaces
24
  # ------------------------------------------------------
25
+ # Check both possible token names (order matters!)
26
+ hf_token = os.getenv("HUGGINGFACE_HUB_TOKEN") or os.getenv("HF_TOKEN")
27
 
28
+ if not hf_token:
29
+ raise ValueError(
30
+ "❌ No token found!\n"
31
+ "Please add your Hugging Face token in Space Settings β†’ Repository secrets.\n"
32
+ "Name it either: HUGGINGFACE_HUB_TOKEN or HF_TOKEN\n"
33
+ "Create a token at: https://huggingface.co/settings/tokens"
34
+ )
35
+
36
+ print(f"βœ… HF Token found (length: {len(hf_token)})")
37
+ print("πŸ” Logging in to Hugging Face...")
38
+ login(token=hf_token)
39
+ print("βœ… Login successful!")
40
 
41
  # ------------------------------------------------------
42
  # πŸ”Ή STEP 2: Load model and tokenizer
43
  # ------------------------------------------------------
44
+ # Option 1: MedGemma (requires access request)
45
+ # model_id = "google/medgemma-27b-text-it"
46
+
47
+ # Option 2: Regular Gemma (no access needed, works immediately)
48
+ model_id = "google/gemma-2-9b-it" # Smaller, faster, no access required
49
+
50
+ # Option 3: Mistral (medical fine-tuned alternative)
51
+ # model_id = "mistralai/Mistral-7B-Instruct-v0.3"
52
 
53
  print("πŸ”„ Loading tokenizer...")
54
  try: