Spaces:
Sleeping
Sleeping
Update app_3.py
Browse files
app_3.py
CHANGED
@@ -150,7 +150,7 @@ vae = AutoencoderKL.from_pretrained(sd15_name, subfolder="vae")
|
|
150 |
unet = UNet2DConditionModel.from_pretrained(sd15_name, subfolder="unet")
|
151 |
# Load model directly
|
152 |
from transformers import AutoModelForImageSegmentation
|
153 |
-
rmbg = AutoModelForImageSegmentation.from_pretrained("briaai/RMBG-
|
154 |
rmbg = rmbg.to(device=device, dtype=torch.float32) # Keep this as float32
|
155 |
|
156 |
# remove bg
|
@@ -1028,17 +1028,17 @@ def process_image(input_image, input_text):
|
|
1028 |
rgba = np.dstack((img, alpha)).astype(np.uint8)
|
1029 |
|
1030 |
# Crop to mask bounds to minimize image size
|
1031 |
-
y_indices, x_indices = np.where(first_mask)
|
1032 |
-
y_min, y_max = y_indices.min(), y_indices.max()
|
1033 |
-
x_min, x_max = x_indices.min(), x_indices.max()
|
1034 |
|
1035 |
# Crop the RGBA image
|
1036 |
-
cropped_rgba = rgba[y_min:y_max+1, x_min:x_max+1]
|
1037 |
|
1038 |
# Set extracted foreground for mask mover
|
1039 |
# mask_mover.set_extracted_fg(cropped_rgba)
|
1040 |
|
1041 |
-
return annotated_frame,
|
1042 |
|
1043 |
|
1044 |
else:
|
|
|
150 |
unet = UNet2DConditionModel.from_pretrained(sd15_name, subfolder="unet")
|
151 |
# Load model directly
|
152 |
from transformers import AutoModelForImageSegmentation
|
153 |
+
rmbg = AutoModelForImageSegmentation.from_pretrained("briaai/BRIA-RMBG-2.0", trust_remote_code=True)
|
154 |
rmbg = rmbg.to(device=device, dtype=torch.float32) # Keep this as float32
|
155 |
|
156 |
# remove bg
|
|
|
1028 |
rgba = np.dstack((img, alpha)).astype(np.uint8)
|
1029 |
|
1030 |
# Crop to mask bounds to minimize image size
|
1031 |
+
# y_indices, x_indices = np.where(first_mask)
|
1032 |
+
# y_min, y_max = y_indices.min(), y_indices.max()
|
1033 |
+
# x_min, x_max = x_indices.min(), x_indices.max()
|
1034 |
|
1035 |
# Crop the RGBA image
|
1036 |
+
#cropped_rgba = rgba[y_min:y_max+1, x_min:x_max+1]
|
1037 |
|
1038 |
# Set extracted foreground for mask mover
|
1039 |
# mask_mover.set_extracted_fg(cropped_rgba)
|
1040 |
|
1041 |
+
return annotated_frame, rgba, gr.update(visible=False), gr.update(visible=False)
|
1042 |
|
1043 |
|
1044 |
else:
|