Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,12 @@ import torch
|
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
| 6 |
import open3d as o3d
|
|
|
|
| 7 |
from pathlib import Path
|
| 8 |
import os
|
| 9 |
|
| 10 |
feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
|
|
|
|
| 11 |
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
|
| 12 |
def process_image(image_path, depth_map_path=None):
|
| 13 |
image_path = Path(image_path)
|
|
@@ -17,8 +19,10 @@ def process_image(image_path, depth_map_path=None):
|
|
| 17 |
Image.Resampling.LANCZOS,
|
| 18 |
)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
subject_image = Image.open(result[0]) # Result is a PNG with transparent background
|
| 23 |
|
| 24 |
if depth_map_path:
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
| 6 |
import open3d as o3d
|
| 7 |
+
from gradio_client import Client
|
| 8 |
from pathlib import Path
|
| 9 |
import os
|
| 10 |
|
| 11 |
feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
|
| 12 |
+
client = Client("not-lain/background-removal")
|
| 13 |
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
|
| 14 |
def process_image(image_path, depth_map_path=None):
|
| 15 |
image_path = Path(image_path)
|
|
|
|
| 19 |
Image.Resampling.LANCZOS,
|
| 20 |
)
|
| 21 |
|
| 22 |
+
# Open the image file and pass it directly to the client
|
| 23 |
+
with open(image_path, 'rb') as image_file:
|
| 24 |
+
result = client.predict(f=image_file, api_name="/png")
|
| 25 |
+
|
| 26 |
subject_image = Image.open(result[0]) # Result is a PNG with transparent background
|
| 27 |
|
| 28 |
if depth_map_path:
|