Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -60,23 +60,14 @@ def resize_image_dimensions(
|
|
60 |
|
61 |
|
62 |
def evf_sam_mask(image, prompt):
|
63 |
-
print(
|
64 |
-
filename=str(uuid.uuid4()) + ".jpg"
|
65 |
-
image.save(filename)
|
66 |
images = client.predict(
|
67 |
-
image_np=handle_file(
|
68 |
prompt=prompt,
|
69 |
api_name="/predict")
|
70 |
print(images)
|
71 |
-
# Open the image
|
72 |
-
|
73 |
-
# Convert to RGB mode if it's not already
|
74 |
-
if webp_image.mode != 'RGB':
|
75 |
-
webp_image = webp_image.convert('RGB')
|
76 |
-
# Create a new PIL Image object
|
77 |
-
pil_image = Image.new('RGB', webp_image.size)
|
78 |
-
pil_image.paste(webp_image)
|
79 |
-
|
80 |
print(pil_image)
|
81 |
print(type(pil_image))
|
82 |
|
@@ -138,28 +129,26 @@ with gr.Blocks() as demo:
|
|
138 |
gr.Markdown(MARKDOWN)
|
139 |
with gr.Row():
|
140 |
with gr.Column():
|
141 |
-
input_image = gr.
|
142 |
label='Image',
|
143 |
-
type='
|
144 |
-
sources=["upload", "webcam"],
|
145 |
image_mode='RGB',
|
146 |
-
|
147 |
-
brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed"))
|
148 |
-
|
149 |
with gr.Row():
|
150 |
with gr.Column():
|
151 |
input_text_component = gr.Text(
|
152 |
-
label="
|
153 |
-
show_label=
|
154 |
max_lines=1,
|
155 |
-
placeholder="segmentation
|
156 |
container=False,
|
157 |
)
|
158 |
inpaint_text_component = gr.Text(
|
159 |
-
label="
|
160 |
-
show_label=
|
161 |
max_lines=1,
|
162 |
-
placeholder="
|
163 |
container=False,
|
164 |
)
|
165 |
submit_button_component = gr.Button(value='Submit', variant='primary', scale=0)
|
|
|
60 |
|
61 |
|
62 |
def evf_sam_mask(image, prompt):
|
63 |
+
print(image)
|
|
|
|
|
64 |
images = client.predict(
|
65 |
+
image_np=handle_file(image),
|
66 |
prompt=prompt,
|
67 |
api_name="/predict")
|
68 |
print(images)
|
69 |
+
# Open the mask image
|
70 |
+
pil_image = Image.open(images[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
print(pil_image)
|
72 |
print(type(pil_image))
|
73 |
|
|
|
129 |
gr.Markdown(MARKDOWN)
|
130 |
with gr.Row():
|
131 |
with gr.Column():
|
132 |
+
input_image = gr.Image(
|
133 |
label='Image',
|
134 |
+
type='filepath',
|
135 |
+
sources=["upload", "webcam", "clipboard"],
|
136 |
image_mode='RGB',
|
137 |
+
)
|
|
|
|
|
138 |
with gr.Row():
|
139 |
with gr.Column():
|
140 |
input_text_component = gr.Text(
|
141 |
+
label="Text-guided segmentation",
|
142 |
+
show_label=True,
|
143 |
max_lines=1,
|
144 |
+
placeholder="Enter text for generating the segmentation mask",
|
145 |
container=False,
|
146 |
)
|
147 |
inpaint_text_component = gr.Text(
|
148 |
+
label="Text-guided Inpainting",
|
149 |
+
show_label=True,
|
150 |
max_lines=1,
|
151 |
+
placeholder="Enter text to generate Inpainting",
|
152 |
container=False,
|
153 |
)
|
154 |
submit_button_component = gr.Button(value='Submit', variant='primary', scale=0)
|