nagolinc commited on
Commit
f0e8178
1 Parent(s): 2995009

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -53
app.py CHANGED
@@ -1,54 +1,54 @@
1
- from asyncio import constants
2
- import gradio as gr
3
- import re
4
-
5
-
6
- def desc_to_image(desc):
7
- print("*****Inside desc_to_image")
8
- desc = " ".join(desc.split('\n'))
9
- #desc = desc + ", character art, concept art, artstation"
10
- steps, width, height, images, diversity = '50','256','256','1',15
11
- iface = gr.Interface.load("spaces/multimodalart/latentdiffusion")
12
- print("about to die",iface,dir(iface))
13
-
14
- prompt = re.sub(r'[^a-zA-Z0-9 ,.]', '', desc)
15
- print("about to die",prompt)
16
-
17
-
18
- img=iface(desc, steps, width, height, images, diversity)[0]
19
- return img
20
-
21
-
22
- def upscale_img(img):
23
- iface = gr.Interface.load("spaces/akhaliq/Real-ESRGAN")
24
- model='base'
25
- uimg=iface(img,models)
26
- return uimg
27
-
28
-
29
-
30
- demo = gr.Blocks()
31
-
32
- with demo:
33
- gr.Markdown("<h1><center>NPC Generator</center></h1>")
34
- gr.Markdown(
35
- "<div>Run <a href='https://huggingface.co/spaces/multimodalart/latentdiffusion'>Latent Diffusion</a> first to generate an image</div>"
36
- "<div>Then upscale with <a href='https://huggingface.co/spaces/akhaliq/Real-ESRGAN/blob/main/app.py'>ESRGAN</a></div>"
37
- )
38
-
39
- with gr.Row():
40
- b0 = gr.Button("generate")
41
- b1 = gr.Button("upscale")
42
-
43
- with gr.Row():
44
- desc = gr.Textbox(label="description",placeholder="an impressionist painting of a white vase")
45
-
46
- with gr.Row():
47
- intermediate_image = gr.Image(label="portrait",type="filepath", shape=(256,256))
48
- output_image = gr.Image(label="portrait",type="filepath", shape=(256,256))
49
-
50
- b0.click(desc_to_image,inputs=[desc],outputs=[intermediate_image])
51
- b1.click(upscale_img, inputs=[ intermediate_image], outputs=output_image)
52
- #examples=examples
53
-
54
  demo.launch(enable_queue=True, debug=True)
 
1
+ from asyncio import constants
2
+ import gradio as gr
3
+ import re
4
+
5
+
6
+ def desc_to_image(desc):
7
+ print("*****Inside desc_to_image")
8
+ desc = " ".join(desc.split('\n'))
9
+ #desc = desc + ", character art, concept art, artstation"
10
+ steps, width, height, images, diversity = '50','256','256','1',15
11
+ iface = gr.Interface.load("spaces/multimodalart/latentdiffusion")
12
+ print("about to die",iface,dir(iface))
13
+
14
+ prompt = re.sub(r'[^a-zA-Z0-9 ,.]', '', desc)
15
+ print("about to die",prompt)
16
+
17
+
18
+ img=iface(desc, steps, width, height, images, diversity)[0]
19
+ return img
20
+
21
+
22
+ def upscale_img(img):
23
+ iface = gr.Interface.load("spaces/akhaliq/Real-ESRGAN")
24
+ model='base'
25
+ uimg=iface(img,models)
26
+ return uimg
27
+
28
+
29
+
30
+ demo = gr.Blocks()
31
+
32
+ with demo:
33
+ gr.Markdown("<h1><center>NPC Generator</center></h1>")
34
+ gr.Markdown(
35
+ "<div>Run <a href='https://huggingface.co/spaces/multimodalart/latentdiffusion'>Latent Diffusion</a> first to generate an image</div>"
36
+ "<div>Then upscale with <a href='https://huggingface.co/spaces/akhaliq/Real-ESRGAN/blob/main/app.py'>ESRGAN</a></div>"
37
+ )
38
+
39
+ with gr.Row():
40
+ b0 = gr.Button("generate")
41
+ b1 = gr.Button("upscale")
42
+
43
+ with gr.Row():
44
+ desc = gr.Textbox(label="description",placeholder="an impressionist painting of a white vase")
45
+
46
+ with gr.Row():
47
+ intermediate_image = gr.Image(label="portrait",type="filepath", width=256,height=256)
48
+ output_image = gr.Image(label="portrait",type="filepath", width=256,height=256)
49
+
50
+ b0.click(desc_to_image,inputs=[desc],outputs=[intermediate_image])
51
+ b1.click(upscale_img, inputs=[ intermediate_image], outputs=output_image)
52
+ #examples=examples
53
+
54
  demo.launch(enable_queue=True, debug=True)