Skip to content

Commit ebb807e

Browse files
committed
main.py updated
1 parent c33dcea commit ebb807e

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

main.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from diffusers import StableDiffusionInpaintPipeline
99
from groundingdino.util.inference import load_model, load_image, predict, annotate
1010
from GroundingDINO.groundingdino.util import box_ops
11-
11+
import argparse
1212

1313
device = "cuda"
1414

@@ -82,17 +82,19 @@ def edit_image(path, item, prompt, box_threshold, text_threshold):
8282

8383
def main():
8484

85-
img_path = "./car_img.jpg"
86-
87-
Selected_Object = "black taxi"
88-
BOX_THRESHOLD = 0.3
89-
TEXT_THRESHOLD = 0.25
85+
parser = argparse.ArgumentParser(description="Text-Based Image Editor")
86+
parser.add_argument("--img_path", type=str, help="Path to the input image")
87+
parser.add_argument("--selected_object", type=str, help="Object to be recognized in the image")
88+
parser.add_argument("--prompt", type=str, help="Text prompt for image editing")
89+
parser.add_argument("--box_threshold", type=float, default=0.3, help="Threshold for bounding box predictions")
90+
parser.add_argument("--text_threshold", type=float, default=0.25, help="Threshold for text predictions")
91+
parser.add_argument("--out_path", type=str, help="Path to save output")
92+
args = parser.parse_args()
9093

91-
Prompt = "red car"
9294

93-
edited_image = edit_image(img_path,Selected_Object,Prompt,BOX_THRESHOLD,TEXT_THRESHOLD)
95+
edited_image = edit_image(args.img_path,args.selected_object,args.prompt,args.box_threshold,args.text_threshold)
9496

95-
save_image(edited_image,"edited_car.jpg")
97+
save_image(edited_image,args.out_path)
9698

9799
if __name__ == "__main__":
98100
main()

0 commit comments

Comments
 (0)