Update app.py
Browse files
app.py
CHANGED
@@ -127,7 +127,7 @@ def swap_faces(target_files, male_file, female_file, enhancer_name="NONE"):
|
|
127 |
# Save the output image to a temporary file
|
128 |
with tempfile.NamedTemporaryFile(suffix=ext, delete=False) as temp_file:
|
129 |
output_path = temp_file.name
|
130 |
-
|
131 |
output_files.append(output_path)
|
132 |
|
133 |
print(f"✔ Hoàn tất tất cả trong {time.time() - start_time:.2f}s")
|
@@ -142,7 +142,7 @@ with gr.Blocks() as demo:
|
|
142 |
target_input = gr.Files(label="Files đích (ảnh)", file_types=[".jpg", ".png"])
|
143 |
male_input = gr.File(label="File nguồn Nam (ảnh)", file_types=[".jpg", ".png"])
|
144 |
female_input = gr.File(label="File nguồn Nữ (ảnh)", file_types=[".jpg", ".png"])
|
145 |
-
enhancer = gr.Dropdown(ENHANCER_CHOICES, label="Face Enhancer", value="
|
146 |
run_btn = gr.Button("✨ Swap")
|
147 |
|
148 |
with gr.Column():
|
|
|
127 |
# Save the output image to a temporary file
|
128 |
with tempfile.NamedTemporaryFile(suffix=ext, delete=False) as temp_file:
|
129 |
output_path = temp_file.name
|
130 |
+
cv2.imwrite(output_path, out_frame) # Convert BGR to RGB before saving
|
131 |
output_files.append(output_path)
|
132 |
|
133 |
print(f"✔ Hoàn tất tất cả trong {time.time() - start_time:.2f}s")
|
|
|
142 |
target_input = gr.Files(label="Files đích (ảnh)", file_types=[".jpg", ".png"])
|
143 |
male_input = gr.File(label="File nguồn Nam (ảnh)", file_types=[".jpg", ".png"])
|
144 |
female_input = gr.File(label="File nguồn Nữ (ảnh)", file_types=[".jpg", ".png"])
|
145 |
+
enhancer = gr.Dropdown(ENHANCER_CHOICES, label="Face Enhancer", value="REAL-ESRGAN 2x")
|
146 |
run_btn = gr.Button("✨ Swap")
|
147 |
|
148 |
with gr.Column():
|