8
8
from diffusers import StableDiffusionInpaintPipeline
9
9
from groundingdino .util .inference import load_model , load_image , predict , annotate
10
10
from GroundingDINO .groundingdino .util import box_ops
11
-
11
+ import argparse
12
12
13
13
device = "cuda"
14
14
@@ -82,17 +82,19 @@ def edit_image(path, item, prompt, box_threshold, text_threshold):
82
82
83
83
def main ():
84
84
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 ()
90
93
91
- Prompt = "red car"
92
94
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 )
94
96
95
- save_image (edited_image ,"edited_car.jpg" )
97
+ save_image (edited_image ,args . out_path )
96
98
97
99
if __name__ == "__main__" :
98
100
main ()
0 commit comments