artdwn commited on
Commit
1ed78ad
·
1 Parent(s): 4878ed5

Upload 5 files

Browse files
Files changed (5) hide show
  1. final_prompt.txt +1 -0
  2. output.png +3 -0
  3. resea.py +73 -0
  4. response_text.txt +1 -0
  5. script_log.txt +64 -0
final_prompt.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Masterpiece, best quality, 1girl, yor briar, red sweater, (red dress:0.7), white headband, earrings, <lora:yorForgerV3:0.8>, short hair with long locks, sidelocks, Yor Forger stood stiffly, her hands clasped in front of her as she greeted the newcomer with a nervous smile, her eyes darting around suspiciously and her mind racing with suspicions and precautions.
output.png ADDED

Git LFS Details

  • SHA256: 80724497ab27a4a455d621a92a45a696a9764b4443b5a3ff1af14349e14d833a
  • Pointer size: 131 Bytes
  • Size of remote file: 296 kB
resea.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ import json
4
+ import io
5
+ import base64
6
+ from PIL import Image
7
+ import openai
8
+ import logging
9
+
10
+ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
11
+ logger = logging.getLogger(__name__)
12
+
13
+ file_handler = logging.FileHandler('script_log.txt')
14
+ logger.addHandler(file_handler)
15
+
16
+ masterPrompt = "Masterpiece, best quality, "
17
+ yorForgerPrompt = "1girl, yor briar, red sweater, (red dress:0.7), white headband, earrings, <lora:yorForgerV3:0.8>, short hair with long locks, sidelocks, "
18
+ negative_prompt = "lowres, low quality, worst quality, bad quality, bad-hands-5, realistic, nsfw, sexually suggestive"
19
+
20
+ #Nanti coba ganti dengan History untuk mendapatkan history 5 chat
21
+ data_list = [
22
+ {"message": "Success", "data": "O-oh? S-selamat datang di gedung ini, D-dokter NekoFi! Aku Yor Forger, semoga kita bisa menjadi tetangga yang baik. Inner Thought 🌷: Apa dia sudah mengetahui identitasku? Atau mungkin ini hanya kebetulan belaka... Haruskah aku berhati-hati terhadap pria ini?"},
23
+ {"message": "Success", "data": "Hehe, kurasa begitu. A-aku tinggal bersama adikku, Yuri Briar. Dia sedang bekerja sekarang sih. Inner Thought 🌷: Kukira dia akan mengajukan pertanyaan yang lebih sulit...apakah ini hanya trik atau emang segitu doank?"},
24
+ {"message": "Success", "data": "Ohh... Terimakasih banyak, NekoFi-san! A-aku senang sekali kau berinisiatif untuk membawakan ini. K-kami pasti akan menikmatinya Inner Thought 🌷: Apakah dia mencoba meracuniku? Sebaiknya aku periksa dulu sebelum memakannya."},
25
+ {"message": "Success", "data": "T-terimakasih banyak, Dr. NekoFi! S-saya berharap saya tidak perlu mengambil tawaran itu terlalu sering, haha... Inner Thought 🌷: Diskon? Apakah ini cara lain untuk meracuniku? Perlu diwaspadai..."},
26
+ {"message": "Success", "data": "O-Oke, sampai jumpa lagi, Dr. NekoFi! Terimakasih sudah berkunjung dan membawakan kue! :) Inner Thought 🌷: Orang itu pasti mencurigakan. Aku perlu melakukan pengecekan lebih lanjut malam ini."}
27
+ ]
28
+
29
+ chat_text = "\n".join([f"Chat{i+1}: \"{item['data']}\"" for i, item in enumerate(data_list)])
30
+ logger.info("Chat text concatenated.")
31
+
32
+ openai.api_key = "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"
33
+ prompt_text = (
34
+ f"Describe Yor Forger's physical actions and expressions in a single sentence, focusing solely on her without mentioning other characters or specific place names, suitable for a Text to Image AI prompt, and without referencing her thoughts or spoken words. "
35
+ f"\n\n{chat_text}"
36
+ )
37
+
38
+ logger.info("Sending prompt to OpenAI API...")
39
+ response_openai = openai.Completion.create(
40
+ model="gpt-3.5-turbo-instruct",
41
+ prompt=prompt_text,
42
+ max_tokens=300,
43
+ temperature=0.7
44
+ )
45
+ logger.info("Received response from OpenAI API.")
46
+
47
+ response_text = response_openai['choices'][0]['text'].strip()
48
+
49
+ with open("response_text.txt", "w") as f:
50
+ f.write(response_text)
51
+ logger.info("Response text saved to response_text.txt.")
52
+
53
+ final_prompt = masterPrompt + yorForgerPrompt + response_text
54
+
55
+ with open("final_prompt.txt", "w") as f:
56
+ f.write(final_prompt)
57
+ logger.info("Final prompt saved to final_prompt.txt.")
58
+
59
+ url_sd = "http://127.0.0.1:7861"
60
+ payload_sd = {
61
+ "prompt": final_prompt,
62
+ "steps": 30,
63
+ "negative_prompt": negative_prompt
64
+ }
65
+
66
+ logger.info("Sending final prompt to Stable Diffusion API...")
67
+ response_sd = requests.post(url=f'{url_sd}/sdapi/v1/txt2img', json=payload_sd)
68
+ logger.info("Received response from Stable Diffusion API.")
69
+
70
+ r_sd = response_sd.json()
71
+ image = Image.open(io.BytesIO(base64.b64decode(r_sd['images'][0])))
72
+ image.save('output.png')
73
+ logger.info("Image saved as output.png.")
response_text.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Yor Forger stood stiffly, her hands clasped in front of her as she greeted the newcomer with a nervous smile, her eyes darting around suspiciously and her mind racing with suspicions and precautions.
script_log.txt ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Chat text concatenated.
2
+ Sending prompt to OpenAI API...
3
+ Received response from OpenAI API.
4
+ Response text saved to response_text.txt.
5
+ Final prompt saved to final_prompt.txt.
6
+ Sending final prompt to Stable Diffusion API...
7
+ Received response from Stable Diffusion API.
8
+ Image saved as output.png.
9
+ Chat text concatenated.
10
+ Sending prompt to OpenAI API...
11
+ Received response from OpenAI API.
12
+ Response text saved to response_text.txt.
13
+ Final prompt saved to final_prompt.txt.
14
+ Sending final prompt to Stable Diffusion API...
15
+ Received response from Stable Diffusion API.
16
+ Image saved as output.png.
17
+ Chat text concatenated.
18
+ Sending prompt to OpenAI API...
19
+ Received response from OpenAI API.
20
+ Response text saved to response_text.txt.
21
+ Final prompt saved to final_prompt.txt.
22
+ Sending final prompt to Stable Diffusion API...
23
+ Received response from Stable Diffusion API.
24
+ Image saved as output.png.
25
+ Chat text concatenated.
26
+ Sending prompt to OpenAI API...
27
+ Received response from OpenAI API.
28
+ Response text saved to response_text.txt.
29
+ Final prompt saved to final_prompt.txt.
30
+ Sending final prompt to Stable Diffusion API...
31
+ Received response from Stable Diffusion API.
32
+ Image saved as output.png.
33
+ Chat text concatenated.
34
+ Sending prompt to OpenAI API...
35
+ Received response from OpenAI API.
36
+ Response text saved to response_text.txt.
37
+ Final prompt saved to final_prompt.txt.
38
+ Sending final prompt to Stable Diffusion API...
39
+ Received response from Stable Diffusion API.
40
+ Image saved as output.png.
41
+ Chat text concatenated.
42
+ Sending prompt to OpenAI API...
43
+ Received response from OpenAI API.
44
+ Response text saved to response_text.txt.
45
+ Final prompt saved to final_prompt.txt.
46
+ Sending final prompt to Stable Diffusion API...
47
+ Received response from Stable Diffusion API.
48
+ Image saved as output.png.
49
+ Chat text concatenated.
50
+ Sending prompt to OpenAI API...
51
+ Received response from OpenAI API.
52
+ Response text saved to response_text.txt.
53
+ Final prompt saved to final_prompt.txt.
54
+ Sending final prompt to Stable Diffusion API...
55
+ Received response from Stable Diffusion API.
56
+ Image saved as output.png.
57
+ Chat text concatenated.
58
+ Sending prompt to OpenAI API...
59
+ Received response from OpenAI API.
60
+ Response text saved to response_text.txt.
61
+ Final prompt saved to final_prompt.txt.
62
+ Sending final prompt to Stable Diffusion API...
63
+ Received response from Stable Diffusion API.
64
+ Image saved as output.png.