File size: 13,430 Bytes
cbbbc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431511b
cbbbc7e
 
 
 
 
 
 
 
 
 
 
 
 
ca38e8d
ca58f2b
cbbbc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0819da6
 
cbbbc7e
0819da6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cbbbc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e88ce07
cbbbc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72adcd7
cbbbc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2be00c
cbbbc7e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297

try:
  import google.colab
  IN_COLAB = True
  from google.colab import drive
  from google.colab import output
  drive.mount('/gdrive')
  Gbase="/gdrive/MyDrive/generate/"
  cache_dir="/gdrive/MyDrive/hf/"
  import sys
  sys.path.append(Gbase)
except:
  IN_COLAB = False
  Gbase="./generate/"
  cache_dir="./hf/"

import time,os,json
hexStamp=lambda :hex(time.time_ns())[2:]
from women1 import randomAction,randomWoman,Woman,woman_description,womanPrompt,ToWomanPrompt,WomanFromString,Translator,TranslatorS,TranslatorC2E,womanPromptUI
from man import randomActionMan,randomMan,Man,man_description,manPrompt,ToManPrompt,ManFromString,manPromptUI,randManWoman
from pets import randomActionAnimal,randomAnimal,Animal,pet_description,animalPrompt,ToAnimalPrompt,AnimalFromString,animalPromptUI,randAnimalWoman,randAnimalMan
from places import randomActionPlace,randomPlace,Place,place_description,placePrompt,ToPlacePrompt,PlaceFromString,placePromptUI

from fileDict3 import FileDict
from fileSQL3 import FileSQL3






os.makedirs(Gbase, exist_ok=True)




import gradio as gr
from gradio.context import Context
from gradio import Request


def persist(component):
    sessions = {}

    def resume_session(value, request: Request):
        return sessions.get(request.username, value)

    def update_session(value, request: Request):
        sessions[request.username] = value

    Context.root_block.load(resume_session, inputs=[component], outputs=component)
    component.change(update_session, inputs=[component])

    return component


sampPrompts=[
"A  beautiful young office lady with blonde luxurious long hair and blue beautiful eyes,clear fine eyes , beautiful black pupil , phantom eyebrows,bloom shiny skin , curvaceous hot body ,casual wear,lardge breasts , eyes contact , confident , determined .",
"A sweet pretty woman with blonde luxurious hair and blue bright eyes,curvaceous hot body , lardge breasts , shiny bloom skin ,romantic .",
"A  beautiful young office lady with black luxurious short hair and golden beautiful eyes,clear fine eyes , beautiful black pupil , phantom eyebrows,bloom shiny skin , curvaceous hot body ,elegant wear,lardge breasts , eyes contact , confident , determined .",
"A  beautiful young office lady with golden vogue short hair and blue beautiful eyes,clear fine eyes , beautiful black pupil , phantom eyebrows,oily shiny skin , curvaceous hot body ,casual wear , eyes contact , confident , determined .",
"A  beautiful slim girl with black luxurious hair and golden beautiful #eyes,clear fine eyes , beautiful black pupil , phantom eyebrows,oily smoothly skin , curvaceous hot body ,vogue wear , eyes contact , confident , determined .",
"A  beautiful slim girl with blonde luxurious hair and blue beautiful eyes,clear fine eyes , beautiful golden pupil , phantom eyebrows,oily shiny skin , curvaceous hot body , eyes contact , confident , determined .",
"A  beautiful slim girl with black luxurious hair and golden beautiful eyes,clear fine eyes , beautiful black pupil , phantom eyebrows,oily smoothly skin , curvaceous hot body ,vogue wear , eyes contact , confident , determined .",
"Create an image of a stunning woman with flowing black hair, captivating eyes, and an enchanting smile. She radiates elegance and confidence, and her beauty is mesmerizing. The background complements her features, enhancing her allure. The image captures her in a moment of grace and poise, expressing her unique charm and vibrant personality.",
"Create an image of a stunning woman with flowing blonde hair, captivating blue eyes, and an enchanting smile. She radiates elegance and confidence, and her beauty is mesmerizing. The background complements her features, enhancing her allure. The image captures her in a moment of grace and poise, expressing her unique charm and vibrant personality.",
"A  beautiful slim girl with blonde luxurious hair and blue bright eyes,clear fine eyes ,beautiful blue eyes , phantom eyebrows,oily shiny skin , curvaceous hot body , eyes contact , confident , determined ,from side ,smile .",
"A  beautiful slim girl with blonde luxurious hair and blue bright eyes , phantom eyebrows,oily shiny skin , beautiful bright eyes ,  , curvaceous hot body , eyes contact , confident , determined ,from side .,smile . " ,
"A  beautiful slim girl with blonde luxurious hair and blue bright eyes , phantom eyebrows,oily shiny skin , beautiful bright eyes  , curvaceous hot body , eyes contact , confident , determined ,from side ,smile .",
"A  beautiful slim girl with blonde luxurious hair and blue bright eyes , phantom eyebrows,oily shiny skin , beautiful bright eyes ,  , curvaceous hot body , eyes contact , confident , determined ,from side .,smile . " ,
"A  beautiful office lady with  black hair and red eyes , phantom eyebrows,oily shiny skin , beautiful bright eyes ,  stylish vogue hair , curvaceous hot body , eyes contact , confident , determined ,from side . " ,
"A pretty young office woman , beautiful blue bright  eyes ,lardge breasts , smile , beautiful face .",
"A very beautiful woman, shiny blonde hair, deep blue bright eyes, perfect figure,, hot clothing , smooth and shiny skin,lardge breasts, fantastic body,very beautiful perfect face,from side,eye contact .",
]
promptIndex=0

def initPrompt():
    global Gbase,sampPrompts
    pPath=os.path.join(Gbase ,"mypromts.txt")
    if os.path.exists (pPath):
        sampPrompts=json.load(open(pPath))
    else:
        with open(pPath,"w" ) as jFile:json.dump(sampPrompts,jFile)

def savePrompt(p):
    global Gbase,sampPrompts,promptIndex
    initPrompt()
    if promptIndex==-1:
        sampPrompts.insert(0,p)
        promptIndex=0
    else:sampPrompts[promptIndex]=p
    pPath=os.path.join(Gbase ,"mypromts.txt")
    with open(pPath,"w" ) as jFile:
        json.dump(sampPrompts,jFile)
    return "saved"
def deletePrompt(p):
    global Gbase,sampPrompts,promptIndex
    if promptIndex==-1:
        promptIndex=0
        return sampPrompts[0]
    try: sampPrompts.pop(sampPrompts.index(p))
    except:pass
    pPath=os.path.join(Gbase ,"mypromts.txt")
    with open(pPath,"w" ) as jFile:
        json.dump(sampPrompts,jFile)
    return sampPrompts[promptIndex]


initPrompt()
currentWoman=randomWoman()
def randPrompt():
    global promptIndex
    promptIndex=-1
    return randomWoman()
def randPromptUI():
    global promptIndex,currentWoman
    promptIndex=-1
    w=WomanFromString(str(randomWoman()))
    currentWoman=w
    return str(w)
def randPromptMan():
    global promptIndex
    promptIndex=-1
    return randomMan()

def randPromptAnimal():
    global promptIndex
    promptIndex=-1
    return randomAnimal()
def randPromptPlace():
    global promptIndex
    promptIndex=-1
    return randomPlace()


def randPromptManWoman():
    global promptIndex
    promptIndex=-1
    return randManWoman()

def randPromptAnimalWoman():
    global promptIndex
    promptIndex=-1
    return randAnimalWoman()

def randPromptAnimalMan():
    global promptIndex
    promptIndex=-1
    return randAnimalMan()

def randPromptUIman():
    global promptIndex,currentMan
    promptIndex=-1
    w=ManFromString(str(randomMan()))
    currentMan=w
    return str(w)    

def randPromptUIplace():
    global promptIndex,currentPlace
    promptIndex=-1
    w=PlaceFromString(str(randomPlace()))
    currentPlace=w
    return str(w)    
def randPromptUIAnimal():
    global promptIndex,currentAnimal
    promptIndex=-1
    w=AnimalFromString(str(randomAnimal()))
    currentAnimal=w
    return str(w)    

def nextPrompt():
    global promptIndex
    promptIndex+=1
    if promptIndex>=len(sampPrompts):promptIndex=0
    return sampPrompts[promptIndex]

def previousPrompt():
    global promptIndex
    promptIndex-=1
    if promptIndex<0:promptIndex=0
    return sampPrompts[promptIndex]

def textToConfig(s):
    w=WomanFromString(s)
    return [w.character,w.eye_color,w.hair_style,w.hair_color,w.dress_styles,w.skin,w.body,w.breast_size,w.hip_measurements,w.action,w.additional,w.dress_upper]

def restConfig():return ["random"]*12
prompt=sampPrompts[0]


def changeRandomActions(b):
    global randomActions
    randomActions=b
    return randomActions

def changeRandomActionsMan(b):
    global randomActionsMan
    randomActionsMan=b
    return randomActionsMan




description ="""<div style="font-family: Arial, sans-serif; padding: 20px;">
Free and open source, you are welcome to use or modify the code according to your needs.

  <h2>🔗My social media links❤️</h2>

Follow <a href="https://www.facebook.com/braiml"  ytarget="_blank">🐍Brian's Page </a> if you want I share more tools .<br>
Follow<a href="https://www.facebook.com/charactersAI" target="_blank">❤️Characters AI</a>
 if you want more  videos .
<br>
  <a href="https://www.facebook.com/brian.pyai" target="_blank"> 📘facebook.com/brian.pyai</a>
 <br>
  <a href="https://www.facebook.com/braiml" target="_blank">🐍Brian's Page </a>
<br>

  <a href="https://www.facebook.com/lovelyai999" target="_blank">🥰AI Hot Shorts </a>



</div>

"""

css=""".gradio-container {max-width: 544px !important}

"""
css1="""
img {
  opacity: 0; /* Optional: Initial hidden state */
}

img[loading="lazy"] {
  opacity: 1; /* Optional: Show the image when it becomes visible */
}
"""

with gr.Blocks(title="Images Prompts Generator", css=css) as demo:
    with gr.Row():gr.HTML(value=description)
    with gr.Row():
      with gr.Column():
          textbox = persist(gr.Textbox(show_label=True , label ="prompt",show_copy_button=True ))
          genWoman= gr.Button(value="Woman")
          toConfig= gr.Button(value="To config")
          bRestConfig= gr.Button(value="Rest config")
          rptsP = gr.Button(value="Previous")
          rpts = gr.Button(value="Next")
          rptsRandom = gr.Button(value="RandomWoman")
          rptsRandomMan = gr.Button(value="RandomMan")
          rptsRandomAnimal= gr.Button(value="RandomAnimal")
          rptsRandomManWoman= gr.Button(value="Random Man+Woman ")
          rptsRandomAnimalWoman= gr.Button(value="Random Animal+Woman ")
          rptsRandomAnimalMan= gr.Button(value="Random Animal+Man")
          rptsRandomPlace= gr.Button(value="Random Place ")
          rptsSave = gr.Button(value="Save")
          rptsDelete = gr.Button(value="Delete")
          character= persist(gr.Dropdown(woman_description["character"],label="character",value ="None",allow_custom_value=True ,show_label=True))
          eye_color= persist(gr.Dropdown(woman_description["eye_color"],label="eye_color",value ="None" ,allow_custom_value=True,show_label=True))
          hair_style= persist(gr.Dropdown(woman_description["hair_style"],label="hair_style",value ="None" ,allow_custom_value=True,show_label=True))
          hair_color= persist(gr.Dropdown(woman_description["hair_color"],label="hair_color",value ="None" ,allow_custom_value=True,show_label=True))
          dress_upper= persist(gr.Dropdown(woman_description["dress_upper"][:50],label="dress_upper",value ="None" ,allow_custom_value=True,show_label=True))
          dress_styles= persist(gr.Dropdown(woman_description["dress_styles"][:50],label="dress_styles",value ="None" ,allow_custom_value=True,show_label=True))
          skinT= persist(gr.Dropdown(woman_description["skin"],label="skin",value ="None" ,allow_custom_value=True,show_label=True))
          bodyT= persist(gr.Dropdown(woman_description["body"],label="body",value ="None" ,allow_custom_value=True,show_label=True))
          breast_size= persist(gr.Dropdown(woman_description["breast_size"],label="breast_size",value ="None" ,allow_custom_value=True,show_label=True))
          hip_measurements= persist(gr.Dropdown(woman_description["hip_measurements"],label="hip_measurements",value ="None" ,allow_custom_value=True,show_label=True))
          actionT= persist(gr.Dropdown(woman_description["action"][:50],label="action",value ="None" ,allow_custom_value=True,show_label=True))
          additionalT= persist(gr.Dropdown(woman_description["additional"],label="additional",value ="None" ,allow_custom_value=True,show_label=True))    
    
    rptsP.click(fn=previousPrompt,outputs=textbox)
    genWoman.click(fn=womanPromptUI,inputs=[ character, eye_color , hair_style , hair_color , dress_styles , skinT , bodyT , breast_size , hip_measurements , actionT , additionalT,dress_upper],outputs=textbox)
    rptsRandom.click(fn=randPromptUI,outputs=textbox)
    rptsRandomMan.click(fn=randPromptUIman
,outputs=textbox)
    rptsRandomManWoman.click(fn=randPromptManWoman
,outputs=textbox)
    
    rptsRandomAnimal.click(fn=randPromptUIAnimal
,outputs=textbox)
    rptsRandomAnimalWoman.click(fn=randPromptAnimalWoman
,outputs=textbox)
    rptsRandomAnimalMan.click(fn=randPromptAnimalMan
,outputs=textbox)
    rptsRandomPlace.click(fn=randPromptPlace
,outputs=textbox) 
    bRestConfig.click(fn=restConfig,outputs=[ character, eye_color , hair_style , hair_color , dress_styles , skinT , bodyT , breast_size , hip_measurements , actionT , additionalT,dress_upper] )
    toConfig.click(fn=textToConfig,inputs=textbox,outputs=[ character, eye_color , hair_style , hair_color , dress_styles , skinT , bodyT , breast_size , hip_measurements , actionT , additionalT,dress_upper] )
    rpts.click(fn=nextPrompt,outputs=textbox)
    
    rptsSave.click(fn=savePrompt,inputs=textbox)
    rptsDelete.click(fn=deletePrompt,inputs=textbox ,outputs=textbox)
    


demo.launch()