SkalskiP commited on
Commit
2740889
1 Parent(s): 7e50af9

Refactor import statements and handle history edge case

Browse files

Reordered import statements in 'app.py' for better code readability and conformance to PEP8 style guide.

Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -9,8 +9,8 @@ import torch
9
  from segment_anything import sam_model_registry
10
 
11
  from gpt4v import prompt_image
12
- from utils import postprocess_masks, Visualizer, extract_numbers_in_brackets
13
  from sam_utils import sam_interactive_inference, sam_inference
 
14
 
15
  HOME = os.getenv("HOME")
16
  DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
@@ -111,6 +111,9 @@ def highlight(
111
  detections: sv.Detections = state[DETECTIONS_KEY]
112
  annotated_image: np.ndarray = state[ANNOTATED_IMAGE_KEY]
113
 
 
 
 
114
  response = history[-1][-1]
115
  detections_ids = extract_numbers_in_brackets(text=response)
116
  highlighted_detections = [
 
9
  from segment_anything import sam_model_registry
10
 
11
  from gpt4v import prompt_image
 
12
  from sam_utils import sam_interactive_inference, sam_inference
13
+ from utils import postprocess_masks, Visualizer, extract_numbers_in_brackets
14
 
15
  HOME = os.getenv("HOME")
16
  DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
 
111
  detections: sv.Detections = state[DETECTIONS_KEY]
112
  annotated_image: np.ndarray = state[ANNOTATED_IMAGE_KEY]
113
 
114
+ if len(history) == 0:
115
+ return None
116
+
117
  response = history[-1][-1]
118
  detections_ids = extract_numbers_in_brackets(text=response)
119
  highlighted_detections = [