File size: 8,800 Bytes
1651159 122624a 1651159 122624a 92c854e 122624a 913877b 122624a a3d7f6f 913877b a3d7f6f 92c854e a3d7f6f cd48491 1651159 122624a 92c854e 98f91a8 122624a 913877b 122624a 913877b 122624a c5ae403 122624a c5ae403 a509d24 122624a 913877b 122624a 913877b 122624a 92c854e 913877b 92c854e c5ae403 913877b c5ae403 913877b c5ae403 913877b c5ae403 913877b c5ae403 1651159 f062dc3 eba05c5 913877b eba05c5 913877b eba05c5 913877b eba05c5 913877b a3d7f6f 913877b a3d7f6f 913877b eba05c5 a3d7f6f 913877b a3d7f6f 913877b a3d7f6f 913877b a3d7f6f 913877b a3d7f6f 913877b |
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 |
import herramientas
import time
import databank
from fastapi.responses import FileResponse
async def crea_partynight(image, outfit_color):
endpoint = 'partynight'
try:
prompt = databank.obtenPrompt(endpoint, outfit_color=outfit_color) #Van a tener que ser kwargs porque variará de lo recibido de ep a ep.
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt)
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint)) #Usa el prompt como nombre en dev para info más rica, endpoint para usuario final.
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error 182: {e}")
return {"error": e}
async def crea_babydoll(image, outfit_color):
endpoint = 'babydoll'
try:
prompt = databank.obtenPrompt(endpoint, outfit_color=outfit_color)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt)
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_leather(image):
endpoint = 'leather'
try:
prompt = databank.obtenPrompt(endpoint)
print("Prompt final: ", prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt)
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_stewardess(image, outfit_color):
endpoint = 'stewardess'
try:
prompt = databank.obtenPrompt(endpoint, outfit_color=outfit_color)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_oktoberfest(image):
endpoint = 'oktoberfest'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_ghibli(image):
endpoint = 'ghibli'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_wildwest(image):
endpoint = 'wildwest'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_bride(image):
endpoint = 'bride'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_swimsuit(image, outfit_color):
endpoint = 'swimsuit'
try:
prompt = databank.obtenPrompt(endpoint, outfit_color=outfit_color)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(endpoint))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_lingerie(image):
endpoint = 'lingerie'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(prompt))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_schooluniform(image):
endpoint = 'schooluniform'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(prompt))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_frenchmaid(image):
endpoint = 'frenchmaid'
try:
prompt = databank.obtenPrompt(endpoint)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(prompt))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."}
async def crea_cheerleader(image, color, hairstyle):
endpoint = 'cheerleader'
try:
prompt = databank.obtenPrompt(endpoint, outfit_color=color, hair_style = hairstyle)
print(prompt)
resultado = await herramientas.exeCute(endpoint, image, prompt) #execute ya debe recibir prompt hecho.
if type(resultado) is str:
return FileResponse(resultado, media_type="image/jpg", filename=herramientas.formaFilename(prompt))
elif type(resultado) is dict:
return resultado
except Exception as e:
print(f"Error: {e}")
return {"error": "Unable to detect a face in the image. Please upload a different photo with a clear face."} |