code-complexity-predictor / download_model.py
raghuram00's picture
Initial commit
24be017
raw
history blame contribute delete
839 Bytes
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")