File size: 684 Bytes
0a31b92 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import torch
from transformers import AutoConfig
# تحميل النموذج الأصلي
model_path = "best_model_improved.pth"
model = torch.load(model_path)
# إنشاء ملف التكوين إذا لم يكن موجوداً
config = AutoConfig.for_model("efficientnet-b0",
num_labels=2, # عدد الفئات (حقيقي/مزيف)
label2id={"real": 0, "fake": 1},
id2label={0: "real", 1: "fake"})
config.save_pretrained("./")
# حفظ النموذج بصيغة pytorch_model.bin
torch.save(model.state_dict(), "pytorch_model.bin")
print("تم تحويل النموذج بنجاح!")
|