Samarth991 commited on
Commit
c850a01
·
1 Parent(s): 428e149

added image detection code to display predicted bboxes

Browse files
Files changed (3) hide show
  1. QA_bot.py +1 -1
  2. extract_tools.py +3 -2
  3. tool_utils/yolo_world.py +2 -2
QA_bot.py CHANGED
@@ -44,7 +44,7 @@ def tyre_synap_bot(filter_agent,image_file_path):
44
  with st.chat_message("assistant"):
45
  message_placeholder = st.empty()
46
  full_response = ""
47
- if 'mask' in ai_response['output']:
48
  display_mask_image('final_mask.png')
49
 
50
  for chunk in re.split(r'(\s+)', response):
 
44
  with st.chat_message("assistant"):
45
  message_placeholder = st.empty()
46
  full_response = ""
47
+ if 'mask' in ai_response['output'] or 'predicted_image' in ai_response['output']:
48
  display_mask_image('final_mask.png')
49
 
50
  for chunk in re.split(r'(\s+)', response):
extract_tools.py CHANGED
@@ -44,7 +44,7 @@ def get_groq_model(model_name = "gemma2-9b-it"):
44
  def panoptic_image_segemntation(image_path:str)->str:
45
  """
46
  The tool is used to create a Panoptic segmentation mask . It uses Maskformer network to create a panoptic segmentation of all \
47
- the objects present in the image . Use the tool in case user ask to create a panoptic segmentation.
48
  """
49
  if image_path.startswith('https'):
50
  image = Image.open(requests.get(image_path, stream=True).raw).convert('RGB')
@@ -240,7 +240,8 @@ def get_all_tools():
240
  func = panoptic_image_segemntation,
241
  description = "The tool is used to create a Panoptic segmentation mask . It uses Maskformer network to create a panoptic segmentation of all \
242
  the objects present in the image . Use the tool in case user ask to create a panoptic segmentation or count objects in the image.\
243
- The tool also provides a list of objects along with the mask image of the all segmented objects found in the image ."
 
244
  )
245
 
246
  tools = [
 
44
  def panoptic_image_segemntation(image_path:str)->str:
45
  """
46
  The tool is used to create a Panoptic segmentation mask . It uses Maskformer network to create a panoptic segmentation of all \
47
+ the objects present in the image . Use the tool in case user ask to create a panoptic image segmentation or panoptic mask .
48
  """
49
  if image_path.startswith('https'):
50
  image = Image.open(requests.get(image_path, stream=True).raw).convert('RGB')
 
240
  func = panoptic_image_segemntation,
241
  description = "The tool is used to create a Panoptic segmentation mask . It uses Maskformer network to create a panoptic segmentation of all \
242
  the objects present in the image . Use the tool in case user ask to create a panoptic segmentation or count objects in the image.\
243
+ The tool also provides a list of objects along with the mask image of the all segmented objects found in the image .\
244
+ Us the tool if user ask to create a panoptic image segmentation or panoptic mask"
245
  )
246
 
247
  tools = [
tool_utils/yolo_world.py CHANGED
@@ -78,6 +78,6 @@ class YoloWorld:
78
  boxes=processed_predictions[0]['boxes'],
79
  labels=processed_predictions[0]['labels']
80
  )
81
- cv2.imwrite('final_mask.jpg',detected_image)
82
- return "Predicted image : final_mask.jpg . Details :{}".format(processed_predictions[0])
83
 
 
78
  boxes=processed_predictions[0]['boxes'],
79
  labels=processed_predictions[0]['labels']
80
  )
81
+ cv2.imwrite('final_mask.png',detected_image)
82
+ return "Predicted image mask : final_mask.jpg . Details :{}".format(processed_predictions[0])
83