prithivMLmods commited on
Commit
b33e20d
β€’
1 Parent(s): 0ab83f9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -58
app.py DELETED
@@ -1,58 +0,0 @@
1
- # -* coding:UTF-8 -*
2
- # !/usr/bin/env python
3
- import numpy as np
4
- import roop.globals
5
- from roop.core import (
6
- start,
7
- decode_execution_providers,
8
- suggest_max_memory,
9
- suggest_execution_threads,
10
- )
11
- from roop.processors.frame.core import get_frame_processors_modules
12
- from roop.utilities import normalize_output_path
13
- from PIL import Image
14
- import gradio as gr
15
- import os
16
-
17
- def swap_face(source_file, target_file):
18
- source_image = Image.fromarray(source_file)
19
- source_path = "input.jpg"
20
- source_image.save(source_path, format="JPEG", quality=95)
21
-
22
-
23
- output_path = "output.mp4"
24
-
25
- roop.globals.source_path = source_path
26
- roop.globals.target_path = target_file
27
-
28
-
29
-
30
- roop.globals.output_path = normalize_output_path(
31
- roop.globals.source_path, roop.globals.target_path, output_path
32
- )
33
- roop.globals.frame_processors = ["face_swapper", "face_enhancer"]
34
- roop.globals.headless = True
35
- roop.globals.keep_fps = True
36
- roop.globals.keep_audio = True
37
- roop.globals.keep_frames = False
38
- roop.globals.many_faces = False
39
- roop.globals.video_encoder = "libx264"
40
- roop.globals.video_quality = 50
41
- roop.globals.max_memory = suggest_max_memory()
42
- roop.globals.execution_providers = decode_execution_providers(["cpu"])
43
- roop.globals.execution_threads = suggest_execution_threads()
44
- for frame_processor in get_frame_processors_modules(
45
- roop.globals.frame_processors
46
- ):
47
- if not frame_processor.pre_check():
48
- return
49
-
50
- start()
51
-
52
- return os.path.join(os.getcwd(), output_path)
53
-
54
- app = gr.Interface(
55
- fn=swap_face, inputs=[gr.Image(), gr.Video()], outputs=[gr.Video()], description="This model is running on CPU an might be slow. To run in gpu, contact the space owner. To suport the space owner please: https://donate.stripe.com/3csg0D0tadXU4mYcMM"
56
- )
57
-
58
- app.launch()