Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -126,13 +126,13 @@ def get_florence_segmentation(image, task_prompt="<REFERRING_EXPRESSION_SEGMENTA
|
|
| 126 |
|
| 127 |
|
| 128 |
@spaces.GPU
|
| 129 |
-
def generate_segmt_img(image_path):
|
| 130 |
init_image = Image.open(image_path).convert("RGB")
|
| 131 |
#image_np = np.array(init_image)
|
| 132 |
|
| 133 |
conditioning_image = get_florence_segmentation(
|
| 134 |
init_image, task_prompt="<REFERRING_EXPRESSION_SEGMENTATION>",
|
| 135 |
-
text_input=
|
| 136 |
return conditioning_image
|
| 137 |
|
| 138 |
@spaces.GPU
|
|
@@ -178,7 +178,7 @@ def load_image(selected_file):
|
|
| 178 |
|
| 179 |
# generate input image
|
| 180 |
@spaces.GPU
|
| 181 |
-
def generate_input_image(image_path,input_choice):
|
| 182 |
print(f"image_path: '{image_path}'")
|
| 183 |
print(f"input_choice: '{input_choice}'")
|
| 184 |
image_path = image_path[0]
|
|
@@ -186,7 +186,7 @@ def generate_input_image(image_path,input_choice):
|
|
| 186 |
if input_choice == "Edge image" :
|
| 187 |
conditioning_image = generate_edgeImage(image_path)
|
| 188 |
elif input_choice == "Segmented image" :
|
| 189 |
-
conditioning_image = generate_segmt_img(image_path)
|
| 190 |
else:
|
| 191 |
conditioning_image = extract_depth_map(image_path)
|
| 192 |
return conditioning_image
|
|
@@ -249,6 +249,8 @@ with gr.Blocks() as demo:
|
|
| 249 |
file_count="multiple",
|
| 250 |
file_types=["image"]
|
| 251 |
)
|
|
|
|
|
|
|
| 252 |
with gr.Row():
|
| 253 |
image_dropdown = gr.Dropdown(
|
| 254 |
choices=["Edge image","Segmented image","Depth Image"] ,
|
|
@@ -283,7 +285,7 @@ with gr.Blocks() as demo:
|
|
| 283 |
#)
|
| 284 |
generate_inp_btn.click(
|
| 285 |
fn=generate_input_image,
|
| 286 |
-
inputs=[file_input,image_dropdown],
|
| 287 |
outputs=[input_preview]
|
| 288 |
)
|
| 289 |
generate_btn.click(
|
|
|
|
| 126 |
|
| 127 |
|
| 128 |
@spaces.GPU
|
| 129 |
+
def generate_segmt_img(image_path,generate_segmt_img):
|
| 130 |
init_image = Image.open(image_path).convert("RGB")
|
| 131 |
#image_np = np.array(init_image)
|
| 132 |
|
| 133 |
conditioning_image = get_florence_segmentation(
|
| 134 |
init_image, task_prompt="<REFERRING_EXPRESSION_SEGMENTATION>",
|
| 135 |
+
text_input=generate_segmt_img)
|
| 136 |
return conditioning_image
|
| 137 |
|
| 138 |
@spaces.GPU
|
|
|
|
| 178 |
|
| 179 |
# generate input image
|
| 180 |
@spaces.GPU
|
| 181 |
+
def generate_input_image(image_path,input_choice,seg_input_promt):
|
| 182 |
print(f"image_path: '{image_path}'")
|
| 183 |
print(f"input_choice: '{input_choice}'")
|
| 184 |
image_path = image_path[0]
|
|
|
|
| 186 |
if input_choice == "Edge image" :
|
| 187 |
conditioning_image = generate_edgeImage(image_path)
|
| 188 |
elif input_choice == "Segmented image" :
|
| 189 |
+
conditioning_image = generate_segmt_img(image_path,seg_input_promt)
|
| 190 |
else:
|
| 191 |
conditioning_image = extract_depth_map(image_path)
|
| 192 |
return conditioning_image
|
|
|
|
| 249 |
file_count="multiple",
|
| 250 |
file_types=["image"]
|
| 251 |
)
|
| 252 |
+
seg_input = gr.Textbox( label="segmentation Prompt",
|
| 253 |
+
placeholder="Describe modifications, styles, or Canny/Depth map directions...")
|
| 254 |
with gr.Row():
|
| 255 |
image_dropdown = gr.Dropdown(
|
| 256 |
choices=["Edge image","Segmented image","Depth Image"] ,
|
|
|
|
| 285 |
#)
|
| 286 |
generate_inp_btn.click(
|
| 287 |
fn=generate_input_image,
|
| 288 |
+
inputs=[file_input,image_dropdown,seg_input],
|
| 289 |
outputs=[input_preview]
|
| 290 |
)
|
| 291 |
generate_btn.click(
|