Spaces:
Running
Running
Niki Zhang
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -729,9 +729,9 @@ recommendation_prompt=[
|
|
729 |
'''
|
730 |
When generating answers, you should tell people that I am the creator of painting you were looking at earlier itself, and generate text in the tone and manner in which you are the creator of painting were looking at earlier.
|
731 |
|
732 |
-
First identify what the creator of the first painting is, you save yourself as the parameter: {
|
733 |
|
734 |
-
Recommendation reason: {{I'm the creator of that painting you saw earlier, {
|
735 |
|
736 |
Each bullet point should be in {language} language, with a response length of about {length} words.
|
737 |
|
@@ -1022,14 +1022,14 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
|
|
1022 |
name ="The Ambassadors"
|
1023 |
artist ="Hans Holbein the Younger"
|
1024 |
year = "1533 (Northern Renaissance)"
|
1025 |
-
material=
|
1026 |
gender = "male"
|
1027 |
|
1028 |
elif task_type=="task 2":
|
1029 |
name = "The Football Players"
|
1030 |
artist= "Albert Gleizes"
|
1031 |
year= "1912 (Cubism)"
|
1032 |
-
material=
|
1033 |
gender= "male"
|
1034 |
else:
|
1035 |
parsed_data = get_gpt_response(openai_api_key, new_image_path,"Please provide the name, artist, year of creation (including the art historical period), and painting style used for this painting. Return the information in dictionary format without any newline characters. Format as follows: { \"name\": \"Name of the painting\", \"artist\": \"Name of the artist\", \"year\": \"Year of creation (Art historical period)\", \"style\": \"Painting style used in the painting\",\"gender\": \"The gender of the author\"}")
|
@@ -1038,6 +1038,7 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
|
|
1038 |
name, artist, year, material,gender= parsed_data["name"],parsed_data["artist"],parsed_data["year"], parsed_data["style"],parsed_data['gender']
|
1039 |
gender=gender.lower()
|
1040 |
print("gender",gender)
|
|
|
1041 |
|
1042 |
|
1043 |
|
@@ -1195,7 +1196,7 @@ async def submit_caption(naritive, state,length, sentiment, factuality, language
|
|
1195 |
# if not args.disable_gpt and text_refiner:
|
1196 |
if not args.disable_gpt:
|
1197 |
print("new crop save",new_crop_save_path)
|
1198 |
-
focus_info=get_gpt_response(openai_api_key,new_crop_save_path,prompt
|
1199 |
if focus_info.startswith('"') and focus_info.endswith('"'):
|
1200 |
focus_info=focus_info[1:-1]
|
1201 |
focus_info=focus_info.replace('#', '')
|
@@ -1712,6 +1713,7 @@ async def item_associate(new_crop,openai_api_key,language,autoplay,length,log_st
|
|
1712 |
rec_path=evt._data['value']['image']['path']
|
1713 |
index="Item Recommendation Picture "+ str(evt.index)
|
1714 |
print("rec_path",rec_path)
|
|
|
1715 |
prompt=recommendation_prompt[0][persona].format(language=language,length=length)
|
1716 |
|
1717 |
image_paths=[new_crop,rec_path]
|
@@ -1732,12 +1734,15 @@ async def item_associate(new_crop,openai_api_key,language,autoplay,length,log_st
|
|
1732 |
return state,state,audio_output,log_state,index,gr.update(value=[])
|
1733 |
|
1734 |
|
1735 |
-
async def style_associate(image_path,openai_api_key,language,autoplay,length,log_state,sort_score,narritive,state,evt: gr.SelectData):
|
1736 |
persona=naritive_mapping[narritive]
|
1737 |
rec_path=evt._data['value']['image']['path']
|
1738 |
index="Style Recommendation Picture "+str(evt.index)
|
1739 |
print("rec_path",rec_path)
|
1740 |
-
|
|
|
|
|
|
|
1741 |
image_paths=[image_path,rec_path]
|
1742 |
result=get_gpt_response(openai_api_key, image_paths, prompt )
|
1743 |
print("recommend result",result)
|
@@ -2324,7 +2329,7 @@ def create_ui():
|
|
2324 |
|
2325 |
style_gallery_result.select(
|
2326 |
style_associate,
|
2327 |
-
inputs=[image_path,openai_api_key,language,auto_play,length,log_state,sort_rec,naritive,recomended_state],
|
2328 |
outputs=[recommend_bot,recomended_state,output_audio,log_state,pic_index,recommend_score],
|
2329 |
|
2330 |
|
|
|
729 |
'''
|
730 |
When generating answers, you should tell people that I am the creator of painting you were looking at earlier itself, and generate text in the tone and manner in which you are the creator of painting were looking at earlier.
|
731 |
|
732 |
+
First identify what the creator of the first painting is, you save yourself as the parameter: {artist}, do not need to tell me, the following will use the parameter. I want you to write the recommendation reason according to the following content, as a markdown outline with appropriate emojis that describe what you see according to the painting:
|
733 |
|
734 |
+
Recommendation reason: {{I'm the creator of that painting you saw earlier, {artist}. I'm an artist. and I'm recommending this painting based on the fact that the painting you're looking at is similar to the one you just saw of me.}} Detailed analysis: Based on the recommendation reason and the relationship between the two paintings, explain why you recommend another painting. Please generate the three points in the tone and manner as if you are the creator of painting were looking at earlier and start every sentence with I.
|
735 |
|
736 |
Each bullet point should be in {language} language, with a response length of about {length} words.
|
737 |
|
|
|
1022 |
name ="The Ambassadors"
|
1023 |
artist ="Hans Holbein the Younger"
|
1024 |
year = "1533 (Northern Renaissance)"
|
1025 |
+
material="Realism"
|
1026 |
gender = "male"
|
1027 |
|
1028 |
elif task_type=="task 2":
|
1029 |
name = "The Football Players"
|
1030 |
artist= "Albert Gleizes"
|
1031 |
year= "1912 (Cubism)"
|
1032 |
+
material="Cubism"
|
1033 |
gender= "male"
|
1034 |
else:
|
1035 |
parsed_data = get_gpt_response(openai_api_key, new_image_path,"Please provide the name, artist, year of creation (including the art historical period), and painting style used for this painting. Return the information in dictionary format without any newline characters. Format as follows: { \"name\": \"Name of the painting\", \"artist\": \"Name of the artist\", \"year\": \"Year of creation (Art historical period)\", \"style\": \"Painting style used in the painting\",\"gender\": \"The gender of the author\"}")
|
|
|
1038 |
name, artist, year, material,gender= parsed_data["name"],parsed_data["artist"],parsed_data["year"], parsed_data["style"],parsed_data['gender']
|
1039 |
gender=gender.lower()
|
1040 |
print("gender",gender)
|
1041 |
+
print("material",material)
|
1042 |
|
1043 |
|
1044 |
|
|
|
1196 |
# if not args.disable_gpt and text_refiner:
|
1197 |
if not args.disable_gpt:
|
1198 |
print("new crop save",new_crop_save_path)
|
1199 |
+
focus_info=get_gpt_response(openai_api_key,new_crop_save_path,prompt)
|
1200 |
if focus_info.startswith('"') and focus_info.endswith('"'):
|
1201 |
focus_info=focus_info[1:-1]
|
1202 |
focus_info=focus_info.replace('#', '')
|
|
|
1713 |
rec_path=evt._data['value']['image']['path']
|
1714 |
index="Item Recommendation Picture "+ str(evt.index)
|
1715 |
print("rec_path",rec_path)
|
1716 |
+
|
1717 |
prompt=recommendation_prompt[0][persona].format(language=language,length=length)
|
1718 |
|
1719 |
image_paths=[new_crop,rec_path]
|
|
|
1734 |
return state,state,audio_output,log_state,index,gr.update(value=[])
|
1735 |
|
1736 |
|
1737 |
+
async def style_associate(image_path,openai_api_key,language,autoplay,length,log_state,sort_score,narritive,state,artist,evt: gr.SelectData):
|
1738 |
persona=naritive_mapping[narritive]
|
1739 |
rec_path=evt._data['value']['image']['path']
|
1740 |
index="Style Recommendation Picture "+str(evt.index)
|
1741 |
print("rec_path",rec_path)
|
1742 |
+
if persona==1:
|
1743 |
+
prompt=recommendation_prompt[1][persona].format(language=language,length=length,artist=artist[8:])
|
1744 |
+
else:
|
1745 |
+
prompt=recommendation_prompt[1][persona].format(language=language,length=length)
|
1746 |
image_paths=[image_path,rec_path]
|
1747 |
result=get_gpt_response(openai_api_key, image_paths, prompt )
|
1748 |
print("recommend result",result)
|
|
|
2329 |
|
2330 |
style_gallery_result.select(
|
2331 |
style_associate,
|
2332 |
+
inputs=[image_path,openai_api_key,language,auto_play,length,log_state,sort_rec,naritive,recomended_state,artist_label],
|
2333 |
outputs=[recommend_bot,recomended_state,output_audio,log_state,pic_index,recommend_score],
|
2334 |
|
2335 |
|