Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ import gradio as gr
|
|
| 12 |
# Initialize Gradio client for background removal
|
| 13 |
client = Client("not-lain/background-removal")
|
| 14 |
|
| 15 |
-
# Initialize DPT depth estimation model
|
| 16 |
feature_extractor = DPTImageProcessor.from_pretrained("Intel/dpt-large")
|
| 17 |
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
|
| 18 |
|
|
@@ -24,11 +24,10 @@ def process_image(image_path, depth_map_path=None):
|
|
| 24 |
Image.Resampling.LANCZOS,
|
| 25 |
)
|
| 26 |
|
| 27 |
-
#
|
| 28 |
with open(image_path, 'rb') as image_file:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
result = client.predict(f"data:image/png;base64,{image_data}", api_name="/png")
|
| 32 |
subject_image = Image.open(result[0]) # Processed PNG with transparent background
|
| 33 |
|
| 34 |
if depth_map_path:
|
|
|
|
| 12 |
# Initialize Gradio client for background removal
|
| 13 |
client = Client("not-lain/background-removal")
|
| 14 |
|
| 15 |
+
# Initialize DPT depth estimation model
|
| 16 |
feature_extractor = DPTImageProcessor.from_pretrained("Intel/dpt-large")
|
| 17 |
model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
|
| 18 |
|
|
|
|
| 24 |
Image.Resampling.LANCZOS,
|
| 25 |
)
|
| 26 |
|
| 27 |
+
# Send image as a file directly to the Gradio Client for background removal
|
| 28 |
with open(image_path, 'rb') as image_file:
|
| 29 |
+
result = client.predict(image_file, api_name="/png")
|
| 30 |
+
|
|
|
|
| 31 |
subject_image = Image.open(result[0]) # Processed PNG with transparent background
|
| 32 |
|
| 33 |
if depth_map_path:
|