engineofperplexity commited on
Commit
592406a
Β·
1 Parent(s): 9741963

fixed readme

Browse files
Files changed (1) hide show
  1. readme.md +43 -61
readme.md CHANGED
@@ -1,42 +1,37 @@
 
1
  # ComfyUI LoRA Metadata Scraper
2
 
3
- This is a Python tool that scans a ComfyUI installation and extracts metadata from `.safetensors` files, including LoRAs, checkpoints, VAEs, and ControlNets. It supports both local metadata extraction and optional scraping of CivitAI metadata, including preview images and videos.
4
 
5
- What it does:
6
- - Extracts embedded metadata from `.safetensors` files
7
- - Optionally scrapes CivitAI metadata (tags, descriptions, trained words)
8
- - Downloads preview images and videos
9
- - Smart deduplication: skips files that already have metadata or previews
10
- - Lets you scan only the LoRA folder or your entire ComfyUI setup
11
- - Lets you choose how many preview images/videos to download (or none)
12
- - Saves previews in a subdirectory or alongside your model files
13
 
14
- --------------------
 
 
 
 
 
 
 
15
 
16
- ## Folder Setup
17
 
18
  Place everything inside:
19
 
20
- ComfyUI/utils/Scrapertool/
21
-
22
- Example structure:
23
-
24
  ComfyUI/
25
  └── utils/
26
  └── Scrapertool/
27
- β”œβ”€β”€ scraper_run.py
28
  β”œβ”€β”€ requirements.txt
29
- └── start.bat (optional launcher)
30
 
31
- --------------------
32
 
33
- ## Usage
34
-
35
- ### Option 1: Interactive Mode
36
 
37
  Run:
38
 
39
- python scraper_run.py --interactive
40
 
41
  You’ll be prompted:
42
 
@@ -47,18 +42,16 @@ D) Scan only the LoRA folder? (Y/N)
47
  E) Save previews in a subdirectory? (Y/N)
48
  F) How many preview images/videos to download? (A=All, N=None, or a number)
49
 
50
- ### Option 2: Command Line Arguments
51
 
52
  Example:
53
 
54
- python scraper_run.py --scrape-civitai --delay 0.5 --force --loras-only --previews-subdir --max-media 5
55
-
56
- --------------------
57
 
58
- ## Command-Line Argument Reference
59
 
60
  --interactive
61
- Launch the interactive menu.
62
 
63
  --scrape-civitai
64
  Enable scraping of metadata and previews from CivitAI.
@@ -67,7 +60,7 @@ python scraper_run.py --scrape-civitai --delay 0.5 --force --loras-only --previe
67
  Set the delay between API calls and image/video downloads (default: 0.5 seconds).
68
 
69
  --force
70
- Force re-scraping even if a metadata JSON already exists.
71
 
72
  --loras-only
73
  Scan only the ComfyUI/models/loras folder. If omitted, scans all subdirectories.
@@ -76,67 +69,56 @@ python scraper_run.py --scrape-civitai --delay 0.5 --force --loras-only --previe
76
  Save previews inside a dedicated subdirectory (e.g., model_previews/).
77
 
78
  --no-previews-subdir
79
- Save previews directly next to the model file.
80
 
81
  --max-media [number]
82
- Set how many preview images/videos to download. Use 0 to skip all. (Default: unlimited)
83
-
84
- --------------------
85
 
86
- ## How It Finds CivitAI Metadata
87
 
88
- 1. First, it checks if the `.safetensors` file includes a `civitai_metadata` block (newly fixed!).
89
- - If found, it extracts the `civitai_model_id` from that nested block.
90
- 2. If not found, it falls back to looking up the file’s SHA256 hash using the CivitAI API.
91
 
92
- This ensures maximum coverage even if metadata is incomplete.
93
 
94
- --------------------
95
-
96
- ## Dependencies
97
-
98
- This script requires the following Python packages:
99
 
100
  safetensors
101
  torch
102
  requests
103
  tqdm
104
 
105
- --------------------
106
-
107
- ## How to Set Up
108
 
109
- 1. Create a virtual environment (recommended):
110
 
111
- python -m venv scrapervenv
112
 
113
  2. Activate the virtual environment:
114
 
115
- On Windows:
116
- scrapervenv\Scripts\activate
117
 
118
- On macOS/Linux:
119
- source scrapervenv/bin/activate
120
 
121
  3. Install dependencies:
122
 
123
- pip install -r requirements.txt
124
 
125
- --------------------
126
-
127
- ## requirements.txt
128
 
129
  safetensors
130
  torch
131
  requests
132
  tqdm
133
 
134
- --------------------
135
-
136
- ## License
137
 
138
  Creative Commons Attribution 4.0 International (CC BY 4.0)
139
 
140
- This tool is free to use, share, and adapt for any purpose, including commercial use, as long as you provide attribution to the original creator.
 
 
141
 
142
- --------------------
 
1
+
2
  # ComfyUI LoRA Metadata Scraper
3
 
4
+ This is a Python tool to recursively extract metadata from `.safetensors` files inside your ComfyUI installation. It supports both local metadata extraction and optional CivitAI scraping (for trigger words, tags, descriptions, and preview images/videos).
5
 
6
+ Features:
 
 
 
 
 
 
 
7
 
8
+ - Extracts metadata from LoRAs, checkpoints, VAEs, and ControlNets
9
+ - Optionally scrapes CivitAI data (tags, trigger words, preview images/videos)
10
+ - Skips files that are already processed (unless forced)
11
+ - Lets you scan only the LoRAs folder or the entire ComfyUI setup
12
+ - Saves previews in subdirectories or alongside model files
13
+ - Supports downloading all, none, or a specific number of previews
14
+ - Fully interactive OR command-line friendly
15
+ - Gracefully handles CivitAI rate limiting and retries
16
 
17
+ Folder Setup:
18
 
19
  Place everything inside:
20
 
 
 
 
 
21
  ComfyUI/
22
  └── utils/
23
  └── Scrapertool/
24
+ β”œβ”€β”€ scrape_metadata_recursive.py
25
  β”œβ”€β”€ requirements.txt
26
+ └── run_scraper.bat (optional launcher)
27
 
28
+ Usage:
29
 
30
+ Option 1: Interactive Mode
 
 
31
 
32
  Run:
33
 
34
+ python scrape_metadata_recursive.py --interactive
35
 
36
  You’ll be prompted:
37
 
 
42
  E) Save previews in a subdirectory? (Y/N)
43
  F) How many preview images/videos to download? (A=All, N=None, or a number)
44
 
45
+ Option 2: Command-Line Arguments
46
 
47
  Example:
48
 
49
+ python scrape_metadata_recursive.py --scrape-civitai --delay 0.5 --force --loras-only --previews-subdir --max-media 5
 
 
50
 
51
+ Command-Line Arguments:
52
 
53
  --interactive
54
+ Launch interactive menu.
55
 
56
  --scrape-civitai
57
  Enable scraping of metadata and previews from CivitAI.
 
60
  Set the delay between API calls and image/video downloads (default: 0.5 seconds).
61
 
62
  --force
63
+ Force re-scrape even if metadata JSON already exists.
64
 
65
  --loras-only
66
  Scan only the ComfyUI/models/loras folder. If omitted, scans all subdirectories.
 
69
  Save previews inside a dedicated subdirectory (e.g., model_previews/).
70
 
71
  --no-previews-subdir
72
+ Save previews directly alongside the model file.
73
 
74
  --max-media [number]
75
+ Set max number of preview images/videos to download (0 = none, default = all).
 
 
76
 
77
+ How It Finds CivitAI Metadata:
78
 
79
+ 1. First, the script checks if the `.safetensors` file contains a `civitai_metadata` block (fixed in the latest version to look in the correct place).
80
+ 2. If that block is missing, it falls back to computing the SHA256 hash and queries CivitAI using that.
 
81
 
82
+ This ensures compatibility even if metadata is incomplete.
83
 
84
+ Dependencies:
 
 
 
 
85
 
86
  safetensors
87
  torch
88
  requests
89
  tqdm
90
 
91
+ Setup Instructions:
 
 
92
 
93
+ 1. Create a virtual environment:
94
 
95
+ python -m venv scrapervenv
96
 
97
  2. Activate the virtual environment:
98
 
99
+ On Windows:
100
+ scrapervenv\Scripts\activate
101
 
102
+ On macOS/Linux:
103
+ source scrapervenv/bin/activate
104
 
105
  3. Install dependencies:
106
 
107
+ pip install -r requirements.txt
108
 
109
+ requirements.txt:
 
 
110
 
111
  safetensors
112
  torch
113
  requests
114
  tqdm
115
 
116
+ License:
 
 
117
 
118
  Creative Commons Attribution 4.0 International (CC BY 4.0)
119
 
120
+ You may use, share, and adapt this tool for any purposeβ€”including commercial useβ€”as long as you provide attribution to the original creator.
121
+
122
+ Contributing:
123
 
124
+ Contributions and improvements are welcome. Please fork, submit pull requests, or open an issue if you'd like to suggest features or report bugs.