File size: 1,815 Bytes
f0e8178
 
 
 
 
 
e8d24b2
f0e8178
e8d24b2
f0e8178
e7e1126
 
 
 
f0e8178
e8d24b2
 
 
 
 
7549030
e8d24b2
 
 
 
 
 
e7e1126
e8d24b2
 
 
 
e7e1126
e8d24b2
e7e1126
e8d24b2
 
f0e8178
 
e8d24b2
f0e8178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428511e
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
from asyncio import constants
import gradio as gr
import re



demo = gr.Blocks()

with demo:

  ds_iface = gr.Interface.load("spaces/artificialguybr/DREAMSHAPER-XL-FREE-DEMO")

  es_iface = gr.Interface.load("spaces/akhaliq/Real-ESRGAN")
      

  def desc_to_image(desc):
      print("*****Inside desc_to_image")
      desc = " ".join(desc.split('\n'))
      #desc = desc + ", character art, concept art, artstation"
      steps, width, height, images, diversity = '50','256','256','1',15
      print("about to die",ds_iface,dir(ds_iface))
    
      prompt = re.sub(r'[^a-zA-Z0-9 ,.]', '', desc)
      print("about to die",prompt)
    
    
      #img=iface(desc, steps, width, height, images, diversity)[0]
      img=ds_iface(desc)[0]
      return img
    
    
  def upscale_img(img):
        
        model='base'
        uimg=es_iface(img,models)
        return uimg
    


    
  gr.Markdown("<h1><center>NPC Generator</center></h1>")
  gr.Markdown(
        "<div>Run <a href='https://huggingface.co/spaces/multimodalart/latentdiffusion'>Latent Diffusion</a> first to generate an image</div>"
        "<div>Then upscale with <a href='https://huggingface.co/spaces/akhaliq/Real-ESRGAN/blob/main/app.py'>ESRGAN</a></div>"
    )
  
  with gr.Row():
    b0 = gr.Button("generate")
    b1 = gr.Button("upscale")
  
  with gr.Row():  
    desc = gr.Textbox(label="description",placeholder="an impressionist painting of a white vase")
    
  with gr.Row():
    intermediate_image = gr.Image(label="portrait",type="filepath", width=256,height=256)
    output_image = gr.Image(label="portrait",type="filepath", width=256,height=256)
  
  b0.click(desc_to_image,inputs=[desc],outputs=[intermediate_image])
  b1.click(upscale_img, inputs=[ intermediate_image], outputs=output_image)
  #examples=examples

demo.launch()