Spaces:
Running
Running
Niki Zhang
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1009,7 +1009,7 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
|
|
1009 |
image_input.save(new_image_path)
|
1010 |
print("img_path",new_image_path)
|
1011 |
visual_chatgpt.current_image = new_image_path
|
1012 |
-
|
1013 |
# visual_chatgpt.agent.memory.buffer = visual_chatgpt.agent.memory.buffer + visual_chatgpt.global_prompt
|
1014 |
if task_type=="task 3":
|
1015 |
name="Along the River During the Qingming Festival"
|
@@ -1017,7 +1017,6 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
|
|
1017 |
year="12th century (Song Dynasty)"
|
1018 |
material="Chinese painting"
|
1019 |
gender="male"
|
1020 |
-
paragraph="This image depicts a traditional Chinese medicine clinic scene from an ancient painting. The interior of the clinic shows various activities related to traditional Chinese medical practices. Inside the clinic: 1. To the right, a practitioner is consulting with a patient, examining the pulse, which is a common diagnostic method in traditional Chinese medicine. 2. To the far right, another practitioner is seated at a desk, likely preparing or recording prescriptions. Behind him is a traditional Chinese medicine cabinet with numerous drawers for storing herbs and medicinal ingredients.3. On the left side of the clinic, there are patients seated, possibly waiting for their turn for consultation or treatment.4. Wall hangings, presumably diagrams or medical posters, are displayed within the clinic.Outside and around the clinic: 1. People walking by or moving around, possibly other patients or townspeople, indicating the scene takes place in a lively community setting.2. Someone carrying goods in a traditional yoke balanced across their shoulders, indicative of daily life and commerce. This scene provides a detailed glimpse into the practice of traditional Chinese medicine and everyday life in historical China."
|
1021 |
|
1022 |
elif task_type=="task 1":
|
1023 |
name ="The Ambassadors"
|
@@ -1025,7 +1024,6 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
|
|
1025 |
year = "1533 (Northern Renaissance)"
|
1026 |
material="Realism"
|
1027 |
gender = "male"
|
1028 |
-
paragraph="This image is a famous painting known as \"The Ambassadors\" by Hans Holbein the Younger, created in 1533. In the painting, there are two men standing on either side of a table covered with a rich carpet. The man on the left is dressed in elaborate, luxurious clothing, indicating his high social status, and holds a dagger. The man on the right is dressed in more somber, clerical attire, possibly denoting a scholarly or ecclesiastical position.The table between them is filled with various objects, including scientific instruments like a globe, a sundial, a quadrant, and books, reflecting the intellectual interests and pursuits of the time, specifically in navigation and astronomy. A significant detail in the painting is the distorted object at the bottom center, which, when viewed from an angle, reveals itself to be a skull — a classic example of anamorphosis. This hidden skull serves as a memento mori, reminding viewers of the inevitability of death, a common theme in Renaissance art."
|
1029 |
|
1030 |
elif task_type=="task 2":
|
1031 |
name = "The Football Players"
|
@@ -1033,9 +1031,8 @@ async def upload_callback(image_input,state, log_state, task_type, visual_chatgp
|
|
1033 |
year= "1912 (Cubism)"
|
1034 |
material="Cubism"
|
1035 |
gender= "male"
|
1036 |
-
|
1037 |
else:
|
1038 |
-
paragraph = get_gpt_response(openai_api_key, new_image_path,f"What's going on in this picture? in {language}")
|
1039 |
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\"}")
|
1040 |
print(parsed_data)
|
1041 |
parsed_data = json.loads(parsed_data.replace("'", "\""))
|
|
|
1009 |
image_input.save(new_image_path)
|
1010 |
print("img_path",new_image_path)
|
1011 |
visual_chatgpt.current_image = new_image_path
|
1012 |
+
paragraph = get_gpt_response(openai_api_key, new_image_path,f"What's going on in this picture? in {language}")
|
1013 |
# visual_chatgpt.agent.memory.buffer = visual_chatgpt.agent.memory.buffer + visual_chatgpt.global_prompt
|
1014 |
if task_type=="task 3":
|
1015 |
name="Along the River During the Qingming Festival"
|
|
|
1017 |
year="12th century (Song Dynasty)"
|
1018 |
material="Chinese painting"
|
1019 |
gender="male"
|
|
|
1020 |
|
1021 |
elif task_type=="task 1":
|
1022 |
name ="The Ambassadors"
|
|
|
1024 |
year = "1533 (Northern Renaissance)"
|
1025 |
material="Realism"
|
1026 |
gender = "male"
|
|
|
1027 |
|
1028 |
elif task_type=="task 2":
|
1029 |
name = "The Football Players"
|
|
|
1031 |
year= "1912 (Cubism)"
|
1032 |
material="Cubism"
|
1033 |
gender= "male"
|
1034 |
+
|
1035 |
else:
|
|
|
1036 |
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\"}")
|
1037 |
print(parsed_data)
|
1038 |
parsed_data = json.loads(parsed_data.replace("'", "\""))
|