Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Anning01 committed Aug 30, 2023
1 parent fd586c8 commit f96a9b3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
16 changes: 2 additions & 14 deletions SDK/ChatGPT/openAI/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,7 @@ class Main:
def __str__(self):
return "ChatGPT请求失败,请检查配置!"

def prompt_generation_chatgpt(self, param, gpt_prompt):
# openai.api_key = openAPI_KEY
# try:
# completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[
# {"role": "user", "content": gpt_prompt.get("prompt") + param}
# ], timeout=5)
# except Timeout:
# raise "ChatGPT请求超时,请检查配置!"
# except Exception as e:
# print(e)
# return False
# return completion.choices[0].message.content

def prompt_generation_chatgpt(self, param, gpt_prompt, api_key=None):
# 构建请求数据
data = {
"model": "gpt-3.5-turbo",
Expand All @@ -60,7 +48,7 @@ def prompt_generation_chatgpt(self, param, gpt_prompt):
# 设置请求头部
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {self.API_KEY}"
"Authorization": f"Bearer {api_key if api_key else self.API_KEY}"
}
print("-----------开始请求ChatGPT-----------")
try:
Expand Down
7 changes: 0 additions & 7 deletions apps/TextSiice/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,8 @@ def txt_long(self, text_list: list):
for index, value in enumerate(text_list):
# print(index, value)
if len(value) > 60:
# value_list = await self.recursion(value)
value_list = self.symbol_split(value, [',', '?'])
# print(index)
# x = text_list.pop(index)
new_list.extend(value_list)
# for i, v in enumerate(value_list):
# print(v)
# new_list.append(v)
# text_list.insert(index + i, v)
else:
new_list.extend([value])
return new_list
Expand Down
19 changes: 13 additions & 6 deletions cli_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,29 @@
if not all((client_id, client_secret, (all([apikey, appId]), ForwardKey), sd_url, file_path)):
raise ValueError("Environment variables are missing.")

prompt_dict = {
"negative_prompt": "badhandv4,ng_deepnegative_v1_64t,worst quality,low quality,normal quality,lowers,monochrome,grayscales,skin spots,acnes,skin blemishes,age spot,6 more fingers on one hand,deformity,bad legs,error legs,bad feet,malformed limbs,extra limbs,ugly,poorly drawn hands,poorly drawn feet,poorly drawn face,text,mutilated,extra fingers,mutated hands,mutation,bad anatomy,cloned face,disfigured,fused fingers",
"prompt": "Task: I will tell you the theme of the prompt to generate in natural language, and your task is to imagine a complete picture based on this theme, then transform it into a detailed, high-quality prompt, so that Stable Diffusion can generate high-quality images. Prompt concept: A prompt is used to describe images, composed of common, often used words, using English half-width ',' as a separator. Each word or phrase separated by ',' is known as a tag. So a prompt consists of a series of tags separated by ','. Below, I will explain the steps to generate a prompt, where the prompt can be used to describe characters, scenery, objects or abstract digital art drawings. Prompt requirements: The prompt should contain elements such as the main subject of the image, texture, additional details, image quality, artistic style, color tone, lighting, etc. Attention, the prompt you output cannot be split into sections, for example, descriptions like 'medium:','Main subject:','Keywords:','Prompt:','texture:','additional details:','image quality:','artistic style:','color tone:','lighting:','tags:' are not needed and it cannot contain ':' or '.'! Main subject: Briefly describe the main subject of the picture in English, such as 'A girl in a garden'. This encapsulates the core content of the image (the subject can be people, things, objects, landscapes). This part is generated based on the theme I give you each time. You can add more reasonable details related to the theme. For character themes, you must describe the character's eyes, nose, and lips, for example 'beautiful detailed eyes, beautiful detailed lips, extremely detailed eyes and face, long eyelashes', to avoid Stable Diffusion randomly generating deformed facial features, this is very important. The theme I provide is:",
"default_prompt": "Big scene, best quality,masterpiece, illustration, an extremely delicate and beautiful, extremely detailed,CG, unity, 8k wallpaper,"
}


def main(bookname: str, tags: list | None = None):
# 处理文本
t = TMain()
text_list = list(filter(None, t.txt_handle(f'{bookname}.txt')))
print(text_list)

# 生成提示词
p = PMain()
object_list = p.create_prompt_words(text_list, tags, prompt_dict)
print(object_list)

# 生成音频
s = SMain()
audio_list = s.text_to_audio(text_list)
print(audio_list)

# 生成提示词
p = PMain()
object_list = p.create_prompt_words(text_list, tags)
print(object_list)

# 生成图片
gp = GPMain()
picture_path_list = gp.create_picture(object_list)
Expand All @@ -55,4 +61,5 @@ def main(bookname: str, tags: list | None = None):
# "时宇": "年轻男性"
# }
# main("不科学御兽(第一章:御兽时代)")
asyncio.run(main("小说"))

main("小说")

0 comments on commit f96a9b3

Please sign in to comment.