DeepBeepMeep commited on
Commit ·
36621e6
1
Parent(s): 7bec208
Added check for already download loras
Browse files- gradio_server.py +12 -3
gradio_server.py
CHANGED
|
@@ -1486,15 +1486,24 @@ def download_loras():
|
|
| 1486 |
|
| 1487 |
yield "<B><FONT SIZE=3>Please wait while the Loras are being downloaded</B></FONT>", *[gr.Column(visible=False)] * 2
|
| 1488 |
log_path = os.path.join(lora_dir, "log.txt")
|
| 1489 |
-
if not os.path.isfile(log_path):
|
| 1490 |
import shutil
|
| 1491 |
tmp_path = os.path.join(lora_dir, "tmp_lora_dowload")
|
| 1492 |
|
| 1493 |
import shutil, glob
|
| 1494 |
snapshot_download(repo_id="DeepBeepMeep/Wan2.1", allow_patterns="loras_i2v/*", local_dir= tmp_path)
|
| 1495 |
-
|
| 1496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1498 |
yield "<B><FONT SIZE=3>Loras have been completely downloaded</B></FONT>", *[gr.Column(visible=True)] * 2
|
| 1499 |
|
| 1500 |
from datetime import datetime
|
|
|
|
| 1486 |
|
| 1487 |
yield "<B><FONT SIZE=3>Please wait while the Loras are being downloaded</B></FONT>", *[gr.Column(visible=False)] * 2
|
| 1488 |
log_path = os.path.join(lora_dir, "log.txt")
|
| 1489 |
+
if not os.path.isfile(log_path) or True:
|
| 1490 |
import shutil
|
| 1491 |
tmp_path = os.path.join(lora_dir, "tmp_lora_dowload")
|
| 1492 |
|
| 1493 |
import shutil, glob
|
| 1494 |
snapshot_download(repo_id="DeepBeepMeep/Wan2.1", allow_patterns="loras_i2v/*", local_dir= tmp_path)
|
| 1495 |
+
for f in glob.glob(os.path.join(tmp_path, "loras_i2v", "*.*")):
|
| 1496 |
+
target_file = os.path.join(lora_dir, Path(f).parts[-1] )
|
| 1497 |
+
if os.path.isfile(target_file):
|
| 1498 |
+
os.remove(f)
|
| 1499 |
+
else:
|
| 1500 |
+
shutil.move(f, lora_dir)
|
| 1501 |
|
| 1502 |
+
try:
|
| 1503 |
+
os.remove(tmp_path)
|
| 1504 |
+
except:
|
| 1505 |
+
pass
|
| 1506 |
+
|
| 1507 |
yield "<B><FONT SIZE=3>Loras have been completely downloaded</B></FONT>", *[gr.Column(visible=True)] * 2
|
| 1508 |
|
| 1509 |
from datetime import datetime
|