Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,9 +21,6 @@ app.prepare(ctx_id=0, det_size=(640, 640))
|
|
| 21 |
# ensure model downloads fully
|
| 22 |
swapper = insightface.model_zoo.get_model('inswapper_128.onnx', download=True, download_zip=True)
|
| 23 |
|
| 24 |
-
# ---------- CTA / marketing config ----------
|
| 25 |
-
BASE_UTM = "utm_source=hfspace_faceswap"
|
| 26 |
-
|
| 27 |
# ---------- Swap logic ----------
|
| 28 |
def swap_faces(src_img, dest_img):
|
| 29 |
# Pre-run nudge
|
|
@@ -63,7 +60,7 @@ def swap_faces(src_img, dest_img):
|
|
| 63 |
def open_side():
|
| 64 |
return gr.Sidebar(open=True)
|
| 65 |
|
| 66 |
-
# ---------- Custom CSS
|
| 67 |
CUSTOM_CSS = """
|
| 68 |
.sticky-cta {
|
| 69 |
position: sticky; top: 0; z-index: 1000;
|
|
@@ -134,7 +131,7 @@ CUSTOM_CSS = """
|
|
| 134 |
"""
|
| 135 |
|
| 136 |
# ---------- UI (Blocks) ----------
|
| 137 |
-
with gr.Blocks(title="Image Face Swap",
|
| 138 |
# Sticky banner
|
| 139 |
gr.HTML(
|
| 140 |
'<a class="sticky-cta" '
|
|
@@ -217,7 +214,7 @@ with gr.Blocks(title="Image Face Swap", theme=gr.themes.Soft(), css=CUSTOM_CSS)
|
|
| 217 |
'</div>'
|
| 218 |
)
|
| 219 |
|
| 220 |
-
# Open sidebar
|
| 221 |
go.click(fn=open_side, inputs=None, outputs=side, queue=False)
|
| 222 |
|
| 223 |
# Main action
|
|
@@ -240,4 +237,5 @@ with gr.Blocks(title="Image Face Swap", theme=gr.themes.Soft(), css=CUSTOM_CSS)
|
|
| 240 |
demo.queue()
|
| 241 |
|
| 242 |
if __name__ == "__main__":
|
| 243 |
-
|
|
|
|
|
|
| 21 |
# ensure model downloads fully
|
| 22 |
swapper = insightface.model_zoo.get_model('inswapper_128.onnx', download=True, download_zip=True)
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
# ---------- Swap logic ----------
|
| 25 |
def swap_faces(src_img, dest_img):
|
| 26 |
# Pre-run nudge
|
|
|
|
| 60 |
def open_side():
|
| 61 |
return gr.Sidebar(open=True)
|
| 62 |
|
| 63 |
+
# ---------- Custom CSS ----------
|
| 64 |
CUSTOM_CSS = """
|
| 65 |
.sticky-cta {
|
| 66 |
position: sticky; top: 0; z-index: 1000;
|
|
|
|
| 131 |
"""
|
| 132 |
|
| 133 |
# ---------- UI (Blocks) ----------
|
| 134 |
+
with gr.Blocks(title="Image Face Swap", css=CUSTOM_CSS) as demo:
|
| 135 |
# Sticky banner
|
| 136 |
gr.HTML(
|
| 137 |
'<a class="sticky-cta" '
|
|
|
|
| 214 |
'</div>'
|
| 215 |
)
|
| 216 |
|
| 217 |
+
# Open sidebar when user starts a swap
|
| 218 |
go.click(fn=open_side, inputs=None, outputs=side, queue=False)
|
| 219 |
|
| 220 |
# Main action
|
|
|
|
| 237 |
demo.queue()
|
| 238 |
|
| 239 |
if __name__ == "__main__":
|
| 240 |
+
# In Gradio 4.x, theme goes here, NOT in gr.Blocks()
|
| 241 |
+
demo.launch(theme=gr.themes.Soft())
|