Spaces:
Running
Running
Update src/facerender/animate.py
Browse files- src/facerender/animate.py +4 -16
src/facerender/animate.py
CHANGED
@@ -131,26 +131,13 @@ class AnimateFromCoeff():
|
|
131 |
def load_cpk_mapping(self, checkpoint_path, mapping=None, discriminator=None,
|
132 |
optimizer_mapping=None, optimizer_discriminator=None, device='cpu'):
|
133 |
|
134 |
-
# Eğer dosya
|
135 |
if os.path.isdir(checkpoint_path):
|
136 |
archive_path = os.path.join(checkpoint_path, "archive", "data.pkl")
|
137 |
if os.path.isfile(archive_path):
|
138 |
-
print(f"📦 data.pkl bulundu: {archive_path}")
|
139 |
checkpoint_path = archive_path
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
# Eğer tar dosyasıysa sadece kontrol amaçlı bakıyoruz
|
144 |
-
elif checkpoint_path.endswith(".tar"):
|
145 |
-
try:
|
146 |
-
with tarfile.open(checkpoint_path, "r") as tar:
|
147 |
-
members = tar.getnames()
|
148 |
-
if not any("storages" in name for name in members):
|
149 |
-
print("⚠️ 'storages' klasörü .tar içinde yok. Devam ediliyor...")
|
150 |
-
except Exception as e:
|
151 |
-
print(f"Tar kontrol hatası: {e}")
|
152 |
-
|
153 |
-
# Yükleme işlemi
|
154 |
checkpoint = torch.load(checkpoint_path, map_location=torch.device(device))
|
155 |
|
156 |
if mapping is not None and 'mapping' in checkpoint:
|
@@ -164,3 +151,4 @@ class AnimateFromCoeff():
|
|
164 |
|
165 |
return checkpoint.get('epoch', 0)
|
166 |
|
|
|
|
131 |
def load_cpk_mapping(self, checkpoint_path, mapping=None, discriminator=None,
|
132 |
optimizer_mapping=None, optimizer_discriminator=None, device='cpu'):
|
133 |
|
134 |
+
# Eğer dosya bir klasörse ve archive/data.pkl varsa, orayı kullan
|
135 |
if os.path.isdir(checkpoint_path):
|
136 |
archive_path = os.path.join(checkpoint_path, "archive", "data.pkl")
|
137 |
if os.path.isfile(archive_path):
|
|
|
138 |
checkpoint_path = archive_path
|
139 |
+
|
140 |
+
# Checkpoint yükle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
checkpoint = torch.load(checkpoint_path, map_location=torch.device(device))
|
142 |
|
143 |
if mapping is not None and 'mapping' in checkpoint:
|
|
|
151 |
|
152 |
return checkpoint.get('epoch', 0)
|
153 |
|
154 |
+
|