FengHou97 commited on
Commit
8313b51
·
verified ·
1 Parent(s): 605f57a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -70,7 +70,7 @@ def shot(image, labels_text, model_name, hypothesis_template_prefix, hypothesis_
70
  #img = Image.open(image)
71
  #input_text = "Please describe the image from six dimensions, including weather (clear, sandstorm, foggy, rainy, snowy), angle (front, left, top), time (daytime, night), occlusion (no occlusion, light occlusion, partial occlusion, moderate occlusion, heavy occlusion), season (spring-summer, autumn, winter). Each dimension should be described in no more than 4 words and should match the image content. Please try to output from the options in the previous brackets. If there is no suitable result, output N/A."# Please also output a probability of your inference."# If there is no information in a certain dimension, you can directly output no information.
72
  input_text = "You are an expert for domain knowledge analysis. Please describe the image from six domain shifts, including Weather (clear, sandstorm, foggy, rainy, snowy), Season (spring-summer, autumn, winter), Time (daytime, night), Angle (front, side, top) and Occlusion (no occlusion, light occlusion, partial occlusion, moderate occlusion, heavy occlusion). You are supposed to recognize each domain from the above domain shifts based on the image. Finally, you only need to output a list of domains like [clear, autumn, night, front, light occlusion]"
73
- domains = gemini_response_vision(input_texts=input_text, image=image)
74
  #IMAGE_PATH = './reasoning_xy.jpg'
75
  # base64_image = encode_image('car.png')
76
  # prompt = "Please describe the image from six dimensions, including weather (clear, sandstorm, foggy, rainy, snowy), angle (front, left, top), time (daytime, night), occlusion (no occlusion, light occlusion, partial occlusion, moderate occlusion, heavy occlusion), season (spring-summer, autumn, winter). Each dimension should be described in no more than 4 words and should match the image content. Please try to output from the options in the previous brackets. If there is no suitable result, output N/A."# Please also output a probability of your inference."# If there is no information in a certain dimension, you can directly output no information."
@@ -89,7 +89,9 @@ def shot(image, labels_text, model_name, hypothesis_template_prefix, hypothesis_
89
  # temperature=0.0,
90
  # )
91
  # domains = response.choices[0].message.content
92
- print(domains)
 
 
93
 
94
  hypothesis_template = hypothesis_template_prefix + ' ' + hypothesis_template_suffix.format(*domains)
95
  print(hypothesis_template)
 
70
  #img = Image.open(image)
71
  #input_text = "Please describe the image from six dimensions, including weather (clear, sandstorm, foggy, rainy, snowy), angle (front, left, top), time (daytime, night), occlusion (no occlusion, light occlusion, partial occlusion, moderate occlusion, heavy occlusion), season (spring-summer, autumn, winter). Each dimension should be described in no more than 4 words and should match the image content. Please try to output from the options in the previous brackets. If there is no suitable result, output N/A."# Please also output a probability of your inference."# If there is no information in a certain dimension, you can directly output no information.
72
  input_text = "You are an expert for domain knowledge analysis. Please describe the image from six domain shifts, including Weather (clear, sandstorm, foggy, rainy, snowy), Season (spring-summer, autumn, winter), Time (daytime, night), Angle (front, side, top) and Occlusion (no occlusion, light occlusion, partial occlusion, moderate occlusion, heavy occlusion). You are supposed to recognize each domain from the above domain shifts based on the image. Finally, you only need to output a list of domains like [clear, autumn, night, front, light occlusion]"
73
+ ans = gemini_response_vision(input_texts=input_text, image=image)
74
  #IMAGE_PATH = './reasoning_xy.jpg'
75
  # base64_image = encode_image('car.png')
76
  # prompt = "Please describe the image from six dimensions, including weather (clear, sandstorm, foggy, rainy, snowy), angle (front, left, top), time (daytime, night), occlusion (no occlusion, light occlusion, partial occlusion, moderate occlusion, heavy occlusion), season (spring-summer, autumn, winter). Each dimension should be described in no more than 4 words and should match the image content. Please try to output from the options in the previous brackets. If there is no suitable result, output N/A."# Please also output a probability of your inference."# If there is no information in a certain dimension, you can directly output no information."
 
89
  # temperature=0.0,
90
  # )
91
  # domains = response.choices[0].message.content
92
+ print(ans)
93
+ domains = [domain.strip(" ") for domain in ans.strip("[").strip("]").split(",")]
94
+
95
 
96
  hypothesis_template = hypothesis_template_prefix + ' ' + hypothesis_template_suffix.format(*domains)
97
  print(hypothesis_template)