Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
import os
|
4 |
+
from IPython import get_ipython
|
5 |
+
from IPython.display import display, Markdown
|
6 |
+
|
7 |
+
COLAB = True
|
8 |
+
|
9 |
+
if COLAB:
|
10 |
+
from google.colab.output import clear as clear_output
|
11 |
+
else:
|
12 |
+
from IPython.display import clear_output
|
13 |
+
|
14 |
+
#@title ## π© Start Here
|
15 |
+
|
16 |
+
#@markdown ### 1οΈβ£ Setup
|
17 |
+
#@markdown This cell will load some requirements and create the necessary folders in your Google Drive. <p>
|
18 |
+
#@markdown Your project name can't contain spaces but it can contain a single / to make a subfolder in your dataset.
|
19 |
+
project_name = "LillieBlueDress" #@param {type:"string"}
|
20 |
+
project_name = project_name.strip()
|
21 |
+
#@markdown The folder structure doesn't matter and is purely for comfort. Make sure to always pick the same one. I like organizing by project.
|
22 |
+
folder_structure = "Organize by project (MyDrive/Loras/project_name/dataset)" #@param ["Organize by category (MyDrive/lora_training/datasets/project_name)", "Organize by project (MyDrive/Loras/project_name/dataset)"]
|
23 |
+
|
24 |
+
if not project_name or any(c in project_name for c in " .()\"'\\") or project_name.count("/") > 1:
|
25 |
+
print("Please write a valid project_name, project name cannot have.()\"'\\.")
|
26 |
+
else:
|
27 |
+
if COLAB and not os.path.exists('/content/drive'):
|
28 |
+
from google.colab import drive
|
29 |
+
print("π Connecting to Google Drive...")
|
30 |
+
drive.mount('/content/drive')
|
31 |
+
|
32 |
+
project_base = project_name if "/" not in project_name else project_name[:project_name.rfind("/")]
|
33 |
+
project_subfolder = project_name if "/" not in project_name else project_name[project_name.rfind("/")+1:]
|
34 |
+
|
35 |
+
root_dir = "/content" if COLAB else "~/Loras"
|
36 |
+
deps_dir = os.path.join(root_dir, "deps")
|
37 |
+
|
38 |
+
if "/Loras" in folder_structure:
|
39 |
+
main_dir = os.path.join(root_dir, "drive/MyDrive/Loras") if COLAB else root_dir
|
40 |
+
config_folder = os.path.join(main_dir, project_base)
|
41 |
+
images_folder = os.path.join(main_dir, project_base, "dataset")
|
42 |
+
if "/" in project_name:
|
43 |
+
images_folder = os.path.join(images_folder, project_subfolder)
|
44 |
+
else:
|
45 |
+
main_dir = os.path.join(root_dir, "drive/MyDrive/lora_training") if COLAB else root_dir
|
46 |
+
config_folder = os.path.join(main_dir, "config", project_name)
|
47 |
+
images_folder = os.path.join(main_dir, "datasets", project_name)
|
48 |
+
|
49 |
+
for dir in [main_dir, deps_dir, images_folder, config_folder]:
|
50 |
+
os.makedirs(dir, exist_ok=True)
|
51 |
+
|
52 |
+
print(f"β
Project {project_name} is ready!")
|
53 |
+
step1_installed_flag = True
|