MCPcopy Create free account
hub / github.com/chenfei-wu/TaskMatrix / get_imagine_caption

Method get_imagine_caption

visual_chatgpt.py:1216–1231  ·  view source on GitHub ↗
(self, image, imagine)

Source from the content-addressed store, hash-verified

1214 return self.llm(check)
1215
1216 def get_imagine_caption(self, image, imagine):
1217 BLIP_caption = self.get_BLIP_caption(image)
1218 background_color = self.get_BLIP_vqa(image, 'what is the background color of this image')
1219 style = self.get_BLIP_vqa(image, 'what is the style of this image')
1220 imagine_prompt = f"let's pretend you are an excellent painter and now " \
1221 f"there is an incomplete painting with {BLIP_caption} in the center, " \
1222 f"please imagine the complete painting and describe it" \
1223 f"you should consider the background color is {background_color}, the style is {style}" \
1224 f"You should make the painting as vivid and realistic as possible" \
1225 f"You can not use words like painting or picture" \
1226 f"and you should use no more than 50 words to describe it"
1227 caption = self.llm(imagine_prompt) if imagine else BLIP_caption
1228 caption = self.check_prompt(caption)
1229 print(f'BLIP observation: {BLIP_caption}, ChatGPT imagine to {caption}') if imagine else print(
1230 f'Prompt: {caption}')
1231 return caption
1232
1233 def resize_image(self, image, max_size=1000000, multiple=8):
1234 aspect_ratio = image.size[0] / image.size[1]

Callers 1

dowhileMethod · 0.95

Calls 3

get_BLIP_captionMethod · 0.95
get_BLIP_vqaMethod · 0.95
check_promptMethod · 0.95

Tested by

no test coverage detected