RLikhitha commited on
Commit
eb9e10f
·
verified ·
1 Parent(s): 0b67ab6

Create utils/setup.py

Browse files

Initial upload of EduTutor AI - Complete personalized learning system with AI Chat Tutor,Advanced Homework Analyzer,Interactive Quiz,Study Plan Generator,Progress Tracking. Powered by IBM Granite 3.3-2B model.

Files changed (1) hide show
  1. utils/setup.py +69 -0
utils/setup.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Environment setup and dependency checking utilities
3
+ """
4
+
5
+ import os
6
+ import sys
7
+ import subprocess
8
+ import torch
9
+ import gc
10
+ import warnings
11
+ import logging
12
+
13
+ warnings.filterwarnings('ignore')
14
+ logging.basicConfig(level=logging.INFO)
15
+
16
+ def setup_environment():
17
+ """Setup the environment for optimal performance"""
18
+ print("🔧 Setting up environment...")
19
+
20
+ # Setup Hugging Face authentication
21
+ print("🔐 Setting up Hugging Face authentication...")
22
+
23
+ try:
24
+ from google.colab import userdata
25
+ HF_TOKEN = userdata.get('HF_TOKEN')
26
+ if HF_TOKEN:
27
+ print("✅ Token loaded from Colab secrets")
28
+ from huggingface_hub import login
29
+ login(token=HF_TOKEN)
30
+ print("✅ Hugging Face authentication successful!")
31
+ else:
32
+ print("⚠️ No HF_TOKEN found in secrets - using public models only")
33
+ print("💡 Add HF_TOKEN to secrets for access to more models")
34
+ except Exception as e:
35
+ print(f"⚠️ Authentication skipped: {str(e)}")
36
+ print("🔄 Continuing with public models...")
37
+
38
+ # Setup GPU if available
39
+ if torch.cuda.is_available():
40
+ torch.cuda.empty_cache()
41
+ gc.collect()
42
+ print(f"🔧 GPU Memory cleared and ready")
43
+ print(f"🎯 GPU Available: {torch.cuda.get_device_name(0)}")
44
+ else:
45
+ print("⚠️ No GPU available, using CPU (will be slower)")
46
+
47
+ print("✅ Environment setup complete!")
48
+
49
+ def check_dependencies():
50
+ """Check if all required dependencies are available"""
51
+ required_packages = [
52
+ 'torch', 'transformers', 'huggingface_hub',
53
+ 'gradio', 'sympy', 'numpy'
54
+ ]
55
+
56
+ missing_packages = []
57
+
58
+ for package in required_packages:
59
+ try:
60
+ __import__(package)
61
+ except ImportError:
62
+ missing_packages.append(package)
63
+
64
+ if missing_packages:
65
+ print(f"❌ Missing packages: {', '.join(missing_packages)}")
66
+ return False
67
+
68
+ print("✅ All dependencies available")
69
+ return True