Spaces:
Runtime error
Runtime error
fix
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import subprocess
|
|
|
2 |
|
3 |
def download_file(url, output_filename):
|
4 |
command = ['wget', '-O', output_filename, '-q', url]
|
@@ -94,13 +95,12 @@ def remove_background(image_path, mask):
|
|
94 |
|
95 |
return result
|
96 |
|
97 |
-
pipe = FluxInpaintPipeline.from_pretrained(bfl_repo, torch_dtype=torch.bfloat16)
|
98 |
MAX_SEED = np.iinfo(np.int32).max
|
99 |
TRIGGER = "a photo of TOK"
|
100 |
|
101 |
@spaces.GPU(duration=200)
|
102 |
def execute(image, prompt):
|
103 |
-
pipe.to(DEVICE)
|
104 |
if not prompt :
|
105 |
gr.Info("Please enter a text prompt.")
|
106 |
return None
|
@@ -123,10 +123,14 @@ def execute(image, prompt):
|
|
123 |
for image in range(len(imgs)):
|
124 |
current_img = imgs[image]
|
125 |
cv2.imwrite('base_image.jpg', current_img)
|
126 |
-
mask
|
|
|
|
|
|
|
|
|
127 |
result = pipe(
|
128 |
prompt=f"{prompt} {TRIGGER}",
|
129 |
-
image=
|
130 |
mask_image=mask,
|
131 |
width=1024,
|
132 |
height=1024,
|
|
|
1 |
import subprocess
|
2 |
+
from PIL import Image
|
3 |
|
4 |
def download_file(url, output_filename):
|
5 |
command = ['wget', '-O', output_filename, '-q', url]
|
|
|
95 |
|
96 |
return result
|
97 |
|
98 |
+
pipe = FluxInpaintPipeline.from_pretrained(bfl_repo, torch_dtype=torch.bfloat16).to(DEVICE)
|
99 |
MAX_SEED = np.iinfo(np.int32).max
|
100 |
TRIGGER = "a photo of TOK"
|
101 |
|
102 |
@spaces.GPU(duration=200)
|
103 |
def execute(image, prompt):
|
|
|
104 |
if not prompt :
|
105 |
gr.Info("Please enter a text prompt.")
|
106 |
return None
|
|
|
123 |
for image in range(len(imgs)):
|
124 |
current_img = imgs[image]
|
125 |
cv2.imwrite('base_image.jpg', current_img)
|
126 |
+
cv2.imwrite("mask.jpg", maskHead('base_image.jpg'))
|
127 |
+
|
128 |
+
im = Image.open('base_image.jpg')
|
129 |
+
mask = Image.open('mask.jpg')
|
130 |
+
|
131 |
result = pipe(
|
132 |
prompt=f"{prompt} {TRIGGER}",
|
133 |
+
image=im,
|
134 |
mask_image=mask,
|
135 |
width=1024,
|
136 |
height=1024,
|