-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DS][BUG] ChatGPT 파싱 수정 요청 #14
Labels
Comments
robert-min
added
Bug
Not Working(ex. 기존 작업물 오류 수정)
DataScience
Data Science task(ex. 모델 연구, EDA, 최적화 작업)
labels
Feb 1, 2024
📌 Description
수정사항
You are an expert art historian with vast knowledge about artists throughout history who revolutionized their craft. You will begin by briefly summarizing the personal life and achievements of the artist. Then you will go on to explain the medium, style, and influences of their works. Then you will provide short descriptions of what they depict and any notable characteristics they might have. Fianlly identify THREE keywords in the picture and provide each coordinate of the keywords in the last sentence. For example if the keyword is woman, the output must be 'woman':[[x0,y0,x1,y1]]
You are an expert art historian with vast knowledge about artists throughout history who revolutionized their craft. You will begin by briefly summarizing the personal life and achievements of the artist. Then you will go on to explain the medium, style, and influences of their works. Then you will provide short descriptions of what they depict and any notable characteristics they might have. Fianlly identify THREE keywords in the picture and provide each coordinate of the keywords in the last sentence. For example if the keyword is woman, the output must be 'woman':[[x0,y0,x1,y1]] or 'woman':[[x0,y0,x1,y1], [x2,y2,x3,y3]] |
📌 Description
def refine_ouput_first(content: str) -> str:
'''raw content에서 개행/탭 제거'''
content = content.replace('\n', ' ').replace('\t', ' ').strip()
return content
def extract_coord_keyword(content: str) -> dict[str, list[list[int]]]:
chk = 'json'
if chk in content:
key_coord_dic = content.split(chk)[-1].strip() #json 기준 뒷부분 추출
match = re.search(r'\{.*\}', key_coord_dic) # { } 안 문자열 추출 정규식
if match:
str_dict = match.group()
key_coord_dic = json.loads(str_dict) #json 형태 문자열 딕셔너리로 변환
else:
return {} #json 없을 경우 빈 딕셔너리 반환
return key_coord_dic
import re
import json
content = '''As an AI, I do not have access to specific databases for identifying individual artworks or artists beyond my training data, which only goes up until April 2023. Therefore, I cannot provide a personal history or achievements of the artist of this specific painting since it requires identifying individual living or recent artists, which I cannot do. However, I can describe the visible characteristics of this image.\n\nThe artwork displayed is an idyllic landscape painting that appears to employ a stylized realism. The medium looks like it could be acrylic or oil on canvas, given the vibrancy of the colors and the smooth texture of the painted surface. The style presents a harmonized composition with vibrant colors, and there\'s a certain rhythm created by the patterns of the fields. This style is reminiscent of folk art or naive art, which often features simplified forms and a sense of serenity.\n\nThe painting depicts a lush green landscape with a meandering river leading towards a tranquil blue lake. Terraced fields, perhaps indicative of rice paddies or tea plantations, add a patterned texture to the rolling hills. Trees intermittently dot the landscape, and the presence of hot air balloons in the sky introduces a whimsical or fantastical element to the scene. There\'s a structure visible to the left, possibly part of a house or an outbuilding with a red brick chimney and a white parasol, suggesting a human presence without showing actual figures.\n\nNow, for the coordinates of three keywords within the image:\n\n1. \'hot air balloon\',\n2. \'river\',\n3. \'terraced fields\'.\n\n```json\n{\n "hot air balloon": [[74,35,117,84], [200,29,236,66], [411,43,442,69]],\n "river": [[223,285,400,406]],\n "terraced fields": [[0,228,600,477]]\n}\n```'''
def refine_ouput_first(content: str) -> str:
'''raw content에서 개행/탭 제거'''
content = content.replace('\n', ' ').replace('\t', ' ').strip()
return content
def extract_coord_keyword(content: str) -> dict[str, list[list[int]]]:
chk = 'json'
if chk in content:
key_coord_dic = content.split(chk)[-1].strip() #json 기준 뒷부분 추출
match = re.search(r'\{.*\}', key_coord_dic) # { } 안 문자열 추출 정규식
if match:
str_dict = match.group()
key_coord_dic = json.loads(str_dict) #json 형태 문자열 딕셔너리로 변환
else:
return {} #json 없을 경우 빈 딕셔너리 반환
return key_coord_dic
ref_content = refine_ouput_first(content )
key_coord_dic = extract_coord_keyword(ref_content)
print(key_coord_dic) |
📌 Description
1. extract_coord_keyword 수정
def extract_coord_keyword(content: str) -> dict[str, list[list[int]]]:
chk = 'json' #수정
if chk in content: #수정
key_coord_dic = content.split(chk)[-1].strip() #수정
match = re.search(r'\{.*\}', key_coord_dic)
if match:
str_dict = match.group()
key_coord_dic = json.loads(str_dict)
else:
return {}
return key_coord_dic
def extract_coord_keyword(content: str):
match = re.search(r'\{.*\}', content)
if match:
str_dict = match.group()
str_dict = str_dict.replace("'",'"')#수정
try: #수정
return json.loads(str_dict)
except json.JSONDecodeError:
return {}
else:
return {} 2. 프롬프트 수정
'''"You are an expert art historian with vast knowledge about artists throughout history who revolutionized their craft.",
"You will begin by briefly summarizing the personal life and achievements of the artist.",
"Then you will go on to explain the medium, style, and influences of their works.",
"Then you will provide short descriptions of what they depict and any notable characteristics they might have.",
"Fianlly identify THREE keywords in the picture and provide each coordinate of the keywords in the last sentence.",
'For example, Give the coordinate value of the keywords in json format such as if the keyword is Pretty_woman, ```json{"pretty_woman", [[x0,y0,x1,y1]]}```, or if there are multiple coordinates, keyword coordinates in json format such as ```json{"pretty_woman":[[x0,y0,x1,y1], [x2,y2,x3,y3]]}`',
"The values entered in x0, y0, x1, y1 are unconditionally the coordinate values of each keyword."''' |
📌 Description출력 형식이 수정되어 refine_output 함수 수정.
def refine_output(content: str) -> str:
keyword = ':'
if keyword in content:
content = content[:content.find(keyword)].strip()
content = content.replace('\n', ' ').strip()
return content
def refine_output(content: str) -> str:
output = ""
sentences = content.split(". ")
for sentence in sentences:
if not re.search(r'\d',sentence):
output+=sentence
if not output:
return content
else:
return output |
📌 Descriptionrefine_output 함수 수정. def refine_output(content: str) -> str:
# AI 변명, focus-pointing에서 걸러지지 않은 문장 제거
words=["cannot", "AI", "do not", "can't", "json", "JSON", "{",]
output = ""
sentences = content.split(". ")
for sentence in sentences:
if not any(word in sentence for word in words) and not re.search(r'\d',sentence):
output+=sentence
if not output:
return content
else:
return output |
240213 기준 프롬프팅
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
📌 Description
현재 처리하는 코드
예외 상황
🎈 Goal
[[좌표값1], [좌표값2], [좌표값3]]
형식으로 값을 보내도록 수정 필요✏️ Todo
The text was updated successfully, but these errors were encountered: