Download api/core/app.py from coder160/gpu_machine_learner: direct link, hf CLI and curl.
- Browser
- Download file 3.44 kB
-
https://huggingface.co/spaces/coder160/gpu_machine_learner/resolve/603152bc8f7eaa6e1c95f0e24e684426b7ba2bd1/api/core/app.py
- Command line
-
hf download hf://spaces/coder160/gpu_machine_learner@603152bc8f7eaa6e1c95f0e24e684426b7ba2bd1/api/core/app.py
-
curl -L -o app.py https://huggingface.co/spaces/coder160/gpu_machine_learner/resolve/603152bc8f7eaa6e1c95f0e24e684426b7ba2bd1/api/core/app.py
3.44 kB
| class Demos: | |
| def __init__(self): | |
| from fastapi import FastAPI, HTTPException, Response, File | |
| self.api = FastAPI | |
| self.exception = HTTPException | |
| self.api_response = Response | |
| self.fileupload = File | |
| def validate_apikey(self,api_key)->bool: | |
| __validation = True | |
| return __validation | |
| def text_to_img(texto:str=None, model:str="PROMPTHERO")->bytes: | |
| """Genera un Bytes de la imagen con el texto dado. | |
| args: | |
| texto (str) : Texto para generar imagen | |
| return: | |
| _img (bytes) : Imagen en Bytes | |
| """ | |
| from api.core.controllers.text2image import Generador | |
| _imagen = str() | |
| if "RUNWAY" in model.upper(): | |
| _imagen = Generador.using_runway_sd_15(prompt=texto) | |
| elif "STABILITY" in model.upper(): | |
| _imagen = Generador.using_stability_sd_21(prompt=texto) | |
| elif "REALISTIC" in model.upper(): | |
| _imagen = Generador.using_realistic_v14(prompt=texto) | |
| elif "PROMPTHERO" in model.upper(): | |
| _imagen = Generador.using_prompthero_openjourney(prompt=texto) | |
| else: | |
| _imagen = bytes("error", 'utf-8') | |
| return _imagen | |
| def text_to_video(texto:str=None)->str: | |
| """Genera un BITARRAY del video con el texto dado. | |
| args: | |
| texto (str) : Texto para generar video | |
| return: | |
| _video (str) : Video en BITARRAY | |
| """ | |
| _video = str() | |
| return _video | |
| def text_to_speach(texto:str=None)->str: | |
| """Genera un BITARRAY del audio con el texto dado. | |
| args: | |
| texto (str) : Texto para generar audio | |
| return: | |
| _speach (str) : Audio en BITARRAY | |
| """ | |
| _speach = str() | |
| return _speach | |
| def image_to_image(task:str="MSLD", image:str=None, mask:str=None,**kwargs)->str: | |
| """Genera una imagen a partir de una imagen | |
| args: | |
| task (str) : Modelo a utilizar: MSLD, DEEP, SCRIBLE, etc.. | |
| image (str) : Input Image | |
| mask (str) : Mask Image | |
| **kwargs (str) : Argumentos adicionales: inference, strnght, guidance... | |
| return: | |
| _image (str) : Imagen en BITARRAY | |
| """ | |
| _image = str() | |
| return _image | |
| def img_to_img(texto:str=None, model:str="PROMPTHERO")->bytes: | |
| """Genera un Bytes de la imagen con el texto dado. | |
| args: | |
| texto (str) : Texto para generar imagen | |
| return: | |
| _img (bytes) : Imagen en Bytes | |
| """ | |
| from api.core.controllers.text2image import Generador | |
| _imagen = str() | |
| if "RUNWAY" in model.upper(): | |
| _imagen = Generador.using_runway_sd_15(prompt=texto) | |
| elif "STABILITY" in model.upper(): | |
| _imagen = Generador.using_stability_sd_21(prompt=texto) | |
| elif "REALISTIC" in model.upper(): | |
| _imagen = Generador.using_realistic_v14(prompt=texto) | |
| elif "PROMPTHERO" in model.upper(): | |
| _imagen = Generador.using_prompthero_openjourney(prompt=texto) | |
| else: | |
| _imagen = bytes("error", 'utf-8') | |
| return _imagen | |