lovelyai999's picture
Upload app.py
e88ce07 verified
raw
history blame contribute delete
No virus
13.4 kB
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()