Transformers
Inference Endpoints
vorstcavry commited on
Commit
0f9fac8
1 Parent(s): 6c4cd5d

Upload a.py

Browse files
Files changed (1) hide show
  1. a.py +59 -0
a.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """a.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1Y6IofzwyAJq64pL9FXFK_3nARPIN6l7C
8
+ """
9
+
10
+ flag_file = f"{root_path}/libraries_installed.txt"
11
+
12
+ if not os.path.exists(flag_file):
13
+ print("💿 Installing the libraries, it's going to take a while:\n")
14
+
15
+ install_lib = {
16
+ "gdown": "pip install -U gdown",
17
+ "aria2": "apt-get update && apt -y install aria2",
18
+ "localtunnel": "npm install -g localtunnel &> /dev/null",
19
+ "insightface": "pip install insightface",
20
+ }
21
+
22
+ # Dictionary of additional libraries specific to certain environments
23
+ additional_libs = {
24
+ "Google Colab": {
25
+ "xformers": "pip install xformers==0.0.25 --no-deps",
26
+ "gradio": "pip install gradio_client==0.2.7"
27
+ },
28
+ "Kaggle": {
29
+ "xformers": "pip install -q xformers==0.0.23.post1 triton==2.1.0",
30
+ "torch": "pip install -q torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121"
31
+ }
32
+ }
33
+
34
+ # If the current environment has additional libraries, update the install_lib dictionary
35
+ if env in additional_libs:
36
+ install_lib.update(additional_libs[env])
37
+
38
+ # Loop through libraries and execute install commands
39
+ for index, (package, install_cmd) in enumerate(install_lib.items(), start=1):
40
+ print(f"\r[{index}/{len(install_lib)}] \033[32m>>\033[0m Installing \033[33m{package}\033[0m..." + " "*35, end='')
41
+ subprocess.run(install_cmd, shell=True, capture_output=True)
42
+
43
+ # Additional manual installation steps for specific packages
44
+ with capture.capture_output() as cap:
45
+ get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
46
+ get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
47
+ get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz && tar -xzf zrok_0.4.23_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.23_linux_amd64.tar.gz')
48
+
49
+ del cap
50
+
51
+ clear_output()
52
+
53
+ # Save file install lib
54
+ with open(flag_file, "w") as f:
55
+ f.write(">W<'")
56
+
57
+ print("🍪 Libraries are installed!" + " "*35)
58
+ time.sleep(2)
59
+ clear_output()