Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import gradio as gr
|
|
| 6 |
from PIL import Image
|
| 7 |
from rembg import remove
|
| 8 |
import sys
|
|
|
|
| 9 |
import subprocess
|
| 10 |
from glob import glob
|
| 11 |
import requests
|
|
@@ -25,6 +26,15 @@ snapshot_download(
|
|
| 25 |
local_dir = "./smpl_related"
|
| 26 |
)
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
def remove_background(input_url):
|
| 30 |
# Create a temporary folder for downloaded and processed images
|
|
@@ -41,7 +51,8 @@ def remove_background(input_url):
|
|
| 41 |
|
| 42 |
# Run background removal
|
| 43 |
try:
|
| 44 |
-
|
|
|
|
| 45 |
img = Image.open(image_path)
|
| 46 |
result = remove(img)
|
| 47 |
result.save(removed_bg_path)
|
|
@@ -111,11 +122,16 @@ def process_image(input_url):
|
|
| 111 |
|
| 112 |
def gradio_interface():
|
| 113 |
with gr.Blocks() as app:
|
| 114 |
-
gr.Markdown("#
|
| 115 |
|
| 116 |
with gr.Row():
|
| 117 |
input_image = gr.Image(label="Image input", type="filepath")
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
output_video= gr.Video(label="Output Video")
|
| 121 |
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
from rembg import remove
|
| 8 |
import sys
|
| 9 |
+
import uuid
|
| 10 |
import subprocess
|
| 11 |
from glob import glob
|
| 12 |
import requests
|
|
|
|
| 26 |
local_dir = "./smpl_related"
|
| 27 |
)
|
| 28 |
|
| 29 |
+
# Folder containing example images
|
| 30 |
+
examples_folder = "examples"
|
| 31 |
+
|
| 32 |
+
# Retrieve all file paths in the folder
|
| 33 |
+
images_examples = [
|
| 34 |
+
os.path.join(examples_folder, file)
|
| 35 |
+
for file in os.listdir(examples_folder)
|
| 36 |
+
if os.path.isfile(os.path.join(examples_folder, file))
|
| 37 |
+
]
|
| 38 |
|
| 39 |
def remove_background(input_url):
|
| 40 |
# Create a temporary folder for downloaded and processed images
|
|
|
|
| 51 |
|
| 52 |
# Run background removal
|
| 53 |
try:
|
| 54 |
+
unique_id = str(uuid.uuid4())
|
| 55 |
+
removed_bg_path = os.path.join(temp_dir, f'output_image_rmbg_{unique_id}.png')
|
| 56 |
img = Image.open(image_path)
|
| 57 |
result = remove(img)
|
| 58 |
result.save(removed_bg_path)
|
|
|
|
| 122 |
|
| 123 |
def gradio_interface():
|
| 124 |
with gr.Blocks() as app:
|
| 125 |
+
gr.Markdown("# PSHuman: Photorealistic Single-image 3D Human Reconstruction using Cross-Scale Multiview Diffusion and Explicit Remeshing")
|
| 126 |
|
| 127 |
with gr.Row():
|
| 128 |
input_image = gr.Image(label="Image input", type="filepath")
|
| 129 |
+
with gr.Column():
|
| 130 |
+
submit_button = gr.Button("Process")
|
| 131 |
+
gr.Examples(
|
| 132 |
+
examples = examples_folder,
|
| 133 |
+
inputs = [input_images]
|
| 134 |
+
)
|
| 135 |
|
| 136 |
output_video= gr.Video(label="Output Video")
|
| 137 |
|