Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ander1119/viper into main
Browse files Browse the repository at this point in the history
  • Loading branch information
adnchao1 committed May 19, 2024
2 parents ef5f678 + f68a335 commit 9fa8340
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cached_code/v+d_df_gpt4_simple/v1.csv
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def execute_command(video, annotation, possible_answers, query):
big_bad_candidate = character_id

# If a candidate is found and their negative impacts are significant, answer 'yes'
if big_bad_candidate and max_negative_impacts > len(video_segment.frame_iterator()) * 0.5: # Arbitrary threshold: more than 50% of frames
if big_bad_candidate and max_negative_impacts > len(video_segment) * 0.5: # Arbitrary threshold: more than 50% of frames
answer = ""yes""
reason = f""The character {big_bad_candidate} caused negative impacts in more than 50% of the frames.""
else:
Expand Down
24 changes: 14 additions & 10 deletions vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def forward(self, image, prompt, task='score', return_index=True, negative_categ
class MaskRCNNModel(BaseModel):
name = 'maskrcnn'

def __init__(self, gpu_number=1, threshold=config.detect_thresholds.maskrcnn):
def __init__(self, gpu_number=0, threshold=config.detect_thresholds.maskrcnn):
super().__init__(gpu_number)
# with HiddenPrints('MaskRCNN'):
obj_detect = torchvision.models.detection.maskrcnn_resnet50_fpn_v2(weights='COCO_V1').to(self.dev)
Expand Down Expand Up @@ -429,7 +429,7 @@ def forward(self, image: torch.Tensor, text: List[str], return_labels: bool = Fa
class GLIPModel(BaseModel):
name = 'glip'

def __init__(self, model_size='large', gpu_number=1, *args):
def __init__(self, model_size='large', gpu_number=0, *args):
BaseModel.__init__(self, gpu_number)

with contextlib.redirect_stderr(open(os.devnull, "w")): # Do not print nltk_data messages when importing
Expand Down Expand Up @@ -910,13 +910,17 @@ def get_summarization(self, prompts) -> list[dict]:
"content": prompt
}
]
response = openai.ChatCompletion.create(
model=self.model,
messages=message,
# response_format={"type": "json_object"},
temperature=self.temperature,
)
responses.append(response.choices[0].message.content)
try:
response = openai.ChatCompletion.create(
model=self.model,
messages=message,
# response_format={"type": "json_object"},
temperature=self.temperature,
)
responses.append(response.choices[0].message.content)
except:
responses.append("")

return responses

def query_gpt3(self, prompt, model="text-davinci-003", max_tokens=16, logprobs=None, stream=False,
Expand Down Expand Up @@ -1394,7 +1398,7 @@ class BLIPModel(BaseModel):
max_batch_size = 32
seconds_collect_data = 0.2 # The queue has additionally the time it is executing the previous forward pass

def __init__(self, gpu_number=1, half_precision=config.blip_half_precision,
def __init__(self, gpu_number=0, half_precision=config.blip_half_precision,
blip_v2_model_type=config.blip_v2_model_type):
super().__init__(gpu_number)

Expand Down

0 comments on commit 9fa8340

Please sign in to comment.