Create run.py
Browse files
run.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import os
|
| 3 |
+
from scripts.swap import run_swap
|
| 4 |
+
|
| 5 |
+
def parse_args():
|
| 6 |
+
parser = argparse.ArgumentParser(description="Face Swap con Roop (por imagen)")
|
| 7 |
+
parser.add_argument("-s", "--source", required=True, help="Ruta al rostro base (RB)")
|
| 8 |
+
parser.add_argument("-t", "--target", required=True, help="Ruta a la imagen objetivo")
|
| 9 |
+
parser.add_argument("-o", "--output", required=True, help="Ruta para guardar el resultado")
|
| 10 |
+
parser.add_argument("--execution-provider", default="cpu", help="cpu o cuda")
|
| 11 |
+
parser.add_argument("--frame-processor", nargs="+", default=["face_swapper"], help="Procesadores: face_swapper, face_enhancer")
|
| 12 |
+
return parser.parse_args()
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
args = parse_args()
|
| 16 |
+
|
| 17 |
+
os.makedirs(os.path.dirname(args.output), exist_ok=True)
|
| 18 |
+
|
| 19 |
+
result = run_swap(
|
| 20 |
+
target_path=args.target,
|
| 21 |
+
source_path=args.source,
|
| 22 |
+
output_path=args.output,
|
| 23 |
+
execution_provider=args.execution_provider,
|
| 24 |
+
frame_processors=args.frame_processor
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
if result:
|
| 28 |
+
print(f"✅ Proceso exitoso: {args.target} → {args.output}")
|
| 29 |
+
else:
|
| 30 |
+
print(f"❌ Falló el proceso con {args.target}")
|
| 31 |
+
|
| 32 |
+
if __name__ == "__main__":
|
| 33 |
+
main()
|