Update
Browse filesSigned-off-by: Balazs Horvath <[email protected]>
- .zshrc +46 -0
- crawl/crawl +1 -1
- keyframe +0 -0
- paper-qa.code-workspace +0 -11
- stats +108 -0
.zshrc
CHANGED
@@ -769,6 +769,52 @@ chop_lora() {
|
|
769 |
done
|
770 |
}
|
771 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
772 |
# Function: swch (Switch Git Branch)
|
773 |
# Description:
|
774 |
# This function facilitates switching between Git branches while ensuring a clean working directory.
|
|
|
769 |
done
|
770 |
}
|
771 |
|
772 |
+
# Function cs1
|
773 |
+
# This function chops blocks from an SDXL LoRA's safetensors file to preserve the style information only.
|
774 |
+
# It uses a specific block configuration and saves the output with a modified filename.
|
775 |
+
cs1() {
|
776 |
+
# Get the target safetensors file path from the first argument
|
777 |
+
local target_safetensors=$1
|
778 |
+
|
779 |
+
# Extract the base name of the target safetensors file (without the .safetensors extension)
|
780 |
+
local base_name=$(basename "$target_safetensors" .safetensors)
|
781 |
+
|
782 |
+
# Extract the version and step string from the base name (e.g., v1s400)
|
783 |
+
local version_step=$(echo "$base_name" | grep -o 'v[0-9]*s[0-9]*')
|
784 |
+
|
785 |
+
# Remove the version and step string from the base name to avoid duplication
|
786 |
+
local base_name_no_version=$(echo "$base_name" | sed "s/${version_step}//")
|
787 |
+
|
788 |
+
# Construct the output safetensors filename by appending c1 to the version and step string
|
789 |
+
local output_safetensors="${base_name_no_version}${version_step}c1.safetensors"
|
790 |
+
|
791 |
+
# Run the chop_blocks command with the specified block configuration and output filename
|
792 |
+
~/toolkit/chop_blocks "$target_safetensors" 1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,1,1,0,0,0 -o "$output_safetensors"
|
793 |
+
}
|
794 |
+
|
795 |
+
# Function cs2
|
796 |
+
# This function chops blocks from an SDXL LoRA's safetensors file to preserve the style information only.
|
797 |
+
# It uses a different block configuration and saves the output with a modified filename.
|
798 |
+
cs2() {
|
799 |
+
# Get the target safetensors file path from the first argument
|
800 |
+
local target_safetensors=$1
|
801 |
+
|
802 |
+
# Extract the base name of the target safetensors file (without the .safetensors extension)
|
803 |
+
local base_name=$(basename "$target_safetensors" .safetensors)
|
804 |
+
|
805 |
+
# Extract the version and step string from the base name (e.g., v1s400)
|
806 |
+
local version_step=$(echo "$base_name" | grep -o 'v[0-9]*s[0-9]*')
|
807 |
+
|
808 |
+
# Remove the version and step string from the base name to avoid duplication
|
809 |
+
local base_name_no_version=$(echo "$base_name" | sed "s/${version_step}//")
|
810 |
+
|
811 |
+
# Construct the output safetensors filename by appending c2 to the version and step string
|
812 |
+
local output_safetensors="${base_name_no_version}${version_step}c2.safetensors"
|
813 |
+
|
814 |
+
# Run the chop_blocks command with the specified block configuration and output filename
|
815 |
+
~/toolkit/chop_blocks "$target_safetensors" 1,0,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,0,0 -o "$output_safetensors"
|
816 |
+
}
|
817 |
+
|
818 |
# Function: swch (Switch Git Branch)
|
819 |
# Description:
|
820 |
# This function facilitates switching between Git branches while ensuring a clean working directory.
|
crawl/crawl
CHANGED
@@ -125,7 +125,7 @@ def save_result(target_url):
|
|
125 |
# Choose the appropriate base path based on the operating system
|
126 |
if platform.system() == "Windows":
|
127 |
base_path = "E:\\datasets\\knowledgebase\\Saved Websites\\"
|
128 |
-
|
129 |
base_path = "/home/kade/datasets/knowledgebase/Saved Websites"
|
130 |
|
131 |
save_dir = os.path.join(base_path, sanitized_title)
|
|
|
125 |
# Choose the appropriate base path based on the operating system
|
126 |
if platform.system() == "Windows":
|
127 |
base_path = "E:\\datasets\\knowledgebase\\Saved Websites\\"
|
128 |
+
else:
|
129 |
base_path = "/home/kade/datasets/knowledgebase/Saved Websites"
|
130 |
|
131 |
save_dir = os.path.join(base_path, sanitized_title)
|
keyframe
CHANGED
File without changes
|
paper-qa.code-workspace
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"folders": [
|
3 |
-
{
|
4 |
-
"path": "."
|
5 |
-
},
|
6 |
-
{
|
7 |
-
"path": "../miniconda3/lib/python3.12/site-packages/paperqa"
|
8 |
-
}
|
9 |
-
],
|
10 |
-
"settings": {}
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stats
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python3
|
2 |
+
|
3 |
+
import os
|
4 |
+
import sys
|
5 |
+
from collections import Counter
|
6 |
+
|
7 |
+
# ANSI color codes
|
8 |
+
|
9 |
+
RED = "\033[91m"
|
10 |
+
GREEN = "\033[92m"
|
11 |
+
ORANGE = "\033[93m"
|
12 |
+
BLUE = "\033[94m"
|
13 |
+
MAGENTA = "\033[95m"
|
14 |
+
CYAN = "\033[96m"
|
15 |
+
RESET = "\033[0m"
|
16 |
+
|
17 |
+
EXT2COLOR = {
|
18 |
+
"jxl": CYAN,
|
19 |
+
"png": MAGENTA,
|
20 |
+
"jpg": RED,
|
21 |
+
"jpeg": RED,
|
22 |
+
"webp": MAGENTA,
|
23 |
+
"caption": BLUE,
|
24 |
+
"txt": BLUE,
|
25 |
+
}
|
26 |
+
EXT2ORDER = {ext: i for i, ext in enumerate(EXT2COLOR.keys())}
|
27 |
+
SORT_KEYS = ["name", "count", "image", "text", *EXT2COLOR.keys()]
|
28 |
+
|
29 |
+
TEXT_FORMATS = {"txt", "caption"}
|
30 |
+
IMAGE_FORMATS = EXT2COLOR.keys() - TEXT_FORMATS
|
31 |
+
|
32 |
+
|
33 |
+
def count_files(directory):
|
34 |
+
file_counts = Counter()
|
35 |
+
for root, dirs, files in os.walk(directory):
|
36 |
+
for file in files:
|
37 |
+
base_name, ext = os.path.splitext(file)
|
38 |
+
if len(ext) > 1:
|
39 |
+
ext = ext[1:]
|
40 |
+
file_counts[ext] += 1
|
41 |
+
if ext in IMAGE_FORMATS:
|
42 |
+
file_counts["image"] += 1
|
43 |
+
elif ext in TEXT_FORMATS:
|
44 |
+
file_counts["text"] += 1
|
45 |
+
|
46 |
+
return file_counts
|
47 |
+
|
48 |
+
|
49 |
+
def main():
|
50 |
+
sort_key_name = "name"
|
51 |
+
sort_reverse = False
|
52 |
+
if len(sys.argv) > 1:
|
53 |
+
sort_key_name = sys.argv[1]
|
54 |
+
if sort_key_name.endswith("_r"):
|
55 |
+
sort_reverse = True
|
56 |
+
sort_key_name = sort_key_name[:-2]
|
57 |
+
|
58 |
+
if sort_key_name == "name":
|
59 |
+
sort_key = lambda x: x[0]
|
60 |
+
elif sort_key_name == "count":
|
61 |
+
sort_key = lambda x: x[1]
|
62 |
+
elif sort_key_name in SORT_KEYS:
|
63 |
+
sort_key = lambda x: x[2].get(sort_key_name, 0)
|
64 |
+
else:
|
65 |
+
print(f'Valid short key are {", ".join(f'"{k}"' for k in SORT_KEYS)}')
|
66 |
+
print('Prepending "_r" to reverse the sort order')
|
67 |
+
sys.exit(1)
|
68 |
+
|
69 |
+
current_directory = os.getcwd()
|
70 |
+
directories = (
|
71 |
+
d
|
72 |
+
for d in os.listdir(current_directory)
|
73 |
+
if os.path.isdir(os.path.join(current_directory, d))
|
74 |
+
)
|
75 |
+
|
76 |
+
stats = []
|
77 |
+
grand_total = Counter()
|
78 |
+
for directory in directories:
|
79 |
+
dir_path = os.path.join(current_directory, directory)
|
80 |
+
counts = count_files(dir_path)
|
81 |
+
total_files = sum(v for k,v in counts.items() if k in EXT2ORDER)
|
82 |
+
stats.append((directory, total_files, counts))
|
83 |
+
grand_total.update(counts)
|
84 |
+
|
85 |
+
stats.sort(key=sort_key, reverse=sort_reverse)
|
86 |
+
stats.append((None, sum(v for k,v in grand_total.items() if k in EXT2ORDER), grand_total))
|
87 |
+
|
88 |
+
for directory, total_files, counts in stats:
|
89 |
+
if total_files == 0:
|
90 |
+
continue
|
91 |
+
if directory is None:
|
92 |
+
print(f'Grand Total: ')
|
93 |
+
print(f"Directory: {directory}")
|
94 |
+
for ext, count in sorted(
|
95 |
+
counts.items(), key=lambda x: EXT2ORDER.get(x[0], -1)
|
96 |
+
):
|
97 |
+
if counts[ext] == 0 or ext not in EXT2COLOR:
|
98 |
+
continue
|
99 |
+
print(f"{EXT2COLOR[ext]}{ext} files: {counts[ext]}{RESET}")
|
100 |
+
tally_color = GREEN if total_files >= 200 else ORANGE
|
101 |
+
print(
|
102 |
+
f"{tally_color}Total files: {total_files}{RESET} ({counts['image']} images, {counts['text']} texts)"
|
103 |
+
)
|
104 |
+
print()
|
105 |
+
|
106 |
+
|
107 |
+
if __name__ == "__main__":
|
108 |
+
main()
|