fangbin commited on
Commit
732af2a
1 Parent(s): cedbeb8
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. app.py +26 -5
  3. requirements.txt +1 -0
Dockerfile CHANGED
@@ -40,4 +40,4 @@ RUN useradd -m appuser
40
  USER appuser
41
 
42
  # 运行应用
43
- CMD ["python", "run.py"]
 
40
  USER appuser
41
 
42
  # 运行应用
43
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -1,7 +1,28 @@
1
- from fastapi import FastAPI
 
 
 
 
 
2
 
3
- app = FastAPI()
 
 
 
 
 
 
 
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import modules.globals
3
+ import modules.processors.frame.core as frame_processor
4
+ import modules.utilities as utilities
5
+ import cv2
6
+ import os
7
 
8
+ def process_image(source_image, target_image):
9
+ modules.globals.source_path = utilities.save_temp_image(source_image)
10
+ modules.globals.target_path = utilities.save_temp_image(target_image)
11
+ modules.globals.output_path = "output.png"
12
+
13
+ frame_processor.process_image(modules.globals.source_path, modules.globals.target_path, modules.globals.output_path)
14
+
15
+ return modules.globals.output_path
16
 
17
+ iface = gr.Interface(
18
+ fn=process_image,
19
+ inputs=[
20
+ gr.Image(type="numpy", label="Source Image"),
21
+ gr.Image(type="numpy", label="Target Image")
22
+ ],
23
+ outputs=gr.Image(type="filepath", label="Output Image"),
24
+ title="Face Swapper",
25
+ description="Upload a source face and a target image to swap faces."
26
+ )
27
+
28
+ iface.launch()
requirements.txt CHANGED
@@ -20,3 +20,4 @@ tqdm==4.66.4
20
  gfpgan==1.3.8
21
  tkinterdnd2==0.4.2
22
  customtkinter==5.2.2
 
 
20
  gfpgan==1.3.8
21
  tkinterdnd2==0.4.2
22
  customtkinter==5.2.2
23
+ gradio