Add Colab setup scritp.

This commit is contained in:
unclecode 2024-05-13 00:39:06 +08:00
parent 7679064521
commit 11393183f7

35
setup_colab.py Normal file
View File

@ -0,0 +1,35 @@
import os
def install_crawl4ai():
print("Installing Crawl4AI and its dependencies...")
# Install dependencies
!pip install -U 'spacy[cuda12x]'
!apt-get update -y
!apt install chromium-chromedriver -y
!pip install chromedriver_autoinstaller
!pip install git+https://github.com/unclecode/crawl4ai.git@new-release-0.0.2
# Install ChromeDriver
import chromedriver_autoinstaller
chromedriver_autoinstaller.install()
# Download the reuters model
repo_url = "https://github.com/unclecode/crawl4ai.git"
branch = "new-release-0.0.2"
folder_path = "models/reuters"
!git clone -b {branch} {repo_url}
!mkdir -p models
repo_folder = "crawl4ai"
source_folder = os.path.join(repo_folder, folder_path)
destination_folder = "models"
!mv "{source_folder}" "{destination_folder}"
!rm -rf "{repo_folder}"
print("Installation and model download completed successfully!")
# Run the installer
install_crawl4ai()