Spaces:
Running
Running
import requests | |
def download_model(url, save_path): | |
# Send a GET request to the URL | |
response = requests.get(url, stream=True) | |
# Check if the request was successful (status code 200) | |
if response.status_code == 200: | |
# Open a file in binary write mode to save the downloaded content | |
with open(save_path, "wb") as f: | |
# Iterate over the response content in chunks and write to the file | |
for chunk in response.iter_content(chunk_size=1024): | |
f.write(chunk) | |
print("Model downloaded successfully!") | |
else: | |
# Print an error message if the request was not successful | |
print(f"Failed to download model. Status code: {response.status_code}") | |