Ii
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -2,30 +2,9 @@ import gradio as gr
|
|
2 |
from refacer import Refacer
|
3 |
import argparse
|
4 |
import os
|
5 |
-
import requests
|
6 |
-
import tempfile
|
7 |
-
import shutil
|
8 |
|
9 |
-
# Hugging Face
|
10 |
-
|
11 |
-
model_path = "./inswapper_128.onnx"
|
12 |
-
|
13 |
-
# Function to download the model
|
14 |
-
def download_model():
|
15 |
-
if not os.path.exists(model_path):
|
16 |
-
print("Downloading inswapper_128.onnx...")
|
17 |
-
response = requests.get(model_url)
|
18 |
-
if response.status_code == 200:
|
19 |
-
with open(model_path, 'wb') as f:
|
20 |
-
f.write(response.content)
|
21 |
-
print("Model downloaded successfully!")
|
22 |
-
else:
|
23 |
-
raise Exception(f"Failed to download the model. Status code: {response.status_code}")
|
24 |
-
else:
|
25 |
-
print("Model already exists.")
|
26 |
-
|
27 |
-
# Download the model when the script runs
|
28 |
-
download_model()
|
29 |
|
30 |
# Argument parser
|
31 |
parser = argparse.ArgumentParser(description='Refacer')
|
@@ -62,7 +41,7 @@ def run(*vars):
|
|
62 |
refaced_video_path = refacer.reface(video_path, faces) # refaced video path
|
63 |
print(f"Refaced video can be found at {refaced_video_path}")
|
64 |
|
65 |
-
#
|
66 |
return refaced_video_path # Gradio will handle the video display
|
67 |
|
68 |
# Prepare Gradio components
|
|
|
2 |
from refacer import Refacer
|
3 |
import argparse
|
4 |
import os
|
|
|
|
|
|
|
5 |
|
6 |
+
# Hugging Face Space-இல் model path
|
7 |
+
model_path = "./models/inswapper_128.onnx"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Argument parser
|
10 |
parser = argparse.ArgumentParser(description='Refacer')
|
|
|
41 |
refaced_video_path = refacer.reface(video_path, faces) # refaced video path
|
42 |
print(f"Refaced video can be found at {refaced_video_path}")
|
43 |
|
44 |
+
# Instead of saving to disk, return the path to Gradio UI directly
|
45 |
return refaced_video_path # Gradio will handle the video display
|
46 |
|
47 |
# Prepare Gradio components
|