forked from wandaweb/Fooocus-Sagemaker-Studio-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
102 lines (93 loc) · 3.08 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# Set this variable to true to install to the temporary folder, or to false to have the installation in permanent storage.
install_in_temp_dir=false
if [ ! -d "Fooocus" ]
then
git clone https://github.com/mashb1t/Fooocus.git
fi
cd Fooocus
git pull
if [ "$install_in_temp_dir" = true ]
then
echo "Installation folder: /tmp/fooocus_env"
if [ ! -L ~/.conda/envs/fooocus ]
then
echo "removing ~/.conda/envs/fooocus"
rm -rf ~/.conda/envs/fooocus
rmdir ~/.conda/envs/fooocus
ln -s /tmp/fooocus_env ~/.conda/envs/fooocus
fi
else
echo "Installation folder: ~/.conda/envs/fooocus"
if [ -L ~/.conda/envs/fooocus ]
then
rm ~/.conda/envs/fooocus
fi
fi
eval "$(conda shell.bash hook)"
if [ ! -d ~/.conda/envs/fooocus ]
then
echo ".conda/envs/fooocus is not a directory or does not exist"
fi
if [ ! -d /tmp/fooocus_env ]
then
echo "/tmp/fooocus_env is currently not a directory"
fi
if [ "$install_in_temp_dir" = true ] && [ ! -d /tmp/fooocus_env ] || [ "$install_in_temp_dir" = false ] && [ ! -d ~/.conda/envs/fooocus ]
then
echo "Installing"
if [ "$install_in_temp_dir" = true ] && [ ! -d /tmp/fooocus_env ]
then
echo "Creating /tmp/fooocus_env"
mkdir /tmp/fooocus_env
fi
conda env create -f environment.yaml
conda activate fooocus
pwd
ls
pip install -r requirements_versions.txt
pip install torch torchvision --force-reinstall --index-url https://download.pytorch.org/whl/cu117
pip install opencv-python-headless
# Install ngrok
pip install pyngrok
# Install openssh for pinggy
#conda config --add channels conda-forge
#conda config --set channel_priority strict
#conda install openssh -y
# Install zrok
#mkdir /home/studio-lab-user/zrok
#wget https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz -O /home/studio-lab-user/zrok/zrok.tar.gz
#tar -xvf /home/studio-lab-user/zrok/zrok.tar.gz -C /home/studio-lab-user/zrok
#chmod a+x /home/studio-lab-user/zrok/zrok
rm -f /opt/conda/.condarc
conda install -y conda-forge::glib
rm -rf ~/.cache/pip
fi
# Because the file manager in Sagemaker Studio Lab ignores the folder called "checkpoints"
# we need to move checkpoint files into a folder with a different name
current_folder=$(pwd)
model_folder=${current_folder}/models/checkpoints-real-folder
if [ ! -e config.txt ]
then
json_data="{ \"path_checkpoints\": \"$model_folder\" }"
echo "$json_data" > config.txt
echo "JSON file created: config.txt"
else
echo "Updating config.txt to use checkpoints-real-folder"
jq --arg new_value "$model_folder" '.path_checkpoints = $new_value' config.txt > config_tmp.txt && mv config_tmp.txt config.txt
fi
# If the checkpoints folder exists, move it to the new checkpoints-real-folder
if [ ! -L models/checkpoints ]
then
mv models/checkpoints models/checkpoints-real-folder
ln -s models/checkpoints-real-folder models/checkpoints
fi
conda activate fooocus
cd ..
if [ $# -eq 0 ]
then
python start-ngrok-zrok.py
elif [ $1 = "reset" ]
then
python start-ngrok-zrok.py --reset
fi