Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
86d8605
1
Parent(s):
d742a71
Added product text box
Browse files
app.py
CHANGED
@@ -219,11 +219,11 @@ def draw_box(box: torch.Tensor, draw: ImageDraw.Draw, label: Optional[str]) -> N
|
|
219 |
draw.text((box[0], box[1]), str(label), fill="white")
|
220 |
|
221 |
|
222 |
-
def run_grounded_sam(input_image):
|
223 |
"""Main function to run GroundingDINO and SAM-HQ"""
|
224 |
# Create output directory
|
225 |
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
226 |
-
text_prompt =
|
227 |
task_type = 'text'
|
228 |
box_threshold = 0.3
|
229 |
text_threshold = 0.25
|
@@ -533,7 +533,7 @@ def generate_ai_bg(input_img, prompt):
|
|
533 |
|
534 |
return relight_img
|
535 |
|
536 |
-
def blend_details(input_image, relit_image, masked_image, scaling_factor=1):
|
537 |
|
538 |
# input_image = resize_image(input_image)
|
539 |
|
@@ -616,9 +616,9 @@ def generate_image(input_image_path, prompt):
|
|
616 |
|
617 |
ai_gen_image = generate_ai_bg(resized_input_img, prompt)
|
618 |
|
619 |
-
mask_input_image = run_grounded_sam(resized_input_img)
|
620 |
|
621 |
-
final_image = blend_details(resized_input_img, ai_gen_image, mask_input_image)
|
622 |
|
623 |
return final_image
|
624 |
|
@@ -632,7 +632,7 @@ def create_ui():
|
|
632 |
with gr.Row():
|
633 |
with gr.Column():
|
634 |
input_image_path = gr.Image(type="filepath", label="image")
|
635 |
-
|
636 |
prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
637 |
run_button = gr.Button(value='Run')
|
638 |
|
@@ -644,7 +644,7 @@ def create_ui():
|
|
644 |
fn=generate_image,
|
645 |
inputs=[
|
646 |
input_image_path,
|
647 |
-
|
648 |
prompt
|
649 |
],
|
650 |
outputs=[output_image]
|
|
|
219 |
draw.text((box[0], box[1]), str(label), fill="white")
|
220 |
|
221 |
|
222 |
+
def run_grounded_sam(input_image, product):
|
223 |
"""Main function to run GroundingDINO and SAM-HQ"""
|
224 |
# Create output directory
|
225 |
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
226 |
+
text_prompt = product
|
227 |
task_type = 'text'
|
228 |
box_threshold = 0.3
|
229 |
text_threshold = 0.25
|
|
|
533 |
|
534 |
return relight_img
|
535 |
|
536 |
+
def blend_details(input_image, relit_image, masked_image, product, scaling_factor=1):
|
537 |
|
538 |
# input_image = resize_image(input_image)
|
539 |
|
|
|
616 |
|
617 |
ai_gen_image = generate_ai_bg(resized_input_img, prompt)
|
618 |
|
619 |
+
mask_input_image = run_grounded_sam(resized_input_img, product)
|
620 |
|
621 |
+
final_image = blend_details(resized_input_img, ai_gen_image, mask_input_image, product)
|
622 |
|
623 |
return final_image
|
624 |
|
|
|
632 |
with gr.Row():
|
633 |
with gr.Column():
|
634 |
input_image_path = gr.Image(type="filepath", label="image")
|
635 |
+
product = gr.Textbox(label="Product", placeholder="Enter what your product is here...")
|
636 |
prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
|
637 |
run_button = gr.Button(value='Run')
|
638 |
|
|
|
644 |
fn=generate_image,
|
645 |
inputs=[
|
646 |
input_image_path,
|
647 |
+
product,
|
648 |
prompt
|
649 |
],
|
650 |
outputs=[output_image]
|