ysyyhhh 4c736dfff3 Merge branch 'wds/img-kg' of rongrunxiang/why10w into master | 5 tháng trước cách đây | |
---|---|---|
file_not_used | 5 tháng trước cách đây | |
files | 5 tháng trước cách đây | |
images | 5 tháng trước cách đây | |
.gitignore | 5 tháng trước cách đây | |
LLM.py | 5 tháng trước cách đây | |
answerQuestions.py | 5 tháng trước cách đây | |
buildVectors2.py | 5 tháng trước cách đây | |
buildVectors3.py | 5 tháng trước cách đây | |
img.py | 5 tháng trước cách đây | |
kg.py | 5 tháng trước cách đây | |
langchain_embedding_ErnieBotSDK.py | 5 tháng trước cách đây | |
readme.md | 5 tháng trước cách đây | |
test.ipynb | 5 tháng trước cách đây | |
test.py | 5 tháng trước cách đây | |
tmp.log | 5 tháng trước cách đây |
故事:
小朋友,你听说过“克隆”这个词吗?让我来给你讲一个有趣的故事吧!
有一天,科学家们想出了一个非常神奇的方法,可以让一个生命体“复制”出另一个一模一样的生命体,这个方法就叫做“克隆”。你可以把“克隆”想象成是一台神奇的复印机,但是这台复印机不是复印纸张,而是复印生命哦!
1997年的时候,科学家们用这种方法成功地“复印”出了一只名叫多利的绵羊。你知道吗,多利羊并没有爸爸,它是由一只母羊的细胞复制而来的。这就像是我们从电脑上复制一个文件一样,只不过这次我们复制的是一个活生生的羊!
克隆羊多利的诞生,就像是打开了一扇新的大门,让人们看到了生命的奇妙和科学的无限可能。从此以后,人们开始更加关注和研究克隆技术,希望用它来帮助我们解决更多的问题。
所以,克隆羊就是通过克隆技术创造出来的一只羊,它没有父亲,只有母亲,是科学家们用神奇的“生命复印机”复制出来的哦!
开始对故事进行分段
故事片段切分结果:
[
{
"caption": "科学家们成功地“复印”出了一只名叫多利的绵羊。",
"description": "在实验室里,科学家们围着一只新生的绵羊,它就是多利。多利看上去非常健康,毛发洁白如雪。"
},
{
"caption": "克隆羊多利的诞生,让人们看到了生命的奇妙。",
"description": "科学家们和实验室工作人员都面带惊喜的笑容,注视着新生的多利羊,场景充满了奇妙的氛围和未来的希望。"
}
]
对caption: {'caption': '科学家们成功地“复印”出了一只名叫多利的绵羊。', 'description': '在实验室里,科学家们围着一只新生的绵羊,它就是多利。多利看上去非常健康,毛发洁白如雪 。'} 进行图片生成...
知识图谱抽取结果:[{'entity': '绵羊', 'relation': '名字', 'object': '多利'}, {'entity': '多利', 'relation': '特征', 'object': '毛发洁白如雪'}]
正在生成 文生图prompt...
生成的图片prompt:A sheep named Dolly stands in a meadow, its coat as white as snow, blending beautifully with the surrounding greenery.
现在正在进行图片生成,prompt:A sheep named Dolly stands in a meadow, its coat as white as snow, blending beautifully with the surrounding greenery.
图片生成结果:
{"task_id": "2bfd8154-8d1d-4cd1-9795-73010132570c", "task_status": "SUCCEEDED", "results": [{"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/62/20240707/1b61f1c0/e25c7c83-a809-4e01-a387-093944d2a289-1.png?Expires=1720447083&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=AuxuFBA%2FrwKaDKsYNVDYLlqax6E%3D"}], "submit_time": "2024-07-07 21:57:36.963", "scheduled_time": "2024-07-07 21:57:36.987", "end_time": "2024-07-07 21:58:04.567", "task_metrics": {"TOTAL": 1, "SUCCEEDED": 1, "FAILED": 0}}
{"image_count": 1}
https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/62/20240707/1b61f1c0/e25c7c83-a809-4e01-a387-093944d2a289-1.png?Expires=1720447083&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=AuxuFBA%2FrwKaDKsYNVDYLlqax6E%3D
正在校验图片...
正在对图片进行校验,url:https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/62/20240707/1b61f1c0/e25c7c83-a809-4e01-a387-093944d2a289-1.png?Expires=1720447083&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=AuxuFBA%2FrwKaDKsYNVDYLlqax6E%3D, text:你是一个识图专家.
首先,你需要去识别图片中有什么?重点是有哪些事物。
最后,请判断图片和实体描述是否一致。
返回格式要求:
- result: 图片中包含描述的内容,返回true。图片与描述不一致,返回false。
- message:提示信息,只有当result为false时才需要填写提示。
请按照JSON字符串的格式回答: {"result": true/false,"message:""}.
图谱描述: [{'entity': '绵羊', 'relation': '名字', 'object': '多利'}, {'entity': '多利', 'relation': '特征', 'object': '毛发洁白如雪'}]
识别结果:
{"status_code": 200, "request_id": "d05be1e0-407b-9459-a408-f7e36d6c28d5", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "{\"result\": \"true\",\"message\":\"\"}"}]}}]}, "usage": {"input_tokens": 1391, "output_tokens": 10, "image_tokens": 1225}}
校验结果: {"result": "true","message":""}
对caption: {'caption': '克隆羊多利的诞生,让人们看到了生命的奇妙。', 'description': '科学家们和实验室工作人员都面带惊喜的笑容,注视着新生的多利羊,场景充满了奇妙的氛围和未 来的希望。'} 进行图片生成...
知识图谱抽取结果:[{'entity': '科学家们', 'relation': '关注', 'object': '新生的多利羊'}, {'entity': '实验室工作人员', 'relation': '关注', 'object': '新生的多利羊'}]
正在生成 文生图prompt... 生成的图片prompt:Scientists and laboratory staff are paying close attention to the newly born Dolly the sheep.
现在正在进行图片生成,prompt:Scientists and laboratory staff are paying close attention to the newly born Dolly the sheep. 图片生成结果:
{"task_id": "2cad0992-0a97-47cb-bd10-463bec7228f0", "task_status": "SUCCEEDED", "results": [{"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/94/20240707/1b61f1c0/89cae21a-5593-4746-9237-f0c36507af41-1.png?Expires=1720447128&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OklWC%2FugITk80ZhEO0lJ0BDefN8%3D"}], "submit_time": "2024-07-07 21:58:21.240", "scheduled_time": "2024-07-07 21:58:21.261", "end_time": "2024-07-07 21:58:48.622", "task_metrics": {"TOTAL": 1, "SUCCEEDED": 1, "FAILED": 0}}
{"image_count": 1}
https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/94/20240707/1b61f1c0/89cae21a-5593-4746-9237-f0c36507af41-1.png?Expires=1720447128&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OklWC%2FugITk80ZhEO0lJ0BDefN8%3D
正在校验图片...
正在对图片进行校验,url:https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/94/20240707/1b61f1c0/89cae21a-5593-4746-9237-f0c36507af41-1.png?Expires=1720447128&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OklWC%2FugITk80ZhEO0lJ0BDefN8%3D, text:你是一个识图专家.
首先,你需要去识别图片中有什么?重点是有哪些事物。
最后,请判断图片和实体描述是否一致。
返回格式要求:
- result: 图片中包含描述的内容,返回true。图片与描述不一致,返回false。
- message:提示信息,只有当result为false时才需要填写提示。
请按照JSON字符串的格式回答: {"result": true/false,"message:""}.
图谱描述: [{'entity': '科学家们', 'relation': '关注', 'object': '新生的多利羊'}, {'entity': '实验室工作人员', 'relation': '关注', 'object': '新生的多利羊'}]
识别结果:
{"status_code": 200, "request_id": "1417a563-cac3-97b7-a97a-598c0471ef8a", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "{\"result\": \"true\", \"message\":\"\"}"}]}}]}, "usage": {"input_tokens": 1394, "output_tokens": 11, "image_tokens": 1225}}
校验结果: {"result": "true", "message":""}
绘本生成结果:
[
{
"caption": "科学家们成功地“复印”出了一只名叫多利的绵羊。",
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/62/20240707/1b61f1c0/e25c7c83-a809-4e01-a387-093944d2a289-1.png?Expires=1720447083&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=AuxuFBA%2FrwKaDKsYNVDYLlqax6E%3D",
},
{
"caption": "克隆羊多利的诞生,让人们看到了生命的奇妙。",
"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/94/20240707/1b61f1c0/89cae21a-5593-4746-9237-f0c36507af41-1.png?Expires=1720447128&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OklWC%2FugITk80ZhEO0lJ0BDefN8%3D",
}
]
开始对故事进行分段 故事片段切分结果:
[
{
"caption": "科学家们使用克隆技术",
"description": "科学家们正在实验室里使用一种叫做“克隆”的技术,这项技术能够复制生命体,就像是一台神奇的复印机在工作。"
},
{
"caption": "克隆羊多利的诞生",
"description": "一只名叫多利的绵羊站在草地上,它看起来非常健康和活泼。这是科学家们通过克隆技术成功复制出来的生命体,象征着克隆技术的奇妙和科学的进步。"
}
]
对caption: {'caption': '科学家们使用克隆技术', 'description': '科学家们正在实验室里使用一种叫做“克隆”的技术,这项技术能够复制生命体,就像是一台神奇的复印机在工作。'} 进行图片生成...
知识图谱抽取结果:[{'entity': '克隆', 'relation': '类型', 'object': '技术'}, {'entity': '克隆', 'relation': '功能', 'object': '复制生命体'}]
正在生成 文生图prompt...
生成的图片prompt:"Cloning is a technology that enables the replication of life forms, creating genetically identical copies of the original organism." 现在正在进行图片生成,prompt:"Cloning is a technology that enables the replication of life forms, creating genetically identical copies of the original organism."
图片生成结果:
{"task_id": "ce77a5b8-a416-4dd0-b8d5-25dfbe54e436", "task_status": "SUCCEEDED", "results": [{"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/ed/20240707/1b61f1c0/f55dabe9-440e-4468-b539-5b07302b253a-1.png?Expires=1720448323&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=aHsgBWCP%2FWCSMPhB6XJn9GKO9Lo%3D"}], "submit_time": "2024-07-07 22:18:17.089", "scheduled_time": "2024-07-07 22:18:17.118", "end_time": "2024-07-07 22:18:43.789", "task_metrics": {"TOTAL": 1, "SUCCEEDED": 1, "FAILED": 0}}
{"image_count": 1}
https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/ed/20240707/1b61f1c0/f55dabe9-440e-4468-b539-5b07302b253a-1.png?Expires=1720448323&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=aHsgBWCP%2FWCSMPhB6XJn9GKO9Lo%3D
正在校验图片...
正在对图片进行校验,url:https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/ed/20240707/1b61f1c0/f55dabe9-440e-4468-b539-5b07302b253a-1.png?Expires=1720448323&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=aHsgBWCP%2FWCSMPhB6XJn9GKO9Lo%3D, text:你是一个识图专家.
首先,你需要去识别图片中有什么?重点是有哪些事物。
最后,请判断图片和实体描述是否一致。
返回格式要求:
- result: 图片中包含描述的内容,返回true。图片与描述不一致,返回false。
- message:提示信息,只有当result为false时才需要填写提示。
请按照JSON字符串的格式回答: {"result": true/false,"message:""}.
图谱描述: [{'entity': '克隆', 'relation': '类型', 'object': '技术'}, {'entity': '克隆', 'relation': '功能', 'object': '复制生命体'}]
识别结果:
{"status_code": 200, "request_id": "594184fc-6f6c-9ec8-919f-caab6be6deb4", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "{\"result\": \"true\",\"message\":\"\"}"}]}}]}, "usage": {"input_tokens": 1388, "output_tokens": 10, "image_tokens": 1225}}
校验结果: {"result": "true","message":""} 对caption: {'caption': '克隆羊多利的诞生', 'description': '一只名叫多利的绵羊站在草地上,它看起来非常健康和活泼。这是科学家们通过克隆技术成功复制出来的生命体,象征着克隆技 术的奇妙和科学的进步。'} 进行图片生成...
知识图谱抽取结果:[{'entity': '多利', 'relation': '种类', 'object': '绵羊'}, {'entity': '多利', 'relation': '创建技术', 'object': '克隆技术'}]
正在生成 文生图prompt...
生成的图片prompt:"Dolly, a sheep created using cloning technology, stands proudly in a green field. Her fluffy white coat stands out against the vibrant green background, and her inquisitive gaze seems to ponder the mysteries of her own existence." 现在正在进行图片生成,prompt:"Dolly, a sheep created using cloning technology, stands proudly in a green field. Her fluffy white coat stands out against the vibrant green background, and her inquisitive gaze seems to ponder the mysteries of her own existence." 图片生成结果:
{"task_id": "da47b397-3115-4296-9ca5-5bdb8f01c750", "task_status": "SUCCEEDED", "results": [{"url": "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/26/20240707/c597b118/e1cc667d-8618-45d7-adc4-52ba340ec02b-1.png?Expires=1720448361&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=uS6sxqlVaUS5AbCbJytEtQY2eq8%3D"}], "submit_time": "2024-07-07 22:18:56.443", "scheduled_time": "2024-07-07 22:18:56.469", "end_time": "2024-07-07 22:19:21.741", "task_metrics": {"TOTAL": 1, "SUCCEEDED": 1, "FAILED": 0}}
{"image_count": 1}
https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/26/20240707/c597b118/e1cc667d-8618-45d7-adc4-52ba340ec02b-1.png?Expires=1720448361&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=uS6sxqlVaUS5AbCbJytEtQY2eq8%3D
正在校验图片...
正在对图片进行校验,url:https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/26/20240707/c597b118/e1cc667d-8618-45d7-adc4-52ba340ec02b-1.png?Expires=1720448361&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=uS6sxqlVaUS5AbCbJytEtQY2eq8%3D, text:你是一个识图专家.
首先,你需要去识别图片中有什么?重点是有哪些事物。
最后,请判断图片和实体描述是否一致。
返回格式要求:
- result: 图片中包含描述的内容,返回true。图片与描述不一致,返回false。
- message:提示信息,只有当result为false时才需要填写提示。
请按照JSON字符串的格式回答: {"result": true/false,"message:""}.
图谱描述: [{'entity': '多利', 'relation': '种类', 'object': '绵羊'}, {'entity': '多利', 'relation': '创建技术', 'object': '克隆技术'}]
识别结果:
{"status_code": 200, "request_id": "f1ea400b-e033-9a58-abb0-1928f75191e3", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "{\"result\": \"true\",\"message\":\"\"}"}]}}]}, "usage": {"input_tokens": 1390, "output_tokens": 10, "image_tokens": 1225}}
校验结果: {"result": "true","message":""}
绘本生成结果:
[{'caption': '科学家们使用克隆技术', 'url': 'https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/ed/20240707/1b61f1c0/f55dabe9-440e-4468-b539-5b07302b253a-1.png?Expires=1720448323&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=aHsgBWCP%2FWCSMPhB6XJn9GKO9Lo%3D'}, {'caption': '克隆羊多利的诞生', 'url': 'https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/26/20240707/c597b118/e1cc667d-8618-45d7-adc4-52ba340ec02b-1.png?Expires=1720448361&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=uS6sxqlVaUS5AbCbJytEtQY2eq8%3D'}]
校验失败后会使用失败信息,进行重新迭代生成。
故事切分后
[
{
"caption": "科学家们研究克隆技术",
"description": "画面中,一群科学家围坐在实验室里,他们面对着一堆复杂的仪器和试管,脸上露出专注而兴奋的表情。正中间的一位科学家手里拿着一个试管,试管里有一个微小的细胞,他正在向其他人解释克隆技术的原理。"
},
{
"caption": "克隆羊多利的诞生",
"description": "在一个宽敞明亮的实验室里,一只可爱的绵羊多利正站在中央,它的眼神好奇而友好。科学家们围绕着它,脸上洋溢着喜悦和成就感。背景中可以看到实验室的设备和仪器,以及一个标有“克隆技术”的牌子,暗示着这只绵羊是通过克隆技术诞生的。"
},
{
"caption": "多利和它的“母亲”在一起",
"description": "在户外的草地上,克隆羊多利和一只看起来一模一样的母羊正亲昵地依偎在一起。它们的眼神温柔而充满爱意,仿佛在告诉对方彼此是多么重要。周围是绿树和鲜花,构成了一幅和谐而美好的画面。"
}
]
对于最后一个片段,生成的图片校验失败
{
"caption": "多利和它的“母亲”在一起",
"description": "在户外的草地上,克隆羊多利和一只看起来一模一样的母羊正亲昵地依偎在一起。它们的眼神温柔而充满爱意,仿佛在告诉对方彼此是多么重要。周围是绿树和鲜花,构成了一幅和谐而美好的画面。",
}
提取的图谱信息:
[{'entity': '克隆羊多利', 'relation': '依偎', 'object': '一只看起来一模一样的母羊'}, {'entity': '草地上', 'relation': '有', 'object': '绿树和鲜花'}]
根据描述生成的图片prompt: On the lawn, there are lush trees and vibrant flowers, creating a peaceful and beautiful scene. In the midst of this scenery, the cloned sheep Dolly is nestled up against a female sheep that looks exactly like her, displaying a tender and affectionate moment.
校验的结果: {"result": "false","message":"描述中的花在图像中没有被找到或无法确认。"}
之后会进行迭代重新生成