denees_k

Untitled

Jul 29th, 2023
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.00 KB | None | 0 0
  1. base_prompt = {
  2.     'model_id': 'sdxl',
  3.     'init_image': '',
  4.     'mask_image': None,
  5.     'control_image': None,
  6.     'width': '512',
  7.     'height': '512',
  8.     'prompt': '',
  9.     'guess_mode': None,
  10.     'use_karras_sigmas': None,
  11.     'tomesd': None,
  12.     'vae': 'sd-ft-mse',
  13.     'embeddings': None,
  14.     'lora_strength': None,
  15.     'multi_lingual': None,
  16.     'upscale': None,
  17.     'strength': 1,
  18.     'negative_prompt': 'high contrast, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, low resolution, 3d model, deformed hands, deformed feet, deformed face, deformed body parts, same haircut, eyes without pupils, doubled image, mid aged man, old men, logo in frame, gun, man with more than one penis on body, scared facial expression, drawing, painting, blur focus, blur, photo effects, skinny guy, make-up on male, angry facial expression, same human face in one frame, illustration, anime, cartoon, ugly face, bruises, cartoon, anime, painting, red color saturation, unattractive face, jpeg artifacts, frame, Violence, Gore, Blood, War, Weapons, Death, Destruction, Fire, Explosions, Pollution, Garbage, Graffiti, Vandalism, Rust, Decay, Filth, Disease, Insects, Rodents, Vermin, Darkness, Shadows, Nightmares, Fear, Horror, Sadness, Depression, Pain, Suffering, Anguish, Despair, Loneliness, Isolation, Neglect, Abandonment, Negativity, Hate, Racism, Sexism, Homophobia, Discrimination, Intolerance, Prejudice, Ignorance, Arrogance, Greed, Selfishness, Cruelty, Insanity, Madness, lowres, text, error, cropped, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, out of frame, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck, deformed, ugly, mutilated, disfigured, text, extra limbs, face cut, head cut, extra fingers, extra arms, poorly drawn face, mutation, bad proportions, cropped head, malformed limbs, mutated hands, fused fingers, long neck, illustration, painting, drawing, art, sketch, disfigured, kitsch, ugly, oversaturated, grain, low-res, Deformed, blurry, bad anatomy, disfigured, poorly drawn face, mutation, mutated, extra limb, ugly, poorly drawn hands, missing limb, blurry, floating limbs, disconnected limbs, malformed hands, blur, out of focus, long neck, long body, ugly, disgusting, poorly drawn, childish, mutilated, , mangled, old, surreal',  # noqa
  19.     'guidance': '10',
  20.     'samples': '1',
  21.     'safety_checker': 'yes',
  22.     'auto_hint': 'yes',
  23.     'steps': 20,
  24.     'seed': 27582,
  25.     'webhook': None,
  26.     'track_id': None,
  27.     'scheduler': 'EulerAncestralDiscreteScheduler',
  28.     'base64': None,
  29.     'clip_skip': None,
  30.     'controlnet_conditioning_scale': None,
  31.     'temp': None,
  32.     'controlnet_type': None,
  33.     'controlnet_model': 'softedge',
  34.     'lora': ''
  35. }
  36.  
  37. loras_types = {
  38.     'ghibli style': {
  39.         'lora': 'ghibli-style'
  40.     },
  41.     'naruto style, a ninja': {
  42.         'lora': 'naruto-oneai'
  43.     },
  44.     'anime style, 2d, masterpiece': {
  45.         'lora': ''
  46.     },
  47.     'kimetsu no yaiba style': {
  48.         'lora': 'vampire-killer'
  49.     },
  50.     'toriyama akira': {
  51.         'lora': 'akira-toriyama'
  52.     },
  53.     'wanostyle': {
  54.         'lora': 'wanostyle'
  55.     },
  56. }
  57.  
  58.  
  59. async def sdf_request(prompt: str, photo: str) -> dict:
  60.     lora = loras_types.get(prompt, {}).get('lora', '')
  61.     base_prompt['key'] = os.environ.get('STABILITY_KEY')
  62.     base_prompt['prompt'] = prompt
  63.     base_prompt['init_image'] = photo
  64.     base_prompt['seed'] = randint(1, 30000)
  65.     base_prompt['lora'] = lora
  66.     async with ClientSession() as session:
  67.         response = await session.post(url_stable,
  68.                                       headers=headers_stable,
  69.                                       data=json.dumps(base_prompt))
  70.         body = await response.json()
  71.         logger.debug(body)
  72.         response.close()
  73.     if body['status'] == 'processing':
  74.         while body['status'] == 'processing':
  75.             data = {'key': os.environ.get('STABILITY_KEY'),
  76.                     'request_id': body['id']}
  77.             async with ClientSession() as session:
  78.                 response = await session.post(url_stable,
  79.                                               headers=headers_stable,
  80.                                               data=json.dumps(data))
  81.                 logger.debug(body)
  82.                 body = await response.json()
  83.                 response.close()
  84.     if body['status'] == 'failed':
  85.         return {}
  86.     return {'photo_url': body['output'][0],
  87.             'prompt': base_prompt,
  88.             'generation_time': body['generationTime']}
Add Comment
Please, Sign In to add comment