File size: 1,739 Bytes
2e6ced0
 
 
 
 
b4af3e0
a8f5a96
 
b4af3e0
 
 
 
 
a8f5a96
 
b4af3e0
0f6af18
 
a8f5a96
 
 
 
 
 
 
 
 
0f6af18
b4af3e0
 
d9a8c1a
b4af3e0
2e6ced0
 
 
 
 
 
 
 
 
 
 
 
b4af3e0
2e6ced0
 
 
 
 
 
 
 
 
b4af3e0
2e6ced0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import gradio as gr
import subprocess
import os
from datetime import datetime

# 🔧 Model parçalarını birleştirme fonksiyonu
def merge_model_parts():
    parts = [
        "checkpoints/facevid2vid_00189-model_aa",
        "checkpoints/facevid2vid_00189-model_bb",
        "checkpoints/facevid2vid_00189-model_cc",
        "checkpoints/facevid2vid_00189-model_dd",
        "checkpoints/facevid2vid_00189-model_ee"
    ]
    output_file = "checkpoints/facevid2vid_00189-model.pth.tar"

    os.makedirs("checkpoints", exist_ok=True)  # <-- klasörü oluştur

    if not os.path.exists(output_file):
        with open(output_file, "wb") as out:
            for part in parts:
                with open(part, "rb") as p:
                    out.write(p.read())
        print("✅ Model parçaları birleştirildi.")
    else:
        print("🟡 Birleştirilmiş dosya zaten var.")


# 🔥 Birleştirme işlemini başta yap
merge_model_parts()

# 🔁 Ana video üretim fonksiyonu
def generate_video(source_image, driven_audio):
    output_dir = "results"
    os.makedirs(output_dir, exist_ok=True)

    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    result_path = f"{output_dir}/video_{timestamp}.mp4"

    cmd = f"python inference.py --driven_audio {driven_audio} --source_image {source_image} --result_dir {output_dir} --enhancer gfpgan --pose_style 45 --still --preprocess full"
    subprocess.run(cmd, shell=True)

    return result_path

# 🎛️ Gradio arayüzü
demo = gr.Interface(
    fn=generate_video,
    inputs=[
        gr.Image(type="filepath", label="Source Image"),
        gr.Audio(type="filepath", label="Driven Audio")
    ],
    outputs=gr.Video(label="Generated Video")
)

# 🚀 Başlat
demo.launch()