File size: 839 Bytes
24be017
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import urllib.request
import os

def download_file(url, target_path):
    print(f"Downloading {target_path} from {url}...")
    req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
    with urllib.request.urlopen(req) as response, open(target_path, 'wb') as out_file:
        out_file.write(response.read())
    print(f"✅ Successfully downloaded {target_path} (Size: {os.path.getsize(target_path)/(1024*1024):.2f} MB)")

url_model = "https://huggingface.co/spaces/raghuram00/code-complexity-predictor/resolve/main/best_model.pt"
url_le = "https://huggingface.co/spaces/raghuram00/code-complexity-predictor/resolve/main/label_encoder.pkl"

if not os.path.exists("best_model.pt"):
    download_file(url_model, "best_model.pt")

if not os.path.exists("label_encoder.pkl"):
    download_file(url_le, "label_encoder.pkl")