update main
Browse files- api/core/controllers/text2image.py +1 -0
- api/main.py +4 -4
api/core/controllers/text2image.py
CHANGED
|
@@ -44,6 +44,7 @@ class Generador:
|
|
| 44 |
_imagen = _generador(prompt).images[0]
|
| 45 |
_response = Generador.img_to_bytes(img=_imagen)
|
| 46 |
except Exception as e:
|
|
|
|
| 47 |
_response = bytes(str(e), 'utf-8')
|
| 48 |
finally:
|
| 49 |
return _response
|
|
|
|
| 44 |
_imagen = _generador(prompt).images[0]
|
| 45 |
_response = Generador.img_to_bytes(img=_imagen)
|
| 46 |
except Exception as e:
|
| 47 |
+
print(e)
|
| 48 |
_response = bytes(str(e), 'utf-8')
|
| 49 |
finally:
|
| 50 |
return _response
|
api/main.py
CHANGED
|
@@ -83,13 +83,13 @@ def get_resumen(data:dict) -> dict:
|
|
| 83 |
return __response
|
| 84 |
|
| 85 |
@api.post("/texto_a_imagen/", status_code=201, responses = {201: {"content": {"image/png": {}}}} ,response_class=__main.api_response)
|
| 86 |
-
def get_text2img(data:dict)
|
| 87 |
__response=dict({"request_data":data})
|
| 88 |
try:
|
| 89 |
if data and 'texto' in data and 'modelo' in data:
|
| 90 |
__response['original']= data.get('texto')
|
| 91 |
-
|
| 92 |
-
|
| 93 |
else:
|
| 94 |
raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
|
| 95 |
except Exception as e:
|
|
@@ -97,7 +97,7 @@ def get_text2img(data:dict) -> dict:
|
|
| 97 |
#To-do ->agregar mas información en el error fecha, usuario, reqs
|
| 98 |
raise __main.exception(status_code = 403, datail=str(e))
|
| 99 |
finally:
|
| 100 |
-
return __main.api_response(content=
|
| 101 |
|
| 102 |
@api.post("/texto_a_video/", status_code=201)
|
| 103 |
def get_text2video(data:dict) -> dict:
|
|
|
|
| 83 |
return __response
|
| 84 |
|
| 85 |
@api.post("/texto_a_imagen/", status_code=201, responses = {201: {"content": {"image/png": {}}}} ,response_class=__main.api_response)
|
| 86 |
+
def get_text2img(data:dict):
|
| 87 |
__response=dict({"request_data":data})
|
| 88 |
try:
|
| 89 |
if data and 'texto' in data and 'modelo' in data:
|
| 90 |
__response['original']= data.get('texto')
|
| 91 |
+
__image = __main.text_to_img(texto=data.get('texto'),
|
| 92 |
+
model=data.get('modelo'))
|
| 93 |
else:
|
| 94 |
raise __main.exception(status_code = 401, datail=f"Datos mal formados:\n{data}")
|
| 95 |
except Exception as e:
|
|
|
|
| 97 |
#To-do ->agregar mas información en el error fecha, usuario, reqs
|
| 98 |
raise __main.exception(status_code = 403, datail=str(e))
|
| 99 |
finally:
|
| 100 |
+
return __main.api_response(content=__image, media_type="image/png")
|
| 101 |
|
| 102 |
@api.post("/texto_a_video/", status_code=201)
|
| 103 |
def get_text2video(data:dict) -> dict:
|