coder160 commited on
Commit
65ea99e
1 Parent(s): 603152b

method name

Browse files
Files changed (2) hide show
  1. api/core/controllers/text2image.py +15 -2
  2. api/main.py +1 -1
api/core/controllers/text2image.py CHANGED
@@ -1,4 +1,4 @@
1
- from diffusers import DiffusionPipeline as Pipe
2
  import torch
3
 
4
  class Generador:
@@ -48,4 +48,17 @@ class Generador:
48
  _response = bytes(str(e), 'utf-8')
49
  finally:
50
  return _response
51
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import ControlNetModel, StableDiffusionControlNetPipeline, DiffusionPipeline as Pipe
2
  import torch
3
 
4
  class Generador:
 
48
  _response = bytes(str(e), 'utf-8')
49
  finally:
50
  return _response
51
+ class Difusor:
52
+ def using_runway_sd_15(prompt:str)->bytes:
53
+ try:
54
+ controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-mlsd")
55
+ _generador = StableDiffusionControlNetPipeline.from_pretrained(
56
+ "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16)
57
+ _generador.to("cuda")
58
+ _imagen = _generador(prompt).images[0]
59
+ _response = bytes(Generador.img_to_bytes(image=_imagen))
60
+ except Exception as e:
61
+ print(e)
62
+ _response = bytes(str(e), 'utf-8')
63
+ finally:
64
+ return _response
api/main.py CHANGED
@@ -54,7 +54,7 @@ def get_text2speach(data:dict) -> dict:
54
 
55
 
56
  @api.post("/imagen_a_imagen/", status_code=201, responses = {201: {"content": {"image/png": {}}}} ,response_class=__main.api_response)
57
- def get_text2img(data:dict, file: bytes = __main.fileupload()):
58
  __response=dict({"request_data":data})
59
  try:
60
  if data and 'texto' in data and 'modelo' in data and file is not None:
 
54
 
55
 
56
  @api.post("/imagen_a_imagen/", status_code=201, responses = {201: {"content": {"image/png": {}}}} ,response_class=__main.api_response)
57
+ def get_img2img(data:dict, file: bytes = __main.fileupload()):
58
  __response=dict({"request_data":data})
59
  try:
60
  if data and 'texto' in data and 'modelo' in data and file is not None: