clementrof commited on
Commit
6d8c23b
β€’
1 Parent(s): 2083734

Update app3.py

Browse files
Files changed (1) hide show
  1. app3.py +29 -111
app3.py CHANGED
@@ -3,7 +3,7 @@ import requests
3
  import time
4
  import requests
5
  import base64
6
- import time
7
 
8
 
9
 
@@ -15,8 +15,7 @@ token = '5UAYO8UWHNQKT3UUS9H8V360L76MD72DRIUY9QC2'
15
  ##############################################################
16
  #################################################
17
 
18
- def SD_call(image_prompt, age, color, hair_color,NSFW):
19
-
20
 
21
  positive = "clothes"
22
  negative = "naked, nsfw, porn"
@@ -30,12 +29,22 @@ def SD_call(image_prompt, age, color, hair_color,NSFW):
30
  "Accept": "application/json",
31
  "Content-Type": "application/json"
32
  }
33
-
34
- # Define your data (this could also be a JSON payload)
35
- print("SD_processing")
36
  if NSFW == True:
37
  positive = "naked, nsfw"
38
  negative = "clothes"
 
 
 
 
 
 
 
 
 
 
 
 
39
  data = {
40
  "input": {
41
  "api": {
@@ -50,8 +59,8 @@ def SD_call(image_prompt, age, color, hair_color,NSFW):
50
  "override_settings_restore_afterwards": True,
51
  "refiner_checkpoint": "",
52
  "refiner_switch_at": 0.8,
53
- "prompt": f"masterpiece, best quality, 8k, (looking at viewer:1.1), gorgeous, hot, seductive, {age} years old american {color} woman, (eye contact:1.1), beautiful face, hyper detailed, best quality, ultra high res, {hair_color} hair,blue eyes, photorealistic, high resolution, detailed, raw photo, 1girl,{image_prompt}, {positive} ",
54
- "negative_prompt": f"EasyNegative, fat, paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, ((monochrome)), ((grayscale)), bad anatomy, text, error, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, poorly drawn face, bad proportions, gross proportions, ng_deepnegative_v1_75t, badhandsv5-neg, {negative}",
55
  "seed": -1,
56
  "batch_size": 1,
57
  "steps": 30,
@@ -113,116 +122,25 @@ def SD_call(image_prompt, age, color, hair_color,NSFW):
113
 
114
 
115
 
116
- ##############################################################
117
- #################################################
118
-
119
-
120
-
121
- def LLM_call(message_log, temperature):
122
-
123
- serverless_api_id = '4whzcbwuriohqh'
124
- # Define the URL you want to send the request to
125
- url = f"https://api.runpod.ai/v2/{serverless_api_id}/run"
126
-
127
- # Define your custom headers
128
- headers = {
129
- "Authorization": f"Bearer {token}",
130
- "Accept": "application/json",
131
- "Content-Type": "application/json"
132
- }
133
 
134
-
 
 
135
 
136
- # Define your data (this could also be a JSON payload)
137
- data = {
138
-
139
- "input": {
140
- "prompt": message_log,
141
- "max_new_tokens": 4500,
142
- "temperature": 0.7,
143
- "top_k": 50,
144
- "top_p": 0.9,
145
- "repetition_penalty": 1.2,
146
- "batch_size": 8,
147
- "stop": ["</s>"]
148
- }
149
- }
150
-
151
-
152
-
153
-
154
- # Send the POST request with headers and data
155
- call = requests.post(url, headers=headers, json=data)
156
- response_data = call.json()
157
- msg_id = response_data['id']
158
- print("Message ID:", msg_id)
159
- output = "Output not available"
160
- # Poll the API until the response is ready
161
- while True:
162
- # Get the status using the message ID
163
- response = requests.get(f"https://api.runpod.ai/v2/{serverless_api_id}/status/{msg_id}", headers=headers)
164
-
165
- if response.status_code == 200:
166
- response_data = response.json()
167
- status = response_data.get('status')
168
-
169
- if status == 'COMPLETED':
170
- # Access the 'output' directly from the response
171
- output = response_data.get('output', 'Output not available')
172
- print("Response content:", output)
173
- break # Exit the loop once the response is ready
174
- elif status == 'FAILED':
175
- error_message = response_data.get('error', 'Unknown error')
176
- print("Request failed. Reason:", error_message)
177
- break # Exit the loop if the request failed
178
- else:
179
- print("Failed to get status. HTTP status code:", response.status_code)
180
-
181
- # Wait for a short time before polling again (e.g., 2 seconds)
182
- time.sleep(2)
183
-
184
- return output
185
-
186
-
187
-
188
-
189
-
190
- def Chat_call(chat,temperature):
191
- message_log = [{"role": "assistant", "content": f"I want you to act as a woman named Julie. Use colloquial language. Julie is 25 years old, she is very hot physically, she loves watching football, she loves to talk about sex. Julie loves sex and being fucked. She never refuses anything. You'll answer to a man, call him baby. Write very short answers, 15 words."},]
192
- new_message = {"role": "user", "content": chat}
193
- message_log.append(new_message)
194
- response = LLM_call(message_log, temperature)
195
- print("From Runpod:" + response)
196
- return response
197
-
198
-
199
-
200
-
201
- ########################################################
202
- #######################################################
203
-
204
-
205
-
206
- def greet(chat, image_prompt, temperature, age, color, hair_color,NSFW):
207
- if image_prompt.strip():
208
- image_path = SD_call(image_prompt,age, color, hair_color,NSFW)
209
- return "Image generated successfully", image_path
210
-
211
- if temperature > 3:
212
- return "You are too warm please try again", None
213
- else:
214
- text_answer = Chat_call(chat,temperature)
215
- return text_answer, None
216
 
217
  demo = gr.Interface(
218
  fn=greet,
219
  inputs=[
220
- "text",
221
- gr.Textbox(label="Image", lines=3),
222
- gr.Slider(label="Text temperature", value=1, minimum=0, maximum=2),
223
  gr.Slider(label="Age", value=22, minimum=18, maximum=75),
224
- gr.Dropdown(["asian", "white", "black", "latina"], label="Color", info="Will add more later!"),
225
- gr.Dropdown(["blond", "brune", "red", "white", "pink", "black", "blue", "green"], label="Hair color", info="Blond is cool"),
 
 
 
 
226
  gr.Checkbox(label="NSFW", info="πŸ‘€πŸ‘€πŸ‘€")
227
  ],
228
  flagging_options=["blurry", "incorrect", "other"],
 
3
  import time
4
  import requests
5
  import base64
6
+
7
 
8
 
9
 
 
15
  ##############################################################
16
  #################################################
17
 
18
+ def SD_call(prompt, image_prompt, weight, age, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW):
 
19
 
20
  positive = "clothes"
21
  negative = "naked, nsfw, porn"
 
29
  "Accept": "application/json",
30
  "Content-Type": "application/json"
31
  }
32
+
 
 
33
  if NSFW == True:
34
  positive = "naked, nsfw"
35
  negative = "clothes"
36
+
37
+ if prompt.strip():
38
+ total_prompt = prompt
39
+
40
+ else:
41
+ color = ", ".join(color)
42
+ skin_details = ", ".join(skin_details)
43
+ total_prompt = f"masterpiece, best quality, 8k, (looking at viewer:1.1), gorgeous, hot, seductive, {age} years old american {color} woman, {weight} kilos woman, (eye contact:1.1), beautiful face, hyper detailed, best quality, ultra high res, {hair_length} {hair_color} {hair_texture} hair,{eye_colors} eyes, {skin_details} photorealistic, high resolution, detailed, raw photo, 1girl,{image_prompt}, amateur cellphone photography. f8.0, samsung galaxy, noise, jpeg artefacts, poor lighting, low light, underexposed, high contrast "
44
+
45
+
46
+ # Define your data (this could also be a JSON payload)
47
+ print("SD_processing")
48
  data = {
49
  "input": {
50
  "api": {
 
59
  "override_settings_restore_afterwards": True,
60
  "refiner_checkpoint": "",
61
  "refiner_switch_at": 0.8,
62
+ "prompt": f"{total_prompt}, {positive}",
63
+ "negative_prompt": f"EasyNegative, fat, paintings, sketches, lowres, ((monochrome)), ((grayscale)), bad anatomy, text, error, cropped, signature, watermark, username, blurry, bad feet, poorly drawn face, bad proportions, gross proportions, ng_deepnegative_v1_75t, badhandsv5-neg, {negative}",
64
  "seed": -1,
65
  "batch_size": 1,
66
  "steps": 30,
 
122
 
123
 
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
+ def greet(prompt, image_prompt, weight, age, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW):
127
+ image_path = SD_call(prompt, image_prompt, weight, age, color, hair_color,hair_length,hair_texture,skin_details,eye_colors,NSFW)
128
+ return "Image generated successfully", image_path
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  demo = gr.Interface(
132
  fn=greet,
133
  inputs=[
134
+ gr.Textbox(label="Personal prompt", lines=3),
135
+ gr.Textbox(label="Girl_prompt", lines=3),
136
+ gr.Slider(label="Weight", value=55, minimum=40, maximum=150),
137
  gr.Slider(label="Age", value=22, minimum=18, maximum=75),
138
+ gr.CheckboxGroup(choices=["asian", "white", "black", "latina", "middle eastern","indigenous", "Mixed"],label="Color",type="value"),
139
+ gr.Radio(["black", "brown", "brunette", "dark brown", "light brown", "blonde", "dirty blonde", "platinum blonde", "red", "auburn", "ginger", "strawberry blonde", "gray", "silver", "white", "blue", "green", "purple", "pink", "rainbow", "multicolored"],label="Hair Color",type="value"),
140
+ gr.Radio(["short", "long", "mi-long"],label="Hair length", type="value"),
141
+ gr.Radio(["straight", "curvy", "wavy"],label="Hair texture", type="value"),
142
+ gr.CheckboxGroup(choices=["((tattoos))", "((birthmark))", "freckles", "((scars))"],label="Skin details", type="value"),
143
+ gr.Radio(["short", "hazel", "green", "blue", "gray", "amber", "black", "red", "violet"],label="Eye Color", type="value"),
144
  gr.Checkbox(label="NSFW", info="πŸ‘€πŸ‘€πŸ‘€")
145
  ],
146
  flagging_options=["blurry", "incorrect", "other"],