Update app.py
Browse files
app.py
CHANGED
|
@@ -154,50 +154,53 @@ def get_my_model(url_data, progress=gr.Progress(track_tqdm=True)):
|
|
| 154 |
# ==================== नया मॉडल स्कैनिंग लॉजिक (फिक्स) ====================
|
| 155 |
def scan_models():
|
| 156 |
"""
|
| 157 |
-
logs फ़ोल्डर के अंदर क
|
| 158 |
-
|
| 159 |
-
संबंधित .index फ़ाइल उसी डायरेक्टरी में या logs फ़ोल्डर में खोजी जाती है।
|
| 160 |
"""
|
| 161 |
logs_dir = "logs"
|
| 162 |
if not os.path.isdir(logs_dir):
|
| 163 |
return []
|
| 164 |
-
|
| 165 |
models = []
|
| 166 |
-
# प
|
|
|
|
| 167 |
for root, dirs, files in os.walk(logs_dir):
|
| 168 |
-
for
|
| 169 |
-
if
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
return models
|
| 192 |
|
| 193 |
-
def update_model_paths(
|
| 194 |
-
"""
|
| 195 |
-
ड्रॉपडाउन से चुने गए मॉडल के लिए .pth और .index के पूरे पाथ लौटाता है।
|
| 196 |
-
"""
|
| 197 |
models = scan_models()
|
| 198 |
-
for
|
| 199 |
-
if
|
| 200 |
-
return pth, idx
|
| 201 |
return None, None
|
| 202 |
|
| 203 |
# ========== ऑडियो इफेक्ट्स ==========
|
|
|
|
| 154 |
# ==================== नया मॉडल स्कैनिंग लॉजिक (फिक्स) ====================
|
| 155 |
def scan_models():
|
| 156 |
"""
|
| 157 |
+
logs फ़ोल्डर के अंदर कहीं भी .pth और .index जोड़ी ढूंढता है।
|
| 158 |
+
ड्रॉपडाउन के लिए (display_name, pth_path, idx_path) की सूची बनाता है।
|
|
|
|
| 159 |
"""
|
| 160 |
logs_dir = "logs"
|
| 161 |
if not os.path.isdir(logs_dir):
|
| 162 |
return []
|
| 163 |
+
|
| 164 |
models = []
|
| 165 |
+
# पहले सभी .pth फ़ाइलें ढूंढें
|
| 166 |
+
pth_files = []
|
| 167 |
for root, dirs, files in os.walk(logs_dir):
|
| 168 |
+
for f in files:
|
| 169 |
+
if f.endswith(".pth"):
|
| 170 |
+
pth_files.append(os.path.join(root, f))
|
| 171 |
+
|
| 172 |
+
for pth_path in pth_files:
|
| 173 |
+
base = os.path.splitext(pth_path)[0] # बिना .pth
|
| 174 |
+
# .index फ़ाइल खोजें
|
| 175 |
+
idx_path = None
|
| 176 |
+
# पहले उसी फ़ोल्डर में
|
| 177 |
+
dir_name = os.path.dirname(pth_path)
|
| 178 |
+
for ext in ['.index', '.added.index']:
|
| 179 |
+
candidate = base + ext
|
| 180 |
+
if os.path.isfile(candidate):
|
| 181 |
+
idx_path = candidate
|
| 182 |
+
break
|
| 183 |
+
# अगर न मिले तो पूरे logs में ढूंढें
|
| 184 |
+
if not idx_path:
|
| 185 |
+
for ext in ['.index', '.added.index']:
|
| 186 |
+
candidate = base + ext
|
| 187 |
+
if os.path.isfile(candidate):
|
| 188 |
+
idx_path = candidate
|
| 189 |
+
break
|
| 190 |
+
# अगर .index मिल गया तो ही मॉडल को लिस्ट में डालें
|
| 191 |
+
if idx_path and os.path.isfile(idx_path):
|
| 192 |
+
# डिस्प्ले नाम: फ़ोल्डर/फ़ाइलनाम (बिना .pth)
|
| 193 |
+
rel_path = os.path.relpath(pth_path, logs_dir)
|
| 194 |
+
display_name = os.path.splitext(rel_path)[0].replace(os.sep, " > ")
|
| 195 |
+
models.append((display_name, pth_path, idx_path))
|
| 196 |
+
|
| 197 |
return models
|
| 198 |
|
| 199 |
+
def update_model_paths(display_name):
|
|
|
|
|
|
|
|
|
|
| 200 |
models = scan_models()
|
| 201 |
+
for name, pth, idx in models:
|
| 202 |
+
if name == display_name:
|
| 203 |
+
return pth, idx
|
| 204 |
return None, None
|
| 205 |
|
| 206 |
# ========== ऑडियो इफेक्ट्स ==========
|