codic commited on
Commit
d9230e8
·
verified ·
1 Parent(s): c53c092

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
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 (using the new ImageProcessor)
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
- # Handle background removal via Gradio Client
28
  with open(image_path, 'rb') as image_file:
29
- image_data = base64.b64encode(image_file.read()).decode('utf-8')
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: