Singhp08 commited on
Commit
f977587
·
verified ·
1 Parent(s): 8ffa95c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -35
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 फ़ोल्डर के अंदर किसी भी स्थान पर मौजूद .pth और .index फ़ाइल को ढूंढता है।
158
- ॉडल क ाम .pth फ़ाइल के बेसनेम (बिना एक्सटेंशन) स लिय जाता है।
159
- संबंधित .index फ़ाइल उसी डायरेक्टरी में या logs फ़ोल्डर में खोजी जाती है।
160
  """
161
  logs_dir = "logs"
162
  if not os.path.isdir(logs_dir):
163
  return []
164
-
165
  models = []
166
- # पूरे logs फ़ो्डर म .pth फ़ाइलें खोजें
 
167
  for root, dirs, files in os.walk(logs_dir):
168
- for file in files:
169
- if file.endswith(".pth"):
170
- pth_path = os.path.join(root, file)
171
- model_name = os.path.splitext(file)[0]
172
- # संबंधित .index फ़ाइल खोजें (पहले उसी फ़ोल्डर में, फिर पूरे logs में)
173
- idx_path = None
174
- # उसी फ़्डर में देखें
175
- for idx_file in os.listdir(root):
176
- if idx_file.endswith(".index") and os.path.splitext(idx_file)[0] == model_name:
177
- idx_path = os.path.join(root, idx_file)
178
- break
179
- # अगर मिले तो पूरे logs में ढूंढें
180
- if idx_path is None:
181
- for r, d, f in os.walk(logs_dir):
182
- for idx_file in f:
183
- if idx_file.endswith(".index") and os.path.splitext(idx_file)[0] == model_name:
184
- idx_path = os.path.join(r, idx_file)
185
- break
186
- if idx_path:
187
- break
188
- # डुप्लिकेट नाम से बचने के लिए यूनिक key बनाएँ (फ़ोल्डर+नाम)
189
- unique_key = os.path.relpath(pth_path, logs_dir).replace(os.sep, "_")
190
- models.append((unique_key, pth_path, idx_path if idx_path else ""))
 
 
 
 
 
 
191
  return models
192
 
193
- def update_model_paths(selected_key):
194
- """
195
- ड्रॉपडाउन से चुने गए मॉडल के लिए .pth और .index के पूरे पाथ लौटाता है।
196
- """
197
  models = scan_models()
198
- for key, pth, idx in models:
199
- if key == selected_key:
200
- return pth, idx if idx else None
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
  # ========== ऑडियो इफेक्ट्स ==========